App Configuration is now read from file.

This commit is contained in:
Tom
2025-06-19 16:01:15 +00:00
parent cc337d22f2
commit 03286c2013
5 changed files with 16 additions and 9 deletions

View File

@ -0,0 +1,5 @@
{
"features": {
"registration": false
}
}

View 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);

View File

@ -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
};
}
}

View File

@ -1,5 +0,0 @@
export const config = {
features: {
registration: false,
},
}

View File

@ -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,