Skip to content

Commit 2dedd0d

Browse files
committed
fix: sentry config
1 parent 033a638 commit 2dedd0d

19 files changed

+135
-118
lines changed

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"jspdf",
2323
"jwtid",
2424
"jwttoken",
25+
"KHTML",
2526
"lukeed",
2627
"Mercurius",
2728
"mikro",

docs/config.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ import { ConfigService } from "@nestjs/config";
119119

120120
@Injectable()
121121
export class DatabaseService {
122-
constructor(private configService: ConfigService) {}
122+
constructor(private configService: ConfigService<Configs, true>) {}
123123

124124
getDatabaseUrl(): string {
125-
return this.configService.get<string>("database.url");
125+
return this.configService.get("database.url");
126126
}
127127

128128
// ... other methods to access configuration settings related to database

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@
5757
"@golevelup/nestjs-rabbitmq": "^4.0.0",
5858
"@golevelup/nestjs-stripe": "^0.6.3",
5959
"@golevelup/nestjs-webhooks": "^0.2.16",
60-
"@mikro-orm/core": "^5.7.14",
61-
"@mikro-orm/migrations": "^5.7.14",
60+
"@mikro-orm/core": "^5.8.0",
61+
"@mikro-orm/migrations": "^5.8.0",
6262
"@mikro-orm/nestjs": "^5.2.1",
63-
"@mikro-orm/postgresql": "^5.7.14",
64-
"@mikro-orm/reflection": "^5.7.14",
63+
"@mikro-orm/postgresql": "^5.8.0",
64+
"@mikro-orm/reflection": "^5.8.0",
6565
"@mikro-orm/sql-highlighter": "^1.0.1",
6666
"@nestjs/axios": "^3.0.0",
6767
"@nestjs/cache-manager": "^2.1.0",
@@ -138,8 +138,8 @@
138138
"@firebase/app-compat": "^0.2.18",
139139
"@firebase/app-types": "^0.9.0",
140140
"@golevelup/ts-jest": "^0.4.0",
141-
"@mikro-orm/cli": "^5.7.14",
142-
"@mikro-orm/seeder": "^5.7.14",
141+
"@mikro-orm/cli": "^5.8.0",
142+
"@mikro-orm/seeder": "^5.8.0",
143143
"@nestjs/cli": "10.1.17",
144144
"@nestjs/schematics": "10.0.2",
145145
"@nestjs/testing": "10.2.4",

pnpm-lock.yaml

+73-93
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/common/@types/global.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ RABBITMQ_QUEUE: string;
7575
RABBITMQ_DEFAULT_PREFETCH: number;
7676

7777
SENTRY_DSN: string;
78+
SENTRY_ENVIRONMENT: string;
7879

7980
GOOGLE_CLIENT_ID: string;
8081
GOOGLE_CLIENT_SECRET: string;

src/common/decorators/validation/is-unique.validator.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('IsUnique', () => {
2424
providers: [IsUniqueConstraint, { provide: EntityManager, useValue: mockEm }],
2525
}).compile();
2626

27-
isUnique = await module.get<IsUniqueConstraint>(IsUniqueConstraint);
27+
isUnique = module.get<IsUniqueConstraint>(IsUniqueConstraint);
2828
});
2929

