Skip to content

Commit

Permalink
Merge pull request #127 from BinaryStudioAcademy/task/thjs-124-upgrad…
Browse files Browse the repository at this point in the history
…e-nodejs-version-20-lts-with-packages

thjs-124: Upgrade nodejs version 20 lts with packages
  • Loading branch information
v0ldemar01 authored Jun 11, 2024
2 parents 2b94309 + cdfe19f commit 48d91f6
Show file tree
Hide file tree
Showing 23 changed files with 5,274 additions and 3,895 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.18
20.11
2 changes: 1 addition & 1 deletion apps/backend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import tsconfigJson from './tsconfig.json' assert { type: 'json' };
const sourcePath = join(fileURLToPath(import.meta.url), '../');

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

const manageMapper = mapper => ({
Expand Down
35 changes: 17 additions & 18 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@thread-js/backend",
"private": true,
"engines": {
"node": "18.18.x",
"npm": "9.8.x"
"node": "20.11.x",
"npm": "10.2.x"
},
"type": "module",
"scripts": {
Expand All @@ -15,7 +15,7 @@
"migrate:dev:unlock": "npm run knex migrate:unlock",
"migrate:dev:reset": "npm run migrate:dev:rollback && npm run migrate:dev",
"seed:run": "npm run knex seed:run",
"start:dev": "nodemon --exec \"node --loader ts-paths-esm-loader\" ./src/main.ts",
"start:dev": "tsx watch ./src/index.ts",
"lint:type": "npx tsc --noEmit",
"lint:js": "npx eslint . --max-warnings=0",
"lint": "concurrently \"npm:lint:*\"",
Expand All @@ -25,30 +25,29 @@
"test:auth": "npm run test -- --verbose --rootDir=tests/modules/auth/"
},
"dependencies": {
"@fastify/static": "6.12.0",
"@fastify/static": "7.0.4",
"@thread-js/shared": "*",
"convict": "6.2.4",
"dotenv": "16.3.1",
"fastify": "4.25.1",
"dotenv": "16.4.5",
"fastify": "4.27.0",
"knex": "3.1.0",
"objection": "3.1.3",
"pg": "8.7.3",
"objection": "3.1.4",
"pg": "8.12.0",
"pino": "9.1.0",
"qs": "6.11.2"
"qs": "6.12.1"
},
"devDependencies": {
"@faker-js/faker": "8.3.1",
"@faker-js/faker": "8.4.1",
"@jest/globals": "29.7.0",
"@types/convict": "6.1.6",
"@types/jest": "29.5.11",
"@types/pg": "8.10.9",
"@types/qs": "6.9.10",
"@types/jest": "29.5.12",
"@types/pg": "8.11.6",
"@types/qs": "6.9.15",
"cross-env": "7.0.3",
"jest": "29.7.0",
"nodemon": "3.0.2",
"pino-pretty": "10.3.0",
"ts-jest": "29.1.1",
"ts-node": "10.9.2",
"ts-paths-esm-loader": "1.4.3"
"pino-pretty": "11.2.0",
"ts-jest": "29.1.4",
"ts-paths-esm-loader": "1.4.3",
"tsx": "4.15.1"
}
}
File renamed without changes.
3 changes: 1 addition & 2 deletions apps/backend/src/libs/modules/logger/logger.module.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { type Logger as LibraryLogger, pino } from 'pino';
import pretty from 'pino-pretty';

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

class Logger implements LoggerModule {
private logger: LibraryLogger;

public constructor() {
this.logger = pino(pretty.default());
this.logger = pino({ transport: { target: 'pino-pretty' } });

this.logger.info('Logger is created…');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { type User } from './types.js';

type UserRepository = {
getByEmail(_email: string): Promise<User | null>;

getByUsername(_username: string): Promise<User | null>;
} & Pick<Repository<User>, 'create'>;

export { type UserRepository };
6 changes: 0 additions & 6 deletions apps/backend/src/modules/user/user.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ class User

return user ?? null;
}

public async getByUsername(username: string): Promise<TUser | null> {
const user = await this.model.query().select().findOne({ username });

return user ?? null;
}
}

export { User };
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const buildApp: BuildApp = () => {
database,
logger,
options: {
logger: true
logger: false
}
});

