bin/routes/main.js

29 lines
754 B
JavaScript

const express = require('express');
const router = express.Router();
const handler = require('express-async-handler');
const content = require('../helpers/content');
const crypto = require('crypto');
async function index(req, res) {
if (!req.session.captcha) {
req.session.captcha = crypto.randomBytes(8).toString('base64').substring(0, 6);
}
req.session.captcha_input = crypto.randomBytes(8).toString('base64').substring(0,10);
if (!req.session.csrf)
req.session.csrf = crypto.randomBytes(10).toString('base64');
res.render('main', {
maxlen: process.env.MAXLEN,
submitted: content.submitted(),
req,
crypto
});
}
router.get('/', handler(index));
module.exports = router;