bin/middleware/index.js

26 lines
752 B
JavaScript
Raw Normal View History

2023-03-04 02:09:05 +01:00
const express = require('express');
const router = express.Router();
2023-03-04 02:31:07 +01:00
const bodyparse = require('body-parser');
router.use(bodyparse.json());
router.use(bodyparse.urlencoded({extended: true}));
2023-03-04 02:09:05 +01:00
2023-04-17 02:37:07 +02:00
const session = require('express-session');
const memcache = require("connect-memcached")(session);
const crypto = require('crypto');
router.use(
session({
secret: process.env.SESSION_SECRET,
secure: true,
resave: false,
saveUninitialized: true,
store: new memcache({
hosts: [process.env.SESSION_MEMCACHE_HOST],
secret: process.env.SESSION_SECRET +
crypto.createHash('sha256', process.env.SESSION_SECRET).digest().toString('hex')
})
})
);
2023-03-04 02:09:05 +01:00
module.exports = router;