Expand Down
53 changes: 2 additions & 51 deletions apps/backend/tests/modules/auth/auth.api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,53 +42,6 @@ describe(`${authApiPath} routes`, () => {
describe(`${registerEndpoint} (${HTTPMethod.POST}) endpoint`, () => {
const app = getApp();

it(`should return ${HTTPCode.UNPROCESSED_ENTITY} of empty ${UserPayloadKey.USERNAME} validation error`, async () => {
const response = await app.inject().post(registerEndpoint).body({});

expect(response.statusCode).toBe(HTTPCode.UNPROCESSED_ENTITY);
expect(response.json<Record<'message', string>>().message).toBe(
`${UserValidationMessage.USERNAME_REQUIRE}. ${UserValidationMessage.EMAIL_REQUIRE}. ${UserValidationMessage.PASSWORD_REQUIRE}`
);
});

it(`should return ${HTTPCode.UNPROCESSED_ENTITY} of too short ${UserPayloadKey.USERNAME} validation error`, async () => {
const [validTestUser] = TEST_USERS_CREDENTIALS;

const response = await app
.inject()
.post(registerEndpoint)
.body({
...validTestUser,
[UserPayloadKey.USERNAME]: faker.string.alpha(
UserValidationRule.USERNAME_MIN_LENGTH - VALIDATION_RULE_DELTA
)
});

expect(response.statusCode).toBe(HTTPCode.UNPROCESSED_ENTITY);
expect(response.json<Record<'message', string>>().message).toBe(
UserValidationMessage.USERNAME_MIN_LENGTH
);
});

it(`should return ${HTTPCode.UNPROCESSED_ENTITY} of too long ${UserPayloadKey.USERNAME} validation error`, async () => {
const [validTestUser] = TEST_USERS_CREDENTIALS;

const response = await app
.inject()
.post(registerEndpoint)
.body({
...validTestUser,
[UserPayloadKey.USERNAME]: faker.string.alpha(
UserValidationRule.USERNAME_MAX_LENGTH + VALIDATION_RULE_DELTA
)
});

expect(response.statusCode).toBe(HTTPCode.UNPROCESSED_ENTITY);
expect(response.json<Record<'message', string>>().message).toBe(
UserValidationMessage.USERNAME_MAX_LENGTH
);
});

it(`should return ${HTTPCode.UNPROCESSED_ENTITY} of empty ${UserPayloadKey.EMAIL} validation error`, async () => {
const [validTestUser] = TEST_USERS_CREDENTIALS;
const { [UserPayloadKey.EMAIL]: _email, ...user } =
Expand Down Expand Up @@ -183,8 +136,7 @@ describe(`${authApiPath} routes`, () => {
expect(response.statusCode).toBe(HTTPCode.CREATED);
expect(response.json()).toEqual(
expect.objectContaining({
[UserPayloadKey.EMAIL]: validTestUser[UserPayloadKey.EMAIL],
[UserPayloadKey.USERNAME]: validTestUser[UserPayloadKey.USERNAME]
[UserPayloadKey.EMAIL]: validTestUser[UserPayloadKey.EMAIL]
})
);

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

expect(savedDatabaseUser).toEqual(
expect.objectContaining({
[UserPayloadKey.EMAIL]: validTestUser[UserPayloadKey.EMAIL],
[UserPayloadKey.USERNAME]: validTestUser[UserPayloadKey.USERNAME]
[UserPayloadKey.EMAIL]: validTestUser[UserPayloadKey.EMAIL]
})
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ const TEST_USERS_CREDENTIALS = Array.from(
(): UserSignUpRequestDto => {
return {
[UserPayloadKey.EMAIL]: faker.internet.email(),
[UserPayloadKey.PASSWORD]: faker.internet.password(),
[UserPayloadKey.USERNAME]: faker.person.firstName()
[UserPayloadKey.PASSWORD]: faker.internet.password()
};
}
);
Expand Down
36 changes: 18 additions & 18 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@thread-js/frontend",
"private": true,
"engines": {
"node": "18.18.x",
"npm": "9.8.x"
"node": "20.11.x",
"npm": "10.2.x"
},
"type": "module",
"scripts": {
Expand All @@ -17,14 +17,14 @@
},
"dependencies": {
"@hookform/error-message": "2.0.1",
"@hookform/resolvers": "3.3.2",
"@reduxjs/toolkit": "2.0.1",
"@hookform/resolvers": "3.6.0",
"@reduxjs/toolkit": "2.2.5",
"@thread-js/shared": "*",
"clsx": "2.0.0",
"query-string": "8.1.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "7.49.2",
"clsx": "2.1.1",
"query-string": "9.0.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-hook-form": "7.51.5",
"react-redux": "9.1.2",
"react-router-dom": "6.23.1"
},
Expand All @@ -35,16 +35,16 @@
"not op_mini all"
],
"devDependencies": {
"@types/react": "18.2.45",
"@types/react-dom": "18.2.18",
"@vitejs/plugin-react": "4.2.1",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@vitejs/plugin-react": "4.3.1",
"eslint-plugin-jsx-a11y": "6.8.0",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react": "7.34.2",
"eslint-plugin-react-hooks": "4.6.2",
"sass": "1.69.5",
"stylelint-config-standard-scss": "12.0.0",
"stylelint-scss": "6.0.0",
"vite": "5.0.10",
"vite-tsconfig-paths": "4.2.2"
"sass": "1.77.4",
"stylelint-config-standard-scss": "13.1.0",
"stylelint-scss": "6.3.1",
"vite": "5.2.13",
"vite-tsconfig-paths": "4.3.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { UserPayloadKey } from '~/modules/user/enums/enums.js';

const DEFAULT_REGISTRATION_PAYLOAD = {
[UserPayloadKey.EMAIL]: '',
[UserPayloadKey.PASSWORD]: '',
[UserPayloadKey.USERNAME]: ''
[UserPayloadKey.PASSWORD]: ''
};

export { DEFAULT_REGISTRATION_PAYLOAD };
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ const SignUpForm: React.FC<Properties> = ({ onSubmit }) => {
<h2 className={styles['title']}>Register for free account</h2>
<form name="registrationForm" onSubmit={handleSubmit(handleFormSubmit)}>
<fieldset className={styles['fieldset']} disabled={isLoading}>
<Input
control={control}
errors={errors}
name={UserPayloadKey.USERNAME}
placeholder="Username"
type="text"
/>
<Input
control={control}
errors={errors}
Expand Down
6 changes: 6 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const unicornConfig = {
},
rules: {
...unicorn.configs.recommended.rules,
'unicorn/import-style': ['off'],
'unicorn/no-null': ['off']
}
};
Expand Down Expand Up @@ -200,6 +201,11 @@ const typescriptConfig = {
prev: '*'
}
],
'@typescript-eslint/restrict-plus-operands': ['off'],
'@typescript-eslint/restrict-template-expressions': [
'error',
{ allowNumber: true }
],
'@typescript-eslint/return-await': ['error', 'always']
}
};
Expand Down
3 changes: 2 additions & 1 deletion knip.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const config: KnipConfig = {
},
'apps/backend': {
entry: ['src/index.ts', 'src/db/**/*.ts', 'knexfile.ts'],
ignoreBinaries: ['ts-paths-esm-loader']
ignoreBinaries: ['ts-paths-esm-loader'],
ignoreDependencies: ['ts-paths-esm-loader', 'pino-pretty']
},
'apps/frontend': {
entry: ['src/index.tsx']
Expand Down
Loading

0 comments on commit 48d91f6

Please sign in to comment.