Created
July 10, 2019 02:43
-
-
Save evdama/dd06225d9d55b4ab8949502f2c37d416 to your computer and use it in GitHub Desktop.
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 once there are typings in place | |
import './css/tailwind.css'; | |
import * as sapper from '@sapper/server'; | |
import compression from 'compression'; | |
import express from 'express'; | |
import helmet from "helmet"; | |
import sirv from 'sirv'; | |
import uuidv4 from 'uuid/v4'; | |
const { | |
PORT, | |
NODE_ENV | |
} = process.env; | |
const dev = NODE_ENV === 'development'; | |
const app = express(); | |
if ( dev ) app.use( sirv( 'static', { dev } ) ); | |
app.use( ( request, response, next ) => { | |
response.locals.nonce = uuidv4(); | |
next(); | |
} ); | |
app.use( | |
helmet( | |
// { | |
// contentSecurityPolicy: { | |
// directives: { | |
// scriptSrc: [ | |
// "'self'", | |
// ( request, response ) => `'nonce-${response.locals.nonce}'` | |
// ] | |
// }, | |
// browserSniff: false | |
// } | |
// } | |
), | |
sapper.middleware(), | |
compression({ threshold: 0 }) | |
); | |
if ( dev ) { | |
// only listen when started in dev | |
app.listen( PORT, err => { | |
if ( err ) console.log( 'error', err ); | |
} ); | |
} | |
export { | |
app | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment