mirror of
https://github.com/docmost/docmost.git
synced 2026-05-15 21:24:09 +08:00
move environment module to integrations
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { IsString, IsUrl, validateSync } from 'class-validator';
|
||||
import { plainToInstance } from 'class-transformer';
|
||||
|
||||
export class EnvironmentVariables {
|
||||
@IsString()
|
||||
NODE_ENV: string;
|
||||
|
||||
@IsUrl({ protocols: ['postgres', 'postgresql'], require_tld: false })
|
||||
DATABASE_URL: string;
|
||||
}
|
||||
|
||||
export function validate(config: Record<string, any>) {
|
||||
const validatedConfig = plainToInstance(EnvironmentVariables, config);
|
||||
|
||||
const errors = validateSync(validatedConfig);
|
||||
if (errors.length > 0) {
|
||||
throw new Error(errors.toString());
|
||||
}
|
||||
return validatedConfig;
|
||||
}
|
||||
Reference in New Issue
Block a user