3030
it('should pass if there are no duplicates', async () => {

src/lib/cloudinary.module.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
import { Module } from "@nestjs/common";
1+
import { Global, Module } from "@nestjs/common";
22
import { ConfigModule, ConfigService } from "@nestjs/config";
33
import { CloudinaryModule } from "nestjs-cloudinary";
44

5+
@Global()
56
@Module({
67
imports: [
78
CloudinaryModule.forRootAsync({
89
imports: [ConfigModule],
910
inject: [ConfigService],
1011
useFactory: (configService: ConfigService<Configs, true>) => ({
1112
isGlobal: true,
12-
cloud_name: configService.get("cloudinary.cloud_name", { infer: true }),
13-
api_key: configService.get("cloudinary.api_key", { infer: true }),
14-
api_secret: configService.get("cloudinary.api_secret", { infer: true }),
13+
cloud_name: configService.get("cloudinary.cloudName", { infer: true }),
14+
api_key: configService.get("cloudinary.apiKey", { infer: true }),
15+
api_secret: configService.get("cloudinary.apiSecret", { infer: true }),
1516
}),
1617
}),
1718
],

src/lib/config/config.interface.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {
99
mail,
1010
rabbitmq,
1111
redis,
12+
sentry,
1213
stripe,
1314
throttle,
1415
twilio,
@@ -27,4 +28,5 @@ export interface Config {
2728
stripe: ConfigType<typeof stripe>;
2829
facebookOauth: ConfigType<typeof facebookOauth>;
2930
googleOauth: ConfigType<typeof googleOauth>;
31+
sentry: ConfigType<typeof sentry>;
3032
}

src/lib/config/config.module.ts

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import {
1919
rabbitmqConfigValidationSchema,
2020
redis,
2121
redisConfigValidationSchema,
22+
sentry,
23+
sentryConfigurationValidationSchema,
2224
throttle,
2325
throttleConfigValidationSchema,
2426
} from "./configs";
@@ -40,6 +42,7 @@ import { HelperService } from "@common/helpers";
4042
googleOauth,
4143
facebookOauth,
4244
throttle,
45+
sentry,
4346
],
4447
cache: true,
4548
isGlobal: true,
@@ -54,6 +57,7 @@ import { HelperService } from "@common/helpers";
5457
...googleOauthConfigValidationSchema,
5558
...facebookOauthConfigValidationSchema,
5659
...throttleConfigValidationSchema,
60+
...sentryConfigurationValidationSchema,
5761
}),
5862
validationOptions: {
5963
abortEarly: true,

src/lib/config/configs/app.config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { registerAs } from "@nestjs/config";
22
import Joi from "joi";
3-
import { APP_ENVIRONMENTS, SENTRY_DSN_REGEX, VERSION_VALIDATION_MESSAGE } from "@common/constant";
3+
import { APP_ENVIRONMENTS, VERSION_VALIDATION_MESSAGE } from "@common/constant";
44

55
// validation schema
66

@@ -18,7 +18,7 @@ export const appConfigValidationSchema = {
1818
ALLOWED_HOSTS: Joi.string().optional(),
1919
SWAGGER_USER: Joi.string().required(),
2020
SWAGGER_PASSWORD: Joi.string().required(),
21-
SENTRY_DSN: Joi.string().pattern(SENTRY_DSN_REGEX).required(),
21+
2222
};
2323

2424
// config

src/lib/config/configs/cloudinary.config.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const cloudinaryConfigValidationSchema = {
88
};
99

1010
export const cloudinary = registerAs("cloudinary", () => ({
11-
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
12-
api_key: process.env.CLOUDINARY_API_KEY,
13-
api_secret: process.env.CLOUDINARY_API_SECRET,
11+
cloudName: process.env.CLOUDINARY_CLOUD_NAME,
12+
apiKey: process.env.CLOUDINARY_API_KEY,
13+
apiSecret: process.env.CLOUDINARY_API_SECRET,
1414
}));

src/lib/config/configs/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// This is autogenerated file , edit if only you are sure
2+
13
export * from "./app.config";
24
export * from "./cloudinary.config";
35
export * from "./database.config";
@@ -7,6 +9,7 @@ export * from "./minio.config";
79
export * from "./oauth2.config";
810
export * from "./rabbitmq.config";
911
export * from "./redis.config";
12+
export * from "./sentry.config";
1013
export * from "./stripe.config";
1114
export * from "./throttle.config";
1215
export * from "./twilio.config";
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { registerAs } from "@nestjs/config";
2+
import Joi from "joi";
3+
import { SENTRY_DSN_REGEX } from "@common/constant";
4+
5+
export const sentryConfigurationValidationSchema = {
6+
SENTRY_DSN: Joi.string().pattern(SENTRY_DSN_REGEX).required(),
7+
SENTRY_ENVIRONMENT: Joi.string().required(),
8+
};
9+
10+
export const sentry = registerAs("sentry", () => ({
11+
sentryDsn: process.env.SENTRY_DSN,
12+
environment: process.env.SENTRY_ENVIRONMENT,
13+
}));

src/lib/http.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Module } from "@nestjs/common";
1111
"Accept": "application/json",
1212
"Content-Type": "application/json",
1313
"user-agent":
14-
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
14+
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
1515
},
1616
}),
1717
],

