Add 404 middleware
This commit is contained in:
parent
26001cadaf
commit
11cacc5e35
2 changed files with 12 additions and 0 deletions
11
src/middleware/404.ts
Normal file
11
src/middleware/404.ts
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
1
src/types/fakes.d.ts
vendored
1
src/types/fakes.d.ts
vendored
|
@ -1,3 +1,4 @@
|
||||||
/* Mock types that dont exist */
|
/* Mock types that dont exist */
|
||||||
|
|
||||||
declare module 'express-ip-access-control';
|
declare module 'express-ip-access-control';
|
||||||
|
declare module 'connect-static-file';
|
||||||
|
|
Reference in a new issue