mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-18 05:25:08 +00:00
tidy up - next is unused
This commit is contained in:
@@ -115,7 +115,7 @@ function get_asset_handler({ pathname, type, cache, body }: {
|
|||||||
const resolved = Promise.resolve();
|
const resolved = Promise.resolve();
|
||||||
|
|
||||||
function get_route_handler(chunks: Record<string, string>, routes: RouteObject[], template: Template) {
|
function get_route_handler(chunks: Record<string, string>, routes: RouteObject[], template: Template) {
|
||||||
function handle_route(route: RouteObject, req: Req, res: ServerResponse, next: () => void) {
|
function handle_route(route: RouteObject, req: Req, res: ServerResponse) {
|
||||||
req.params = route.params(route.pattern.exec(req.pathname));
|
req.params = route.params(route.pattern.exec(req.pathname));
|
||||||
|
|
||||||
const mod = route.module;
|
const mod = route.module;
|
||||||
@@ -234,7 +234,7 @@ function get_route_handler(chunks: Record<string, string>, routes: RouteObject[]
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const handle_error = err => {
|
const handle_error = (err?: Error) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err.stack);
|
console.error(err.stack);
|
||||||
res.statusCode = 500;
|
res.statusCode = 500;
|
||||||
@@ -306,12 +306,12 @@ function get_route_handler(chunks: Record<string, string>, routes: RouteObject[]
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
return function find_route(req: Req, res: ServerResponse, next: () => void) {
|
return function find_route(req: Req, res: ServerResponse) {
|
||||||
const url = req.pathname;
|
const url = req.pathname;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const route of routes) {
|
for (const route of routes) {
|
||||||
if (!route.error && route.pattern.test(url)) return handle_route(route, req, res, next);
|
if (!route.error && route.pattern.test(url)) return handle_route(route, req, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_not_found(req, res, 404, 'Not found');
|
handle_not_found(req, res, 404, 'Not found');
|
||||||
|
|||||||
Reference in New Issue
Block a user