Skip to content

Commit 3d67ef3

Browse files
authored
Merge pull request #18 from afteracademy/upgrade-libs
upgrade all libs
2 parents 6444606 + 740b9ea commit 3d67ef3

File tree

25 files changed

+2874
-2306
lines changed

25 files changed

+2874
-2306
lines changed

.eslintrc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
22
"rules": {
3-
"semi": ["error", "always"],
4-
"@typescript-eslint/ban-ts-ignore": "off",
5-
"@typescript-eslint/no-var-requires": "off",
3+
"@typescript-eslint/naming-convention": "off",
4+
"@typescript-eslint/ban-ts-comment": "off",
65
"@typescript-eslint/no-explicit-any": "off",
7-
"@typescript-eslint/explicit-function-return-type": "off",
8-
"@typescript-eslint/no-use-before-define": "off"
6+
"@typescript-eslint/explicit-function-return-types": "off",
7+
"@typescript-eslint/explicit-module-boundary-types": "off"
98
},
109
"extends": [
1110
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
.idea
33

44
# ignore vs code project config files
5-
.vscode/settings.json
65
.vs
76

87
# ignore logs

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"javascript.validate.enable": true,
3+
"typescript.preferences.importModuleSpecifier": "relative",
4+
"editor.defaultFormatter": "esbenp.prettier-vscode",
5+
"editor.insertSpaces": true,
6+
"editor.detectIndentation": false,
7+
"editor.tabSize": 2,
8+
"typescript.validate.enable": true,
9+
"typescript.tsdk": "node_modules/typescript/lib"
10+
}

package-lock.json

Lines changed: 2754 additions & 2216 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
"scripts": {
77
"start": "npm run build && npm run serve",
88
"serve": "node -r dotenv/config build/server.js",
9-
"build": "npm run build-ts",
9+
"build": "npm run clean && npm run build-ts",
1010
"watch": "concurrently -k -p \"[{name}]\" -n \"TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-ts\" \"npm run watch-node\"",
1111
"watch-node": "nodemon -r dotenv/config build/server.js",
12+
"clean": "rimraf ./build",
1213
"build-ts": "tsc",
1314
"watch-ts": "tsc -w",
1415
"eslint": "eslint . --ext .js,.ts",
16+
"upgrade": "npm update --save-dev && npm update --save",
1517
"test": "jest --forceExit --detectOpenHandles --coverage --verbose"
1618
},
1719
"repository": {
@@ -22,48 +24,48 @@
2224
"license": "Apache-2.0",
2325
"dependencies": {
2426
"@hapi/joi": "^17.1.1",
25-
"bcrypt": "^4.0.1",
27+
"bcrypt": "^5.0.0",
2628
"body-parser": "^1.19.0",
2729
"cookie-parser": "^1.4.5",
2830
"cors": "^2.8.5",
2931
"express": "^4.17.1",
30-
"helmet": "^3.21.3",
32+
"helmet": "^4.1.1",
3133
"jsonwebtoken": "^8.5.1",
32-
"lodash": "^4.17.15",
33-
"mongoose": "^5.9.5",
34-
"winston": "^3.2.1",
35-
"winston-daily-rotate-file": "^4.4.2"
34+
"lodash": "^4.17.20",
35+
"mongoose": "^5.10.11",
36+
"winston": "^3.3.3",
37+
"winston-daily-rotate-file": "^4.5.0"
3638
},
3739
"devDependencies": {
3840
"@types/bcrypt": "^3.0.0",
3941
"@types/body-parser": "^1.19.0",
4042
"@types/cookie-parser": "^1.4.2",
41-
"@types/cors": "^2.8.6",
42-
"@types/express": "^4.17.3",
43-
"@types/hapi__joi": "^16.0.12",
44-
"@types/helmet": "0.0.45",
45-
"@types/jest": "^25.1.4",
46-
"@types/jsonwebtoken": "^8.3.8",
47-
"@types/lodash": "^4.14.149",
48-
"@types/mongoose": "^5.7.7",
49-
"@types/morgan": "^1.9.0",
50-
"@types/node": "^13.9.3",
51-
"@types/supertest": "^2.0.8",
52-
"@typescript-eslint/eslint-plugin": "^2.29.0",
53-
"@typescript-eslint/parser": "^2.29.0",
43+
"@types/cors": "^2.8.8",
44+
"@types/express": "^4.17.8",
45+
"@types/hapi__joi": "^17.1.6",
46+
"@types/helmet": "^4.0.0",
47+
"@types/jest": "^26.0.15",
48+
"@types/jsonwebtoken": "^8.5.0",
49+
"@types/lodash": "^4.14.163",
50+
"@types/mongoose": "^5.7.36",
51+
"@types/morgan": "^1.9.2",
52+
"@types/node": "^14.14.6",
53+
"@types/supertest": "^2.0.10",
54+
"@typescript-eslint/eslint-plugin": "^4.6.0",
55+
"@typescript-eslint/parser": "^4.6.0",
5456
"colors": "^1.4.0",
57+
"concurrently": "^5.3.0",
5558
"dotenv": "^8.2.0",
56-
"eslint": "^6.8.0",
57-
"eslint-config-prettier": "^6.11.0",
58-
"eslint-plugin-prettier": "^3.1.3",
59-
"jest": "^25.2.1",
60-
"nodemon": "^2.0.2",
61-
"prettier": "^2.0.5",
62-
"supertest": "^4.0.2",
63-
"ts-jest": "^25.2.1",
64-
"ts-node": "^8.8.1",
59+
"eslint": "^7.12.1",
60+
"eslint-config-prettier": "^6.15.0",
61+
"eslint-plugin-prettier": "^3.1.4",
62+
"jest": "^26.6.1",
63+
"nodemon": "^2.0.6",
64+
"prettier": "^2.1.2",
65+
"supertest": "^6.0.0",
66+
"ts-jest": "^26.4.3",
67+
"ts-node": "^9.0.0",
6568
"tslint": "^6.1.0",
66-
"typescript": "^3.8.3",
67-
"concurrently": "^5.3.0"
69+
"typescript": "^4.0.5"
6870
}
6971
}

