Created
July 1, 2019 14:09
-
-
Save evdama/dceb726b73cd2df09075ea46ed651929 to your computer and use it in GitHub Desktop.
current server.js created from sapper template a few weeks ago / switch to polka pending
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @ts-nocheck TODO: remove at some point | |
//import config from './config'; | |
import express from 'express'; | |
import sirv from 'sirv'; | |
import session from 'express-session'; | |
import bodyParser from 'body-parser'; | |
import * as sapper from '@sapper/server'; | |
import './css/index.css' | |
const { PORT, NODE_ENV } = process.env; | |
const dev = NODE_ENV === 'development'; | |
const server = express(); // You can also use Express | |
if(dev) server.use(sirv('static', { dev })); | |
server.use( | |
//compression({ threshold: 0 }), | |
bodyParser.json(), | |
session({ | |
secret: 'test', | |
resave: false, | |
saveUninitialized: false | |
}), | |
sapper.middleware({ | |
session: (req, res) => { | |
return {} | |
} | |
}) | |
); | |
if(dev){ | |
// only listen when started in dev | |
server.listen(PORT, err => { | |
if (err) console.log('error', err); | |
}); | |
} | |
export { server }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment