mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-25 06:01:02 +10:00
fixes
* integrate websocket redis adapter * use APP_SECRET for jwt signing * auto migrate database on startup in production * add updatedAt to update db operations * create enterprise ee package directory * fix comment editor focus * other fixes
This commit is contained in:
@ -5,8 +5,8 @@ import { ConfigService } from '@nestjs/config';
|
||||
export class EnvironmentService {
|
||||
constructor(private configService: ConfigService) {}
|
||||
|
||||
getEnv(): string {
|
||||
return this.configService.get<string>('NODE_ENV');
|
||||
getNodeEnv(): string {
|
||||
return this.configService.get<string>('NODE_ENV', 'development');
|
||||
}
|
||||
|
||||
getAppUrl(): string {
|
||||
@ -17,7 +17,7 @@ export class EnvironmentService {
|
||||
}
|
||||
|
||||
getPort(): number {
|
||||
return parseInt(this.configService.get<string>('PORT'));
|
||||
return parseInt(this.configService.get<string>('PORT', '3000'));
|
||||
}
|
||||
|
||||
getAppSecret(): string {
|
||||
@ -28,20 +28,19 @@ export class EnvironmentService {
|
||||
return this.configService.get<string>('DATABASE_URL');
|
||||
}
|
||||
|
||||
getJwtSecret(): string {
|
||||
return this.configService.get<string>('JWT_SECRET_KEY');
|
||||
getRedisUrl(): string {
|
||||
return this.configService.get<string>(
|
||||
'REDIS_URL',
|
||||
'redis://localhost:6379',
|
||||
);
|
||||
}
|
||||
|
||||
getJwtTokenExpiresIn(): string {
|
||||
return this.configService.get<string>('JWT_TOKEN_EXPIRES_IN');
|
||||
return this.configService.get<string>('JWT_TOKEN_EXPIRES_IN', '30d');
|
||||
}
|
||||
|
||||
getStorageDriver(): string {
|
||||
return this.configService.get<string>('STORAGE_DRIVER');
|
||||
}
|
||||
|
||||
getLocalStoragePath(): string {
|
||||
return this.configService.get<string>('LOCAL_STORAGE_PATH');
|
||||
return this.configService.get<string>('STORAGE_DRIVER', 'local');
|
||||
}
|
||||
|
||||
getAwsS3AccessKeyId(): string {
|
||||
@ -68,27 +67,12 @@ export class EnvironmentService {
|
||||
return this.configService.get<string>('AWS_S3_URL');
|
||||
}
|
||||
|
||||
getAwsS3UsePathStyleEndpoint(): boolean {
|
||||
return this.configService.get<boolean>('AWS_S3_USE_PATH_STYLE_ENDPOINT');
|
||||
}
|
||||
|
||||
isCloud(): boolean {
|
||||
const cloudConfig = this.configService
|
||||
.get<string>('CLOUD', 'false')
|
||||
.toLowerCase();
|
||||
return cloudConfig === 'true';
|
||||
}
|
||||
|
||||
isSelfHosted(): boolean {
|
||||
return !this.isCloud();
|
||||
}
|
||||
|
||||
getMailDriver(): string {
|
||||
return this.configService.get<string>('MAIL_DRIVER', 'log');
|
||||
}
|
||||
|
||||
getMailHost(): string {
|
||||
return this.configService.get<string>('MAIL_HOST', '127.0.0.1');
|
||||
return this.configService.get<string>('MAIL_HOST');
|
||||
}
|
||||
|
||||
getMailPort(): number {
|
||||
@ -115,10 +99,14 @@ export class EnvironmentService {
|
||||
return this.configService.get<string>('POSTMARK_TOKEN');
|
||||
}
|
||||
|
||||
getRedisUrl(): string {
|
||||
return this.configService.get<string>(
|
||||
'REDIS_URL',
|
||||
'redis://@127.0.0.1:6379',
|
||||
);
|
||||
isCloud(): boolean {
|
||||
const cloudConfig = this.configService
|
||||
.get<string>('CLOUD', 'false')
|
||||
.toLowerCase();
|
||||
return cloudConfig === 'true';
|
||||
}
|
||||
|
||||
isSelfHosted(): boolean {
|
||||
return !this.isCloud();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
import { IsString, IsUrl, validateSync } from 'class-validator';
|
||||
import { IsNotEmpty, IsUrl, validateSync } from 'class-validator';
|
||||
import { plainToInstance } from 'class-transformer';
|
||||
|
||||
export class EnvironmentVariables {
|
||||
@IsString()
|
||||
NODE_ENV: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
@IsUrl({ protocols: ['postgres', 'postgresql'], require_tld: false })
|
||||
DATABASE_URL: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
APP_SECRET: string;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user