src/lib/minio.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { NestMinioModule } from "nestjs-minio";
1313
port: configService.get("minio.port"),
1414
accessKey: configService.get("minio.accessKey"),
1515
secretKey: configService.get("minio.secretKey"),
16-
useSSL: configService.get<boolean>("minio.ssl"),
16+
useSSL: configService.get("minio.ssl"),
1717
}),
1818
}),
1919
],

src/lib/orm.module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import { baseOptions } from "@common/database/mikro-orm-cli.config";
1616
...baseOptions,
1717
host: configService.get("database.host", { infer: true }),
1818
port: configService.get("database.port", { infer: true }),
19-
password: configService.get("database.password", { infer: true }),
20-
user: configService.get("database.user", { infer: true }),
2119
dbName: configService.get("database.dbName", { infer: true }),
20+
user: configService.get("database.user", { infer: true }),
21+
password: configService.get("database.password", { infer: true }),
2222
}),
2323
}),
2424
MikroOrmModule.forFeature({

src/lib/sentry.module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { SentryModule } from "@ntegral/nestjs-sentry";
88
imports: [ConfigModule],
99
inject: [ConfigService],
1010
useFactory: async (configService: ConfigService<Configs, true>) => ({
11-
dsn: configService.get("app.sentryDsn", { infer: true }),
11+
dsn: configService.get("sentry.sentryDsn", { infer: true }),
12+
environment: configService.get("sentry.sentryDsn", { infer: true }),
1213
debug: true,
13-
environment: "development",
1414
tracesSampleRate: 1,
1515
}),
1616
}),

src/modules/auth/strategies/magic-login.strategy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class MagicLoginStrategy extends PassportStrategy(Strategy, "magicLogin")
5151
template: EmailTemplate.MAGIC_LOGIN_TEMPLATE,
5252
replacements: {
5353
link: `${this.configService.get("app.url", { infer: true })}/v1/${href}`,
54-
expiry: this.configService.get<string>("jwt.magicLinkExpiry", { infer: true }),
54+
expiry: this.configService.get("jwt.magicLinkExpiry", { infer: true }),
5555
},
5656
to: destination,
5757
subject: EmailSubject.MAGIC_LOGIN,

src/socket-io.adapter.ts

+12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ export class SocketIOAdapter extends IoAdapter {
1616
super(app);
1717
}
1818

19+
/**
20+
* The function connects to a Redis server and creates a Redis adapter.
21+
* @returns a promise that resolves to void.
22+
*/
1923
async connectToRedis(): Promise<void> {
2024
const pubClient = createClient({
2125
url: this.configService.get("redis.url", { infer: true }),
@@ -27,6 +31,14 @@ export class SocketIOAdapter extends IoAdapter {
2731
this.adapterConstructor = createAdapter(pubClient, subClient);
2832
}
2933

34+
/**
35+
* The function creates an IO server with CORS options and an adapter constructor.
36+
* @param port - The `port` parameter is the port number on which the server will listen for
37+
* incoming connections. It is a number that specifies the port, such as 3000 or 8080.
38+
* @param [options] - The `options` parameter is an optional object that can contain
39+
* additional configuration options for the server. It is of type `ServerOptions`.
40+
* @returns a server object.
41+
*/
3042
createIOServer(port: number, options?: ServerOptions): any {
3143
const cors = {
3244
origin: this.configService.get("app.allowedOrigins", { infer: true }),

0 commit comments

Comments
 (0)