Skip to content

Commit e6967d5

Browse files
authored
Merge branch 'development' into fix/th-183-fix-the-phone-field
2 parents 2f2a323 + 2e04f8f commit e6967d5

File tree

233 files changed

+7428
-530
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

233 files changed

+7428
-530
lines changed

.stylelintrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ rules:
88
selector-class-pattern: null
99
color-hex-length: long
1010
declaration-no-important: true
11-
max-nesting-depth: 0
11+
max-nesting-depth: 2
1212
no-descending-specificity: true
1313
scss/at-import-partial-extension: always
1414
import-notation: string

backend/.env.example

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,23 @@ JWT_SECRET=very_secret_secret
1111
JWT_ISSUER=jwt_issuer
1212
JWT_ACCESS_LIFETIME=24h
1313

14+
#
15+
# SENDGRID
16+
#
17+
SENDGRID_API_KEY=YOUR_API_KEY
18+
SENDGRID_USER=apikey
19+
SENDGRID_SENDER_EMAIL=YOUR_VERIFIED_SENDER_EMAIL
20+
SMTP_TLS=true
21+
1422
#
1523
# DATABASE
1624
#
1725
DB_CONNECTION_STRING=[db_client]://[db_username]:[db_user_password]@localhost:[db_port]/[db_name]
1826
DB_DIALECT=pg
1927
DB_POOL_MIN=2
2028
DB_POOL_MAX=10
29+
30+
#
31+
# API
32+
#
33+
GOOGLE_MAPS_API_KEY=YOUR_API_KEY

backend/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@
2828
},
2929
"dependencies": {
3030
"@fastify/auth": "4.3.0",
31+
"@fastify/cors": "8.3.0",
3132
"@fastify/static": "6.10.2",
3233
"@fastify/swagger": "8.9.0",
3334
"@fastify/swagger-ui": "1.9.3",
35+
"@googlemaps/google-maps-services-js": "3.3.38",
3436
"@types/bcryptjs": "2.4.3",
3537
"@types/convict": "6.1.3",
38+
"@types/nodemailer": "6.4.9",
3639
"@types/swagger-jsdoc": "6.0.1",
3740
"bcryptjs": "2.4.3",
3841
"convict": "6.2.4",
@@ -41,7 +44,9 @@
4144
"drizzle-orm": "0.28.2",
4245
"fastify": "4.21.0",
4346
"fastify-plugin": "4.5.1",
47+
"handlebars": "4.7.8",
4448
"jose": "4.14.4",
49+
"nodemailer": "6.9.4",
4550
"pg": "8.11.3",
4651
"pino": "8.15.0",
4752
"pino-pretty": "10.2.0",

backend/src/libs/exceptions/database/database-connection.exception.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { type Constructor } from '~/libs/types/types.js';
1+
import { type ErrorConstructor } from '~/libs/types/types.js';
22

33
class DatabaseConnectionError extends Error {
4-
public constructor({ message, cause }: Constructor) {
4+
public constructor({ message, cause }: ErrorConstructor) {
55
super(message, {
66
cause,
77
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
export { DatabaseConnectionError } from './database/database.js';
2+
export { MailerConnectionError } from './mailer/mailer.js';
23
export { NotFoundError } from './not-found-error/not-found-error.exception.js';
34
export {
45
ApplicationError,
6+
ConfigValidationError,
57
HttpError,
68
ValidationError,
79
} from 'shared/build/index.js';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { type ErrorConstructor } from '~/libs/types/types.js';
2+
3+
class MailerConnectionError extends Error {
4+
public constructor({ message, cause }: ErrorConstructor) {
5+
super(message, {
6+
cause,
7+
});
8+
}
9+
}
10+
11+
export { MailerConnectionError };
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { MailerConnectionError } from './mailer-connection.exception.js';

backend/src/libs/exceptions/not-found-error/not-found-error.exception.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
1-
import { type ValueOf } from '~/libs/types/types.js';
2-
31
import { AppErrorMessage, HttpCode } from '../../enums/enums.js';
4-
import { ApplicationError } from '../exceptions.js';
2+
import { HttpError } from '../exceptions.js';
53

64
type Constructor = {
75
message?: string;
86
cause?: unknown;
97
};
108

11-
class NotFoundError extends ApplicationError {
12-
public status: ValueOf<typeof HttpCode>;
13-
9+
class NotFoundError extends HttpError {
1410
public constructor({ message, cause }: Constructor) {
1511
super({
1612
message: message ?? AppErrorMessage.ENTITY_NOT_FOUND,
13+
status: HttpCode.NOT_FOUND,
1714
cause,
1815
});
19-
20-
this.status = HttpCode.NOT_FOUND;
2116
}
2217
}
2318

backend/src/libs/packages/config/config.package.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import convict, { type Config as TConfig } from 'convict';
22
import { config } from 'dotenv';
33

44
import { AppEnvironment } from '~/libs/enums/enums.js';
5+
import { ConfigValidationError } from '~/libs/exceptions/exceptions.js';
56
import { type ILogger } from '~/libs/packages/logger/logger.js';
67

8+
import { FormatRegex } from './libs/enums/enums.js';
79
import { type IConfig } from './libs/interfaces/interfaces.js';
810
import { type EnvironmentSchema } from './libs/types/types.js';
911

@@ -28,6 +30,28 @@ class Config implements IConfig {
2830
}
2931

3032
private get envSchema(): TConfig<EnvironmentSchema> {
33+
convict.addFormat({
34+
name: 'boolean_string',
35+
validate: (value: string, schema: convict.SchemaObj) => {
36+
if (value !== 'true' && value !== 'false') {
37+
throw new ConfigValidationError({
38+
message: `Invalid ${schema.env ?? ''} format`,
39+
});
40+
}
41+
},
42+
});
43+
44+
convict.addFormat({
45+
name: 'email',
46+
validate: (value: string, schema: convict.SchemaObj) => {
47+
if (!FormatRegex.EMAIL.test(value)) {
48+
throw new ConfigValidationError({
49+
message: `Invalid ${schema.env ?? ''} format`,
50+
});
51+
}
52+
},
53+
});
54+
3155
return convict<EnvironmentSchema>({
3256
APP: {
3357
ENVIRONMENT: {
@@ -83,6 +107,40 @@ class Config implements IConfig {
83107
default: null,
84108
},
85109
},
110+
MAILER: {
111+
SENDGRID_API_KEY: {
112+
doc: 'Twilio SendGrid API key',
113+
format: String,
114+
env: 'SENDGRID_API_KEY',
115+
default: null,
116+
},
117+
SENDGRID_USER: {
118+
doc: 'Twilio SendGrid SMTP username',
119+
format: String,
120+
env: 'SENDGRID_USER',
121+
default: 'apikey',
122+
},
123+
SMTP_TLS: {
124+
doc: 'Whether SMTP connection uses TLS',
125+
env: 'SMTP_TLS',
126+
format: 'boolean_string',
127+
default: true,
128+
},
129+
SENDGRID_SENDER_EMAIL: {
130+
doc: 'Sendgrid verified sender email',
131+
env: 'SENDGRID_SENDER_EMAIL',
132+
format: 'email',
133+
default: null,
134+
},
135+
},
136+
API: {
137+
GOOGLE_MAPS_API_KEY: {
138+
doc: 'Key for Google maps API',
139+
format: String,
140+
env: 'GOOGLE_MAPS_API_KEY',
141+
default: null,
142+
},
143+
},
86144
});
87145
}
88146
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { FormatRegex } from 'shared/build/index.js';

0 commit comments

Comments
 (0)