Skip to content

Commit 48d91f6

Browse files
authored
Merge pull request #127 from BinaryStudioAcademy/task/thjs-124-upgrade-nodejs-version-20-lts-with-packages
thjs-124: Upgrade nodejs version 20 lts with packages
2 parents 2b94309 + cdfe19f commit 48d91f6

File tree

23 files changed

+5274
-3895
lines changed

23 files changed

+5274
-3895
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18.18
1+
20.11

apps/backend/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import tsconfigJson from './tsconfig.json' assert { type: 'json' };
77
const sourcePath = join(fileURLToPath(import.meta.url), '../');
88

99
const manageKey = key => {
10-
return key.includes('(.*)') ? key.slice(0, -1) + '\\.js$' : key;
10+
return key.includes('(.*)') ? key.slice(0, -1) + String.raw`\.js$` : key;
1111
};
1212

1313
const manageMapper = mapper => ({

apps/backend/package.json

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"name": "@thread-js/backend",
33
"private": true,
44
"engines": {
5-
"node": "18.18.x",
6-
"npm": "9.8.x"
5+
"node": "20.11.x",
6+
"npm": "10.2.x"
77
},
88
"type": "module",
99
"scripts": {
@@ -15,7 +15,7 @@
1515
"migrate:dev:unlock": "npm run knex migrate:unlock",
1616
"migrate:dev:reset": "npm run migrate:dev:rollback && npm run migrate:dev",
1717
"seed:run": "npm run knex seed:run",
18-
"start:dev": "nodemon --exec \"node --loader ts-paths-esm-loader\" ./src/main.ts",
18+
"start:dev": "tsx watch ./src/index.ts",
1919
"lint:type": "npx tsc --noEmit",
2020
"lint:js": "npx eslint . --max-warnings=0",
2121
"lint": "concurrently \"npm:lint:*\"",
@@ -25,30 +25,29 @@
2525
"test:auth": "npm run test -- --verbose --rootDir=tests/modules/auth/"
2626
},
2727
"dependencies": {
28-
"@fastify/static": "6.12.0",
28+
"@fastify/static": "7.0.4",
2929
"@thread-js/shared": "*",
3030
"convict": "6.2.4",
31-
"dotenv": "16.3.1",
32-
"fastify": "4.25.1",
31+
"dotenv": "16.4.5",
32+
"fastify": "4.27.0",
3333
"knex": "3.1.0",
34-
"objection": "3.1.3",
35-
"pg": "8.7.3",
34+
"objection": "3.1.4",
35+
"pg": "8.12.0",
3636
"pino": "9.1.0",
37-
"qs": "6.11.2"
37+
"qs": "6.12.1"
3838
},
3939
"devDependencies": {
40-
"@faker-js/faker": "8.3.1",
40+
"@faker-js/faker": "8.4.1",
4141
"@jest/globals": "29.7.0",
4242
"@types/convict": "6.1.6",
43-
"@types/jest": "29.5.11",
44-
"@types/pg": "8.10.9",
45-
"@types/qs": "6.9.10",
43+
"@types/jest": "29.5.12",
44+
"@types/pg": "8.11.6",
45+
"@types/qs": "6.9.15",
4646
"cross-env": "7.0.3",
4747
"jest": "29.7.0",
48-
"nodemon": "3.0.2",
49-
"pino-pretty": "10.3.0",
50-
"ts-jest": "29.1.1",
51-
"ts-node": "10.9.2",
52-
"ts-paths-esm-loader": "1.4.3"
48+
"pino-pretty": "11.2.0",
49+
"ts-jest": "29.1.4",
50+
"ts-paths-esm-loader": "1.4.3",
51+
"tsx": "4.15.1"
5352
}
5453
}

apps/backend/src/libs/modules/logger/logger.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { type Logger as LibraryLogger, pino } from 'pino';
2-
import pretty from 'pino-pretty';
32

43
import { type LoggerModule } from './libs/types/types.js';
54

65
class Logger implements LoggerModule {
76
private logger: LibraryLogger;
87

98
public constructor() {
10-
this.logger = pino(pretty.default());
9+
this.logger = pino({ transport: { target: 'pino-pretty' } });
1110

1211
this.logger.info('Logger is created…');
1312
}

apps/backend/src/modules/user/libs/types/user-repository.type.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { type User } from './types.js';
44

55
type UserRepository = {
66
getByEmail(_email: string): Promise<User | null>;
7-
8-
getByUsername(_username: string): Promise<User | null>;
97
} & Pick<Repository<User>, 'create'>;
108

119
export { type UserRepository };

apps/backend/src/modules/user/user.repository.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ class User
2121

2222
return user ?? null;
2323
}
24-
25-
public async getByUsername(username: string): Promise<TUser | null> {
26-
const user = await this.model.query().select().findOne({ username });
27-
28-
return user ?? null;
29-
}
3024
}
3125

3226
export { User };

