Skip to content

Instantly share code, notes, and snippets.

@kuc-arc-f
Created May 31, 2021
Embed
What would you like to do?
sapper session use
import sirv from 'sirv';
import polka from 'polka';
import compression from 'compression';
import * as sapper from '@sapper/server';
const { json } = require('body-parser');
var cookieParser = require('cookie-parser');
import session from 'express-session';
const { PORT, NODE_ENV } = process.env;
const dev = NODE_ENV === 'development';
polka() // You can also use Express
.use(json())
.use(
cookieParser(),
session({
secret: 'secret key',
resave: true,
saveUninitialized: true,
cookie: {
//max= 90 days
maxAge: 90 * 24 * 60 * 1000,
}
}),
compression({ threshold: 0 }),
sirv('static', { dev }),
sapper.middleware()
)
.listen(PORT, err => {
if (err) console.log('error', err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment