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 { Controller, Request, Get } from '@nestjs/common';
|
||||||
import { config } from './config';
|
import { AppConfig } from './app-config';
|
||||||
|
|
||||||
@Controller('asset')
|
@Controller('asset')
|
||||||
export class ConfigController {
|
export class ConfigController {
|
||||||
@ -9,7 +9,7 @@ export class ConfigController {
|
|||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
success: true,
|
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 { JwtAccessGuard } from './guards/jwt-access.guard';
|
||||||
import { LoginDto } from './dto/login.dto';
|
import { LoginDto } from './dto/login.dto';
|
||||||
import { AuthenticationDto } from './dto/authentication.dto';
|
import { AuthenticationDto } from './dto/authentication.dto';
|
||||||
import { config } from 'src/asset/config/config';
|
import { AppConfig } from 'src/asset/config/app-config';
|
||||||
|
|
||||||
@Controller('auth')
|
@Controller('auth')
|
||||||
export class AuthController {
|
export class AuthController {
|
||||||
@ -188,7 +188,7 @@ export class AuthController {
|
|||||||
@Res({ passthrough: true }) response: Response,
|
@Res({ passthrough: true }) response: Response,
|
||||||
@Body() body: RegisterUserDto,
|
@Body() body: RegisterUserDto,
|
||||||
) {
|
) {
|
||||||
if (!config.features.registration) {
|
if (!AppConfig.features.registration) {
|
||||||
response.statusCode = 404;
|
response.statusCode = 404;
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
|
Reference in New Issue
Block a user