Skip to content

Commit c14fcc3

Browse files
committed
chore: upgrade deps to latest, replace old rollup plugins with the new ones, refactor http-status-codes import
1 parent d814df3 commit c14fcc3

File tree

4 files changed

+1124
-1611
lines changed

4 files changed

+1124
-1611
lines changed

package.json

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,32 @@
2525
"release:patch": "yarn release --release-as patch"
2626
},
2727
"devDependencies": {
28-
"@boringcodes/eslint-config-typescript": "^1.0.0",
29-
"@boringcodes/prettier-config": "^1.0.0",
30-
"@types/express": "^4.16.1",
28+
"@boringcodes/eslint-config-typescript": "^1.2.0",
29+
"@boringcodes/prettier-config": "^1.3.1",
30+
"@rollup/plugin-node-resolve": "^11.0.1",
31+
"@rollup/plugin-typescript": "^8.1.0",
32+
"@types/express": "^4.17.9",
3133
"@types/http-status-codes": "^1.2.0",
32-
"@typescript-eslint/eslint-plugin": "^2.25.0",
33-
"@typescript-eslint/parser": "^2.25.0",
34-
"copyfiles": "^2.2.0",
35-
"eslint": "^6.8.0",
36-
"eslint-config-prettier": "^6.10.1",
37-
"eslint-config-standard-with-typescript": "^15.0.1",
38-
"eslint-plugin-import": "^2.20.1",
39-
"eslint-plugin-node": "^11.0.0",
34+
"@typescript-eslint/eslint-plugin": "^4.12.0",
35+
"@typescript-eslint/parser": "^4.12.0",
36+
"copyfiles": "^2.4.1",
37+
"eslint": "^7.17.0",
38+
"eslint-config-prettier": "^7.1.0",
39+
"eslint-config-standard-with-typescript": "^19.0.1",
40+
"eslint-plugin-import": "^2.22.1",
41+
"eslint-plugin-node": "^11.1.0",
4042
"eslint-plugin-promise": "^4.2.1",
41-
"eslint-plugin-standard": "^4.0.1",
42-
"husky": "^2.3.0",
43-
"lint-staged": "^10.0.9",
44-
"prettier": "^2.0.2",
45-
"rollup": "^1.12.3",
46-
"rollup-plugin-node-resolve": "^5.0.0",
47-
"rollup-plugin-typescript2": "^0.21.1",
48-
"standard-version": "^8.0.1",
49-
"typescript": "^3.8.3"
43+
"eslint-plugin-standard": "^5.0.0",
44+
"husky": "^4.3.7",
45+
"lint-staged": "^10.5.3",
46+
"prettier": "^2.2.1",
47+
"rollup": "^2.36.1",
48+
"standard-version": "^9.1.0",
49+
"tslib": "^2.1.0",
50+
"typescript": "^4.1.3"
5051
},
5152
"dependencies": {
5253
"express": "^4.17.1",
53-
"http-status-codes": "^1.3.2"
54+
"http-status-codes": "^2.1.4"
5455
}
5556
}

rollup.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import resolve from 'rollup-plugin-node-resolve';
2-
import typescript from 'rollup-plugin-typescript2';
1+
import { nodeResolve } from '@rollup/plugin-node-resolve';
2+
import typescript from '@rollup/plugin-typescript';
33

44
import pkg from './package.json';
55

@@ -8,13 +8,14 @@ const getConfig = (inputFile) => ({
88
...Object.keys(pkg.dependencies || {}),
99
...Object.keys(pkg.peerDependencies || {}),
1010
],
11-
plugins: [resolve(), typescript({ useTsconfigDeclarationDir: true })],
11+
plugins: [nodeResolve(), typescript()],
1212
input: inputFile,
1313
output: [
1414
{
1515
dir: 'dist',
1616
format: 'cjs',
1717
sourcemap: true,
18+
exports: 'auto',
1819
},
1920
],
2021
});

src/express.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import { Request, Response, NextFunction, Router } from 'express';
2-
import {
3-
NOT_FOUND,
4-
OK,
5-
INTERNAL_SERVER_ERROR,
6-
getStatusText,
7-
} from 'http-status-codes';
2+
import { StatusCodes, getReasonPhrase } from 'http-status-codes';
83

94
import { MyError, HttpError } from './error';
105
import errorHandler from './errorHandler';
@@ -20,7 +15,7 @@ import errorHandler from './errorHandler';
2015
* @param next Express Next function
2116
*/
2217
const handleNotFound = (_: Request, __: Response, next: NextFunction): void => {
23-
next(new HttpError(NOT_FOUND, 'Resource not found'));
18+
next(new HttpError(StatusCodes.NOT_FOUND, 'Resource not found'));
2419
};
2520

2621
/**
@@ -40,11 +35,13 @@ const handleErrors = (
4035

4136
try {
4237
// check if status code exists, error thrown if doesn't
43-
getStatusText((err as HttpError).code);
38+
getReasonPhrase((err as HttpError).code);
4439

45-
res.status((err as HttpError).code).send(err);
40+
// TODO: as type def of express.Response has problem, tmp casting it to any
41+
(res as any).status((err as HttpError).code).send(err);
4642
} catch (error) {
47-
res.status(INTERNAL_SERVER_ERROR).send(error);
43+
// TODO: as type def of express.Response has problem, tmp casting it to any
44+
(res as any).status(StatusCodes.INTERNAL_SERVER_ERROR).send(error);
4845
}
4946
};
5047

@@ -54,7 +51,8 @@ const handleErrors = (
5451
* @param res Express Response object
5552
*/
5653
const handleHealthCheck = (_: Request, res: Response): void => {
57-
res.status(OK).send('OK');
54+
// TODO: as type def of express.Response has problem, tmp casting it to any
55+
(res as any).status(StatusCodes.OK).send('OK');
5856
};
5957

6058
/**

0 commit comments

Comments
 (0)