archive
/
tstatic
Archived
1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
tstatic/src/middleware/404.ts

12 lines
437 B
TypeScript
Raw Normal View History

2017-04-18 13:52:56 +01:00
import * as staticFile from 'connect-static-file';
2017-02-15 07:32:19 +00:00
import { Request, Response } from 'express';
2017-02-19 21:53:06 +00:00
import * as path from 'path';
2017-02-15 07:32:19 +00:00
2017-04-18 13:52:56 +01:00
export default function handle404(serveDir: string) {
2017-02-15 07:32:19 +00:00
const handle404Middleware = staticFile(path.join(serveDir, '.404.html'));
2018-03-15 21:40:35 +00:00
return (request: Request, response: Response, next: () => void) => {
2017-02-15 07:32:19 +00:00
response.statusCode = 404;
return handle404Middleware(request, response, next);
2017-04-18 13:52:56 +01:00
};
2017-02-15 07:32:19 +00:00
}