Add 404 middleware

This commit is contained in:
Jake Howard 2017-02-15 07:32:19 +00:00
parent 26001cadaf
commit 11cacc5e35
2 changed files with 12 additions and 0 deletions

11
src/middleware/404.ts Normal file
View file

@ -0,0 +1,11 @@
import { Request, Response } from 'express';
import staticFile from 'connect-static-file'
import path from 'path';
export default function handle404(serveDir : string) {
const handle404Middleware = staticFile(path.join(serveDir, '.404.html'));
return function (request : Request, response : Response, next : Function) {
response.statusCode = 404;
return handle404Middleware(request, response, next);
}
}

View file

@ -1,3 +1,4 @@
/* Mock types that dont exist */
declare module 'express-ip-access-control';
declare module 'connect-static-file';