@highoutput/email-auth
v0.7.7
Published
server middleware for email authentication
Downloads
1
Keywords
Readme
email-auth
TODO: description
Usage
import EmailAuthentication from '@highoutput-library/email-auth';
const PERSISTENCE_CONFIG = {
db: mongoose.connection,
userCollectionString: 'users',
};
const persistenceAdapter = new MongooseAdapter(PERSISTENCE_CONFIG);
const EMAIL_PROVIDER_CONFIG = {
apiKey: process.env.SENDGRID_API_KEY as string,
from: {
email: process.env.SENDER_EMAIL as string || '[email protected]',
name: process.env.SENDER_NAME as string || 'no-reply',
}
};
const emailProviderAdapter = new SendGridAdapter(EMAIL_PROVIDER_CONFIG);
const server = http.createServer();
const emailAuthentication = new EmailAuthentication({
server,
persistenceAdapter,
emailProviderAdapter,
jwtSecretKey: 'SECRET',
});
emailAuthentication.use();
generateOtp
// POST localhost:8080/generateOtp
{
"message": {
"to": "[email protected]"
}
}
validateOtp
// POST localhost:8080/validateOtp
{
"email": "[email protected]",
"otp": "257057"
}