Sapper: Incorporate sirv

Created on 5 May 2019  路  2Comments  路  Source: sveltejs/sapper

Given that the static folder has special meaning (e.g. it's used to determine what should go in the service worker manifest) it probably makes sense just to include sirv inside Sapper, rather than having it in the project template separately.

That way, the simplest possible Sapper server could look roughly like this:

import * as http from 'http';
import * as sapper from '@sapper/server';

http.createServer(sapper.middleware()).listen(process.env.PORT);
internals proposal

Most helpful comment

We can also try to replace http with https://github.com/uNetworking/uWebSockets.js which is much faster than node http.

All 2 comments

Its a great idea but we should be able to use other middlewares. We can also include http inside sapper.
````
import * as sapper from '@sapper/server';
import bodyParser from 'body-parser';
import helmet from 'helmet';

sapper.use(bodyParser.json())
sapper.use(helmet())
sapper.session((req, res) => ({
user: req.user
}))

sapper.start(process.env.PORT);
````

We can also try to replace http with https://github.com/uNetworking/uWebSockets.js which is much faster than node http.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

keyvan-m-sadeghi picture keyvan-m-sadeghi  路  4Comments

matt3224 picture matt3224  路  4Comments

freedmand picture freedmand  路  4Comments

nikku picture nikku  路  4Comments

Rich-Harris picture Rich-Harris  路  4Comments