1.0.0 • Published 12 months ago

vstring-express-mongodb v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

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:

  1. 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,
    })
);
  1. 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:'someone@example.com'}
});

const link = `http://${host}/vstring/${string}`;

sendEmail({
    to: 'someone@example.com',
    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.

1.0.0

12 months ago

0.0.2

3 years ago

0.0.1

3 years ago