6d024fc3de
* refactor imports - WIP * Add readstream * WIP * fix attachmentId render * fix attachmentId render * turndown video tag * feat: add stream upload support and improve file handling - Add stream upload functionality to storage drivers\n- Improve ZIP file extraction with better encoding handling\n- Fix attachment ID rendering issues\n- Add AWS S3 upload stream support\n- Update dependencies for better compatibility * WIP * notion formatter * move embed parser to editor-ext package * import embeds * utility files * cleanup * Switch from happy-dom to cheerio * Refine code * WIP * bug fixes and UI * sync * WIP * sync * keep import modal mounted * Show modal during upload * WIP * WIP
197 lines
4.8 KiB
TypeScript
197 lines
4.8 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { ConfigService } from '@nestjs/config';
|
|
|
|
@Injectable()
|
|
export class EnvironmentService {
|
|
constructor(private configService: ConfigService) {}
|
|
|
|
getNodeEnv(): string {
|
|
return this.configService.get<string>('NODE_ENV', 'development');
|
|
}
|
|
|
|
getAppUrl(): string {
|
|
const rawUrl =
|
|
this.configService.get<string>('APP_URL') ||
|
|
`http://localhost:${this.getPort()}`;
|
|
|
|
const { origin } = new URL(rawUrl);
|
|
return origin;
|
|
}
|
|
|
|
isHttps(): boolean {
|
|
const appUrl = this.configService.get<string>('APP_URL');
|
|
try {
|
|
const url = new URL(appUrl);
|
|
return url.protocol === 'https:';
|
|
} catch (error) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
getSubdomainHost(): string {
|
|
return this.configService.get<string>('SUBDOMAIN_HOST');
|
|
}
|
|
|
|
getPort(): number {
|
|
return parseInt(this.configService.get<string>('PORT', '3000'));
|
|
}
|
|
|
|
getAppSecret(): string {
|
|
return this.configService.get<string>('APP_SECRET');
|
|
}
|
|
|
|
getDatabaseURL(): string {
|
|
return this.configService.get<string>('DATABASE_URL');
|
|
}
|
|
|
|
getDatabaseMaxPool(): number {
|
|
return parseInt(this.configService.get<string>('DATABASE_MAX_POOL', '10'));
|
|
}
|
|
|
|
getRedisUrl(): string {
|
|
return this.configService.get<string>(
|
|
'REDIS_URL',
|
|
'redis://localhost:6379',
|
|
);
|
|
}
|
|
|
|
getJwtTokenExpiresIn(): string {
|
|
return this.configService.get<string>('JWT_TOKEN_EXPIRES_IN', '30d');
|
|
}
|
|
|
|
getStorageDriver(): string {
|
|
return this.configService.get<string>('STORAGE_DRIVER', 'local');
|
|
}
|
|
|
|
getFileUploadSizeLimit(): string {
|
|
return this.configService.get<string>('FILE_UPLOAD_SIZE_LIMIT', '50mb');
|
|
}
|
|
|
|
getFileImportSizeLimit(): string {
|
|
return this.configService.get<string>('FILE_IMPORT_SIZE_LIMIT', '200mb');
|
|
}
|
|
|
|
getAwsS3AccessKeyId(): string {
|
|
return this.configService.get<string>('AWS_S3_ACCESS_KEY_ID');
|
|
}
|
|
|
|
getAwsS3SecretAccessKey(): string {
|
|
return this.configService.get<string>('AWS_S3_SECRET_ACCESS_KEY');
|
|
}
|
|
|
|
getAwsS3Region(): string {
|
|
return this.configService.get<string>('AWS_S3_REGION');
|
|
}
|
|
|
|
getAwsS3Bucket(): string {
|
|
return this.configService.get<string>('AWS_S3_BUCKET');
|
|
}
|
|
|
|
getAwsS3Endpoint(): string {
|
|
return this.configService.get<string>('AWS_S3_ENDPOINT');
|
|
}
|
|
|
|
getAwsS3ForcePathStyle(): boolean {
|
|
return this.configService.get<boolean>('AWS_S3_FORCE_PATH_STYLE');
|
|
}
|
|
|
|
getAwsS3Url(): string {
|
|
return this.configService.get<string>('AWS_S3_URL');
|
|
}
|
|
|
|
getMailDriver(): string {
|
|
return this.configService.get<string>('MAIL_DRIVER', 'log');
|
|
}
|
|
|
|
getMailFromAddress(): string {
|
|
return this.configService.get<string>('MAIL_FROM_ADDRESS');
|
|
}
|
|
|
|
getMailFromName(): string {
|
|
return this.configService.get<string>('MAIL_FROM_NAME', 'Docmost');
|
|
}
|
|
|
|
getSmtpHost(): string {
|
|
return this.configService.get<string>('SMTP_HOST');
|
|
}
|
|
|
|
getSmtpPort(): number {
|
|
return parseInt(this.configService.get<string>('SMTP_PORT'));
|
|
}
|
|
|
|
getSmtpSecure(): boolean {
|
|
const secure = this.configService
|
|
.get<string>('SMTP_SECURE', 'false')
|
|
.toLowerCase();
|
|
return secure === 'true';
|
|
}
|
|
|
|
getSmtpIgnoreTLS(): boolean {
|
|
const ignoretls = this.configService
|
|
.get<string>('SMTP_IGNORETLS', 'false')
|
|
.toLowerCase();
|
|
return ignoretls === 'true';
|
|
}
|
|
|
|
getSmtpUsername(): string {
|
|
return this.configService.get<string>('SMTP_USERNAME');
|
|
}
|
|
|
|
getSmtpPassword(): string {
|
|
return this.configService.get<string>('SMTP_PASSWORD');
|
|
}
|
|
|
|
getPostmarkToken(): string {
|
|
return this.configService.get<string>('POSTMARK_TOKEN');
|
|
}
|
|
|
|
getDrawioUrl(): string {
|
|
return this.configService.get<string>('DRAWIO_URL');
|
|
}
|
|
|
|
isCloud(): boolean {
|
|
const cloudConfig = this.configService
|
|
.get<string>('CLOUD', 'false')
|
|
.toLowerCase();
|
|
return cloudConfig === 'true';
|
|
}
|
|
|
|
isSelfHosted(): boolean {
|
|
return !this.isCloud();
|
|
}
|
|
|
|
getStripePublishableKey(): string {
|
|
return this.configService.get<string>('STRIPE_PUBLISHABLE_KEY');
|
|
}
|
|
|
|
getStripeSecretKey(): string {
|
|
return this.configService.get<string>('STRIPE_SECRET_KEY');
|
|
}
|
|
|
|
getStripeWebhookSecret(): string {
|
|
return this.configService.get<string>('STRIPE_WEBHOOK_SECRET');
|
|
}
|
|
|
|
getBillingTrialDays(): number {
|
|
return parseInt(this.configService.get<string>('BILLING_TRIAL_DAYS', '14'));
|
|
}
|
|
|
|
getCollabUrl(): string {
|
|
return this.configService.get<string>('COLLAB_URL');
|
|
}
|
|
|
|
isCollabDisableRedis(): boolean {
|
|
const isStandalone = this.configService
|
|
.get<string>('COLLAB_DISABLE_REDIS', 'false')
|
|
.toLowerCase();
|
|
return isStandalone === 'true';
|
|
}
|
|
|
|
isDisableTelemetry(): boolean {
|
|
const disable = this.configService
|
|
.get<string>('DISABLE_TELEMETRY', 'false')
|
|
.toLowerCase();
|
|
return disable === 'true';
|
|
}
|
|
}
|