Skip to content

Commit cdfe19f

Browse files
committed
thjs-124: * fix typescript build
1 parent 5f4896e commit cdfe19f

File tree

13 files changed

+9
-94
lines changed

13 files changed

+9
-94
lines changed

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/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.EMAIL_REQUIRE}. ${UserValidationMessage.PASSWORD_REQUIRE}. ${UserValidationMessage.USERNAME_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
);

apps/frontend/src/pages/auth/components/sign-up-form/libs/common/constants.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { UserPayloadKey } from '~/modules/user/enums/enums.js';
22

33
const DEFAULT_REGISTRATION_PAYLOAD = {
44
[UserPayloadKey.EMAIL]: '',
5-
[UserPayloadKey.PASSWORD]: '',
6-
[UserPayloadKey.USERNAME]: ''
5+
[UserPayloadKey.PASSWORD]: ''
76
};
87

98
export { DEFAULT_REGISTRATION_PAYLOAD };

apps/frontend/src/pages/auth/components/sign-up-form/sign-up-form.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ const SignUpForm: React.FC<Properties> = ({ onSubmit }) => {
3434
<h2 className={styles['title']}>Register for free account</h2>
3535
<form name="registrationForm" onSubmit={handleSubmit(handleFormSubmit)}>
3636
<fieldset className={styles['fieldset']} disabled={isLoading}>
37-
<Input
38-
control={control}
39-
errors={errors}
40-
name={UserPayloadKey.USERNAME}
41-
placeholder="Username"
42-
type="text"
43-
/>
4437
<Input
4538
control={control}
4639
errors={errors}

knip.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const config: KnipConfig = {
1010
'apps/backend': {
1111
entry: ['src/index.ts', 'src/db/**/*.ts', 'knexfile.ts'],
1212
ignoreBinaries: ['ts-paths-esm-loader'],
13-
ignoreDependencies: ['ts-paths-esm-loader']
13+
ignoreDependencies: ['ts-paths-esm-loader', 'pino-pretty']
1414
},
1515
'apps/frontend': {
1616
entry: ['src/index.tsx']

packages/shared/src/modules/auth/libs/validation-schemas/sign-up.validation-schema.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,6 @@ const signUp = Joi.object({
2626
'string.empty': UserValidationMessage.PASSWORD_REQUIRE,
2727
'string.max': UserValidationMessage.PASSWORD_MAX_LENGTH,
2828
'string.min': UserValidationMessage.PASSWORD_MIN_LENGTH
29-
}),
30-
[UserPayloadKey.USERNAME]: Joi.string()
31-
.trim()
32-
.min(UserValidationRule.USERNAME_MIN_LENGTH)
33-
.max(UserValidationRule.USERNAME_MAX_LENGTH)
34-
.required()
35-
.messages({
36-
'any.required': UserValidationMessage.USERNAME_REQUIRE,
37-
'string.empty': UserValidationMessage.USERNAME_REQUIRE,
38-
'string.max': UserValidationMessage.USERNAME_MAX_LENGTH,
39-
'string.min': UserValidationMessage.USERNAME_MIN_LENGTH
4029
})
4130
});
4231

packages/shared/src/modules/user/libs/enums/user-payload-key.enum.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ const UserPayloadKey = {
22
EMAIL: 'email',
33
PASSWORD: 'password',
44
STATUS: 'status',
5-
TOKEN: 'token',
6-
USERNAME: 'username'
5+
TOKEN: 'token'
76
} as const;
87

98
export { UserPayloadKey };

0 commit comments

Comments
 (0)