App Configuration is now read from file.
This commit is contained in:
5
backend/nestjs-seshat-api/assets/config/config.json
Normal file
5
backend/nestjs-seshat-api/assets/config/config.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"features": {
|
||||
"registration": false
|
||||
}
|
||||
}
|
7
backend/nestjs-seshat-api/src/asset/config/app-config.ts
Normal file
7
backend/nestjs-seshat-api/src/asset/config/app-config.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
const file_path = path.join(process.cwd(), './assets/config/config.json');
|
||||
const file_content = fs.readFileSync(file_path).toString();
|
||||
|
||||
export const AppConfig = JSON.parse(file_content);
|
@ -1,5 +1,5 @@
|
||||
import { Controller, Request, Get } from '@nestjs/common';
|
||||
import { config } from './config';
|
||||
import { AppConfig } from './app-config';
|
||||
|
||||
@Controller('asset')
|
||||
export class ConfigController {
|
||||
@ -9,7 +9,7 @@ export class ConfigController {
|
||||
) {
|
||||
return {
|
||||
success: true,
|
||||
config: config
|
||||
config: AppConfig
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
export const config = {
|
||||
features: {
|
||||
registration: false,
|
||||
},
|
||||
}
|
@ -11,7 +11,7 @@ import { PinoLogger } from 'nestjs-pino';
|
||||
import { JwtAccessGuard } from './guards/jwt-access.guard';
|
||||
import { LoginDto } from './dto/login.dto';
|
||||
import { AuthenticationDto } from './dto/authentication.dto';
|
||||
import { config } from 'src/asset/config/config';
|
||||
import { AppConfig } from 'src/asset/config/app-config';
|
||||
|
||||
@Controller('auth')
|
||||
export class AuthController {
|
||||
@ -188,7 +188,7 @@ export class AuthController {
|
||||
@Res({ passthrough: true }) response: Response,
|
||||
@Body() body: RegisterUserDto,
|
||||
) {
|
||||
if (!config.features.registration) {
|
||||
if (!AppConfig.features.registration) {
|
||||
response.statusCode = 404;
|
||||
return {
|
||||
success: false,
|
||||
|
Reference in New Issue
Block a user