mirror of
https://github.com/kevin-DL/sapper-template.git
synced 2026-01-21 22:15:00 +00:00
use polka again
This commit is contained in:
@@ -1,21 +1,20 @@
|
|||||||
import { resolve } from 'url';
|
import { resolve } from 'url';
|
||||||
import express from 'express';
|
import polka from 'polka';
|
||||||
import compression from 'compression';
|
import compression from 'compression';
|
||||||
import sapper from 'sapper';
|
import sapper from 'sapper';
|
||||||
import serve from 'serve-static';
|
import serve from 'serve-static';
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import { basepath, routes } from './manifest/server.js';
|
import { routes } from './manifest/server.js';
|
||||||
|
|
||||||
const { PORT } = process.env;
|
const { PORT } = process.env;
|
||||||
|
|
||||||
// this allows us to do e.g. `fetch('/api/blog-posts')` on the server
|
// this allows us to do e.g. `fetch('/api/blog-posts')` on the server
|
||||||
global.fetch = (url, opts) => {
|
global.fetch = (url, opts) => {
|
||||||
url = resolve(`http://localhost:${PORT}${basepath}/`, url);
|
url = resolve(`http://localhost:${PORT}/`, url);
|
||||||
return fetch(url, opts);
|
return fetch(url, opts);
|
||||||
};
|
};
|
||||||
|
|
||||||
express()
|
polka()
|
||||||
.use(compression({ threshold: 0 }))
|
.use(compression({ threshold: 0 }))
|
||||||
.use(basepath, serve('assets'))
|
.use(serve('assets'), sapper({ routes }))
|
||||||
.use(sapper({ routes }))
|
|
||||||
.listen(PORT);
|
.listen(PORT);
|
||||||
@@ -14,7 +14,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"compression": "^1.7.1",
|
"compression": "^1.7.1",
|
||||||
"cross-env": "^5.1.3",
|
"cross-env": "^5.1.3",
|
||||||
"express": "^4.16.3",
|
|
||||||
"node-fetch": "^2.0.0",
|
"node-fetch": "^2.0.0",
|
||||||
"npm-run-all": "^4.1.2",
|
"npm-run-all": "^4.1.2",
|
||||||
"polka": "^0.3.4",
|
"polka": "^0.3.4",
|
||||||
|
|||||||
Reference in New Issue
Block a user