Initial commit: LACA parking management system
This commit is contained in:
17
backend/src/config/app/app-config.module.ts
Normal file
17
backend/src/config/app/app-config.module.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import appConfiguration from './app-configuration';
|
||||
import { AppConfigService } from './app-config.service';
|
||||
import { appConfigValidationSchema } from './app-config.schema';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
load: [appConfiguration],
|
||||
validationSchema: appConfigValidationSchema,
|
||||
}),
|
||||
],
|
||||
providers: [ConfigService, AppConfigService],
|
||||
exports: [ConfigService, AppConfigService],
|
||||
})
|
||||
export class AppConfigModule {}
|
||||
24
backend/src/config/app/app-config.schema.ts
Normal file
24
backend/src/config/app/app-config.schema.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as Joi from 'joi';
|
||||
|
||||
export const appConfigValidationSchema = Joi.object({
|
||||
ENVIRONMENT: Joi.string().valid('dev', 'stag', 'prod').default('dev'),
|
||||
APP_NAME: Joi.string().default('NestJS Example App'),
|
||||
APP_URL: Joi.string().default('http://localhost:3000'),
|
||||
PORT: Joi.number().default(3000),
|
||||
APP_CORS_ENABLED: Joi.boolean().default(true),
|
||||
JWT_ACCESS_SECRET: Joi.string().required(),
|
||||
JWT_REFRESH_SECRET: Joi.string().required(),
|
||||
JWT_EXPIRES_IN: Joi.string().required(),
|
||||
JWT_REFRESH_IN: Joi.string().required(),
|
||||
BCRYPT_SALT_ROUNDS: Joi.number().default(10),
|
||||
GRAPHQL_PLAYGROUND_ENABLED: Joi.boolean().default(true),
|
||||
GRAPHQL_DEBUG: Joi.boolean().default(true),
|
||||
GRAPHQL_SCHEMA_DESTINATION: Joi.string().default('schema.graphql'),
|
||||
GRAPHQL_SORT_SCHEMA: Joi.boolean().default(true),
|
||||
SWAGGER_ENABLED: Joi.boolean().default(true),
|
||||
SWAGGER_DESCRIPTION: Joi.string().default('NestJS example app API'),
|
||||
SWAGGER_VERSION: Joi.string().default('1.5'),
|
||||
SWAGGER_PATH: Joi.string().default('api'),
|
||||
REDIS_URL: Joi.string().default('redis://localhost:6379'),
|
||||
UPLOAD_LOCATION: Joi.string().default('audio'),
|
||||
});
|
||||
100
backend/src/config/app/app-config.service.ts
Normal file
100
backend/src/config/app/app-config.service.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
@Injectable()
|
||||
export class AppConfigService {
|
||||
constructor(private configService: ConfigService) {}
|
||||
|
||||
get environment(): string {
|
||||
return this.configService.get<string>('app.environment');
|
||||
}
|
||||
get name(): string {
|
||||
return this.configService.get<string>('app.name');
|
||||
}
|
||||
|
||||
get url(): string {
|
||||
return this.configService.get<string>('app.url');
|
||||
}
|
||||
|
||||
get port(): number {
|
||||
return Number(this.configService.get<number>('app.port'));
|
||||
}
|
||||
|
||||
get corsEnabled(): boolean {
|
||||
return this.configService.get<boolean>('app.corsEnabled');
|
||||
}
|
||||
|
||||
get jwtAccessSecret(): string {
|
||||
return this.configService.get<string>('app.jwtAccessSecret');
|
||||
}
|
||||
|
||||
get jwtRefreshSecret(): string {
|
||||
return this.configService.get<string>('app.jwtRefreshSecret');
|
||||
}
|
||||
|
||||
get jwtExpiresIn(): string {
|
||||
return this.configService.get<string>('app.jwtExpiresIn');
|
||||
}
|
||||
|
||||
get jwtRefreshIn(): string {
|
||||
return this.configService.get<string>('app.jwtRefreshIn');
|
||||
}
|
||||
|
||||
get bcryptSaltRounds(): number {
|
||||
return this.configService.get<number>('app.bcryptSaltRounds');
|
||||
}
|
||||
|
||||
get graphqlPlaygroundEnabled(): boolean {
|
||||
return this.configService.get<boolean>('app.graphqlPlaygroundEnabled');
|
||||
}
|
||||
|
||||
get graphqlDebug(): boolean {
|
||||
return this.configService.get<boolean>('app.graphqlDebug');
|
||||
}
|
||||
|
||||
get graphqlSchemaDestination(): string {
|
||||
return this.configService.get<string>('app.graphqlSchemaDestination');
|
||||
}
|
||||
|
||||
get graphqlSortSchema(): boolean {
|
||||
return this.configService.get<boolean>('app.graphqlSortSchema');
|
||||
}
|
||||
|
||||
get swaggerEnabled(): boolean {
|
||||
return this.configService.get<boolean>('app.swaggerEnabled');
|
||||
}
|
||||
|
||||
get swaggerDescription(): string {
|
||||
return this.configService.get<string>('app.swaggerDescription');
|
||||
}
|
||||
|
||||
get swaggerVersion(): string {
|
||||
return this.configService.get<string>('app.swaggerVersion');
|
||||
}
|
||||
|
||||
get swaggerPath(): string {
|
||||
return this.configService.get<string>('app.swaggerPath');
|
||||
}
|
||||
|
||||
get gClientId(): string {
|
||||
return this.configService.get<string>('app.gClientId');
|
||||
}
|
||||
|
||||
get gClientSecret(): string {
|
||||
return this.configService.get<string>('app.gClientSecret');
|
||||
}
|
||||
|
||||
get redisUri(): string {
|
||||
return this.configService.get<string>('app.redis');
|
||||
}
|
||||
|
||||
get loggingType(): string {
|
||||
return this.configService.get<string>('app.loggingType');
|
||||
}
|
||||
get googleMailer(): string {
|
||||
return this.configService.get<any>('app.googleMailer');
|
||||
}
|
||||
get contactMailer(): string {
|
||||
return this.configService.get<any>('app.googleMailer.contactMail');
|
||||
}
|
||||
}
|
||||
39
backend/src/config/app/app-configuration.ts
Normal file
39
backend/src/config/app/app-configuration.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { registerAs } from '@nestjs/config';
|
||||
|
||||
export default registerAs('app', () => ({
|
||||
environment: process.env.ENVIRONMENT,
|
||||
name: process.env.APP_NAME,
|
||||
url: process.env.APP_URL,
|
||||
port: process.env.PORT,
|
||||
redis: process.env.REDIS_URL,
|
||||
corsEnabled: process.env.APP_CORS_ENABLED,
|
||||
jwtAccessSecret: process.env.JWT_ACCESS_SECRET,
|
||||
jwtRefreshSecret: process.env.JWT_REFRESH_SECRET,
|
||||
jwtExpiresIn: process.env.JWT_EXPIRES_IN,
|
||||
jwtRefreshIn: process.env.JWT_REFRESH_IN,
|
||||
bcryptSaltRounds: process.env.BCRYPT_SALT_ROUNDS,
|
||||
graphqlPlaygroundEnabled: process.env.GRAPHQL_PLAYGROUND_ENABLED,
|
||||
graphqlDebug: process.env.GRAPHQL_DEBUG,
|
||||
graphqlSchemaDestination: process.env.GRAPHQL_SCHEMA_DESTINATION,
|
||||
graphqlSortSchema: process.env.GRAPHQL_SORT_SCHEMA,
|
||||
swaggerEnabled: process.env.SWAGGER_ENABLED,
|
||||
swaggerDescription: process.env.SWAGGER_DESCRIPTION,
|
||||
swaggerVersion: process.env.SWAGGER_VERSION,
|
||||
swaggerPath: process.env.SWAGGER_PATH,
|
||||
gClientId: process.env.GOOGLE_CLIENT_ID,
|
||||
gClientSecret: process.env.GOOGLE_SECRET,
|
||||
loggingType: process.env.LOGGING_TYPE || 'dev',
|
||||
googleMailer: {
|
||||
contactMail: process.env.CONTACT_MAIL || '',
|
||||
clientId: process.env.GOOGLE_MAILER_CLIENT_ID || '',
|
||||
clientSecret: process.env.GOOGLE_MAILER_CLIENT_SECRET || '',
|
||||
refreshToken: process.env.GOOGLE_MAILER_REFRESH_TOKEN || '',
|
||||
host: process.env.MAILER_HOST || '',
|
||||
port: process.env.MAILER_PORT || '',
|
||||
secure: process.env.MAILER_REFRESH_TOKEN || '',
|
||||
auth: {
|
||||
user: process.env.ADMIN_EMAIL_ADDRESS || '',
|
||||
pass: process.env.ADMIN_EMAIL_PASS || '',
|
||||
},
|
||||
},
|
||||
}));
|
||||
Reference in New Issue
Block a user