Skip to content

Commit

Permalink
Merge pull request #838 from myrotvorets/renovate/express-5.x
Browse files Browse the repository at this point in the history
chore(deps): update dependency @types/express to v5
  • Loading branch information
myrotvorets-team authored Dec 20, 2024
2 parents f4f6ae4 + bfbd32e commit fab4947
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
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 @@ -26,7 +26,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.1.2",
"eslint-formatter-gha": "^1.5.1",
Expand Down
18 changes: 11 additions & 7 deletions test/index.test.mts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { describe, it } from 'node:test';
import type { RequestListener } from 'node:http';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import express, { type Application, type NextFunction, type Request, type Response } from 'express';
import express, { type NextFunction, type Request, type Response } from 'express';
import request from 'supertest';
import { installOpenApiValidator } from '../lib/index.mjs';

interface IWithStatus {
status?: number;
}

function buildServer(install: boolean, env: string): Application {
function buildServer(install: boolean, env: string): RequestListener {
const app = express();
app.set('x-powered-by', false);

if (install) {
app.use(installOpenApiValidator(join(dirname(fileURLToPath(import.meta.url)), 'openapi.yaml'), env));
Expand All @@ -23,13 +25,15 @@ function buildServer(install: boolean, env: string): Application {
});
});

app.get('/auth', (_req, res): unknown => res.status(204).end());
app.get('/auth', (_req, res): void => {
res.status(204).end();
});

app.use((err: unknown, _req: Request, res: Response, _next: NextFunction) =>
res.status((err as IWithStatus).status ?? 500).json(err),
);
app.use((err: unknown, _req: Request, res: Response, _next: NextFunction): void => {
res.status((err as IWithStatus).status ?? 500).json(err);
});

return app;
return app as RequestListener;
}

const keepTSHappy = (): Promise<void> => Promise.resolve();
Expand Down

0 comments on commit fab4947

Please sign in to comment.