rebundle when routes and templates change

This commit is contained in:
Rich Harris
2017-12-20 17:34:23 -05:00
parent cd91bf2ca4
commit fefb0d96d7
9 changed files with 257 additions and 73 deletions

View File

@@ -59,7 +59,7 @@ function connect_dev() {
get_route_handler(() => asset_cache),
not_found
get_not_found_handler(() => asset_cache)
]);
}
@@ -95,7 +95,7 @@ function connect_prod() {
get_route_handler(() => asset_cache),
not_found
get_not_found_handler(() => asset_cache)
]);
}
@@ -174,13 +174,18 @@ function get_route_handler(fn) {
}
}
function not_found(req, res) {
res.status(404).end(templates.render(404, {
title: 'Not found',
status: 404,
method: req.method,
url: req.url
}));
function get_not_found_handler(fn) {
return function handle_not_found(req, res) {
const asset_cache = fn();
res.status(404).end(templates.render(404, {
title: 'Not found',
status: 404,
method: req.method,
main: asset_cache.client.main_file,
url: req.url
}));
}
}
function compose_handlers(handlers) {