vstring-express-mongodb
v1.0.0
Published
MongoDb Verification String Store for vstring-express
Downloads
0
Readme
vstring-express-mongodb
v1.0.0
MongoDb data store for use with vstring-express
Stores verification strings in a MongoDB database.
Can be used as a model for developing new stores for use with vstring-express
.
Quick Start:
- Initialize a Mongo store, and use it to initialize Vstring:
const Vstring = require('vstring-express');
const MongoStore = require('vstring-express-mongodb');
const vstring = new Vstring(
new MongoStore({
uri: process.env.MONGO_URI,
})
);
- Continue using
vstring-express
as explained in its documentation:
const app = express();
app.get('/vstring/:vstring', vstring.intercept);
const {string, expires} = await vstring.newString({
action: 'verify-email',
ttl: 14 * 24 * 60 * 60 * 1000, // 14 days
email:'[email protected]'}
});
const link = `http://${host}/vstring/${string}`;
sendEmail({
to: '[email protected]',
content: `Click: ${link}`,
});
vstring.handle('verify-email', (req, res, next) => {
const {email} = req.vparams;
await markVerified(email);
res.redirect('/email-verified.html');
})
©2024 by Gregory Everett Brandon. See LICENSE.