Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-10-06 11:54:08 +02:00
parent f3463b176b
commit 2d3a5f09ab
18 changed files with 47 additions and 32 deletions
@@ -21,7 +21,7 @@ import { notFoundHandler } from './notFoundHandler';
describe('notFoundHandler', () => {
it('handles only missing routes', async () => {
const app = express();
app.use('/exists', (_, res) => res.status(200).send());
app.use('/exists', (_, res) => res.status(200).end());
app.use(notFoundHandler());
const existsResponse = await request(app).get('/exists');
@@ -28,6 +28,6 @@ import { NextFunction, Request, RequestHandler, Response } from 'express';
export function notFoundHandler(): RequestHandler {
/* eslint-disable @typescript-eslint/no-unused-vars */
return (_request: Request, response: Response, _next: NextFunction) => {
response.status(404).send();
response.status(404).end();
};
}
@@ -26,8 +26,8 @@ describe('requestLoggingHandler', () => {
const app = express();
app.use(requestLoggingHandler(logger));
app.use('/exists1', (_, res) => res.status(200).send());
app.use('/exists2', (_, res) => res.status(201).send());
app.use('/exists1', (_, res) => res.status(200).end());
app.use('/exists2', (_, res) => res.status(201).end());
const r = request(app);
await r.get('/exists1');
@@ -55,7 +55,7 @@ export async function statusCheckHandler(
return async (_request: Request, response: Response, next: NextFunction) => {
try {
const status = await statusCheck();
response.status(200).header('').send(status);
response.status(200).json(status);
} catch (err) {
next(err);
}