src/auth/apikey.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const router = express.Router();
1212
export default router.use(
1313
validator(schema.apiKey, ValidationSource.HEADER),
1414
asyncHandler(async (req: PublicRequest, res, next) => {
15+
// @ts-ignore
1516
req.apiKey = req.headers['x-api-key'].toString();
1617

1718
const apiKey = await ApiKeyRepo.findByKey(req.apiKey);

src/auth/authUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Types } from 'mongoose';
55
import User from '../database/model/User';
66
import { tokenInfo } from '../config';
77

8-
export const getAccessToken = (authorization: string) => {
8+
export const getAccessToken = (authorization?: string) => {
99
if (!authorization) throw new AuthFailureError('Invalid Authorization');
1010
if (!authorization.startsWith('Bearer ')) throw new AuthFailureError('Invalid Authorization');
1111
return authorization.split(' ')[1];

src/config.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ export const environment = process.env.NODE_ENV;
33
export const port = process.env.PORT;
44

55
export const db = {
6-
name: process.env.DB_NAME,
7-
host: process.env.DB_HOST,
8-
port: process.env.DB_PORT,
9-
user: process.env.DB_USER,
10-
password: process.env.DB_USER_PWD,
6+
name: process.env.DB_NAME || '',
7+
host: process.env.DB_HOST || '',
8+
port: process.env.DB_PORT || '',
9+
user: process.env.DB_USER || '',
10+
password: process.env.DB_USER_PWD || '',
1111
};
1212

1313
export const corsUrl = process.env.CORS_URL;
1414

1515
export const tokenInfo = {
16-
accessTokenValidityDays: parseInt(process.env.ACCESS_TOKEN_VALIDITY_DAYS),
17-
refreshTokenValidityDays: parseInt(process.env.REFRESH_TOKEN_VALIDITY_DAYS),
18-
issuer: process.env.TOKEN_ISSUER,
19-
audience: process.env.TOKEN_AUDIENCE,
16+
accessTokenValidityDays: parseInt(process.env.ACCESS_TOKEN_VALIDITY_SEC || '0'),
17+
refreshTokenValidityDays: parseInt(process.env.REFRESH_TOKEN_VALIDITY_SEC || '0'),
18+
issuer: process.env.TOKEN_ISSUER || '',
19+
audience: process.env.TOKEN_AUDIENCE || '',
2020
};
2121

2222
export const logDirectory = process.env.LOG_DIR;

src/core/ApiResponse.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ abstract class ApiResponse {
3535
private static sanitize<T extends ApiResponse>(response: T): T {
3636
const clone: T = {} as T;
3737
Object.assign(clone, response);
38-
// delete {some_field};
38+
// @ts-ignore
3939
delete clone.status;
4040
for (const i in clone) if (typeof clone[i] === 'undefined') delete clone[i];
4141
return clone;
@@ -49,14 +49,14 @@ export class AuthFailureResponse extends ApiResponse {
4949
}
5050

5151
export class NotFoundResponse extends ApiResponse {
52-
private url: string;
52+
private url: string | undefined;
5353

5454
constructor(message = 'Not Found') {
5555
super(StatusCode.FAILURE, ResponseStatus.NOT_FOUND, message);
5656
}
5757

5858
send(res: Response): Response {
59-
this.url = res.req.originalUrl;
59+
this.url = res.req?.originalUrl;
6060
return super.prepare<NotFoundResponse>(res, this);
6161
}
6262
}

src/database/model/Blog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default interface Blog extends Document {
88
title: string;
99
description: string;
1010
text?: string;
11-
draftText: string;
11+
draftText?: string;
1212
tags: string[];
1313
author: User;
1414
imgUrl?: string;

0 commit comments

Comments
 (0)