Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency @types/express to v5 #766

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/sonarscan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
egress-policy: block
allowed-endpoints: >
api.github.com:443
api.sonarcloud.io:443
binaries.sonarsource.com:443
github.com:443
npm.pkg.github.com:443
objects.githubusercontent.com:443
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"license": "MIT",
"devDependencies": {
"@myrotvorets/eslint-config-myrotvorets-ts": "^3.0.0",
"@types/express": "^4.17.21",
"@types/express": "^5.0.0",
"@types/supertest": "^6.0.2",
"c8": "^10.0.0",
"eslint-formatter-gha": "^1.4.3",
Expand Down
16 changes: 10 additions & 6 deletions test/index.test.mts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
/* eslint-disable sonarjs/assertions-in-tests */
import { describe, it } from 'node:test';
import type { RequestListener } from 'node:http';
import request from 'supertest';
import express, { Application, NextFunction, Request, Response } from 'express';
import express, { type NextFunction, type Request, type Response } from 'express';
import { acceptsJsonMiddleware } from '../src/index.mjs';

interface IStatus {
status: number;
}

function buildServer(): Application {
function buildServer(): RequestListener {
const app = express();
app.disable('x-powered-by');
return app.use(
acceptsJsonMiddleware,
(_req: Request, res: Response): unknown => res.json({ status: 200 }),
(err: unknown, _req: Request, res: Response, _next: NextFunction): unknown =>
res.status((err as IStatus).status).json(err),
);
(_req: Request, res: Response) => {
res.json({ status: 200 });
},
(err: unknown, _req: Request, res: Response, _next: NextFunction): void => {
res.status((err as IStatus).status).json(err);
},
) as RequestListener;
}

const server = buildServer();
Expand Down
Loading