apps/backend/tests/libs/modules/app/libs/helpers/build-app/build-app.helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const buildApp: BuildApp = () => {
2525
database,
2626
logger,
2727
options: {
28-
logger: true
28+
logger: false
2929
}
3030
});
3131

apps/backend/tests/modules/auth/auth.api.spec.ts

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -42,53 +42,6 @@ describe(`${authApiPath} routes`, () => {
4242
describe(`${registerEndpoint} (${HTTPMethod.POST}) endpoint`, () => {
4343
const app = getApp();
4444

45-
it(`should return ${HTTPCode.UNPROCESSED_ENTITY} of empty ${UserPayloadKey.USERNAME} validation error`, async () => {
46-
const response = await app.inject().post(registerEndpoint).body({});
47-
48-
expect(response.statusCode).toBe(HTTPCode.UNPROCESSED_ENTITY);
49-
expect(response.json<Record<'message', string>>().message).toBe(
50-
`${UserValidationMessage.USERNAME_REQUIRE}. ${UserValidationMessage.EMAIL_REQUIRE}. ${UserValidationMessage.PASSWORD_REQUIRE}`
51-
);
52-
});
53-
54-
it(`should return ${HTTPCode.UNPROCESSED_ENTITY} of too short ${UserPayloadKey.USERNAME} validation error`, async () => {
55-
const [validTestUser] = TEST_USERS_CREDENTIALS;
56-
57-
const response = await app
58-
.inject()
59-
.post(registerEndpoint)
60-
.body({
61-
...validTestUser,
62-
[UserPayloadKey.USERNAME]: faker.string.alpha(
63-
UserValidationRule.USERNAME_MIN_LENGTH - VALIDATION_RULE_DELTA
64-
)
65-
});
66-
67-
expect(response.statusCode).toBe(HTTPCode.UNPROCESSED_ENTITY);
68-
expect(response.json<Record<'message', string>>().message).toBe(
69-
UserValidationMessage.USERNAME_MIN_LENGTH
70-
);
71-
});
72-
73-
it(`should return ${HTTPCode.UNPROCESSED_ENTITY} of too long ${UserPayloadKey.USERNAME} validation error`, async () => {
74-
const [validTestUser] = TEST_USERS_CREDENTIALS;
75-
76-
const response = await app
77-
.inject()
78-
.post(registerEndpoint)
79-
.body({
80-
...validTestUser,
81-
[UserPayloadKey.USERNAME]: faker.string.alpha(
82-
UserValidationRule.USERNAME_MAX_LENGTH + VALIDATION_RULE_DELTA
83-
)
84-
});
85-
86-
expect(response.statusCode).toBe(HTTPCode.UNPROCESSED_ENTITY);
87-
expect(response.json<Record<'message', string>>().message).toBe(
88-
UserValidationMessage.USERNAME_MAX_LENGTH
89-
);
90-
});
91-
9245
it(`should return ${HTTPCode.UNPROCESSED_ENTITY} of empty ${UserPayloadKey.EMAIL} validation error`, async () => {
9346
const [validTestUser] = TEST_USERS_CREDENTIALS;
9447
const { [UserPayloadKey.EMAIL]: _email, ...user } =
@@ -183,8 +136,7 @@ describe(`${authApiPath} routes`, () => {
183136
expect(response.statusCode).toBe(HTTPCode.CREATED);
184137
expect(response.json()).toEqual(
185138
expect.objectContaining({
186-
[UserPayloadKey.EMAIL]: validTestUser[UserPayloadKey.EMAIL],
187-
[UserPayloadKey.USERNAME]: validTestUser[UserPayloadKey.USERNAME]
139+
[UserPayloadKey.EMAIL]: validTestUser[UserPayloadKey.EMAIL]
188140
})
189141
);
190142

@@ -196,8 +148,7 @@ describe(`${authApiPath} routes`, () => {
196148

197149
expect(savedDatabaseUser).toEqual(
198150
expect.objectContaining({
199-
[UserPayloadKey.EMAIL]: validTestUser[UserPayloadKey.EMAIL],
200-
[UserPayloadKey.USERNAME]: validTestUser[UserPayloadKey.USERNAME]
151+
[UserPayloadKey.EMAIL]: validTestUser[UserPayloadKey.EMAIL]
201152
})
202153
);
203154
});

apps/backend/tests/modules/user/libs/constants/test-user-credentials.constant.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ const TEST_USERS_CREDENTIALS = Array.from(
1010
(): UserSignUpRequestDto => {
1111
return {
1212
[UserPayloadKey.EMAIL]: faker.internet.email(),
13-
[UserPayloadKey.PASSWORD]: faker.internet.password(),
14-
[UserPayloadKey.USERNAME]: faker.person.firstName()
13+
[UserPayloadKey.PASSWORD]: faker.internet.password()
1514
};
1615
}
1716
);

0 commit comments

Comments
 (0)