Create SQLite directory before app startup

This commit is contained in:
Dymas
2026-06-22 09:35:17 +02:00
parent 75129db86c
commit f467836046
+9 -3
View File
@@ -3,7 +3,7 @@ import { ValidationPipe } from '@nestjs/common';
import { HttpExceptionFilter } from './shared/filters/http-exception.filter';
import { AppModule } from './app.module';
import * as fs from 'fs';
import { resolve } from 'path';
import { dirname, resolve } from 'path';
import { spawn } from 'child_process';
import helmet from 'helmet';
import { EnvironmentEnum } from './environmentEnum';
@@ -17,11 +17,17 @@ async function bootstrap() {
throw new Error('DOWNLOADS_PATH environment variable is missing');
}
const folderName = resolve(
const downloadsPath = resolve(
__dirname,
process.env[EnvironmentEnum.DOWNLOADS_PATH],
);
fs.mkdirSync(folderName, { recursive: true });
fs.mkdirSync(downloadsPath, { recursive: true });
const dbPath = resolve(
__dirname,
process.env[EnvironmentEnum.DB_PATH] || './config/db.sqlite',
);
fs.mkdirSync(dirname(dbPath), { recursive: true });
if (envFlag(EnvironmentEnum.REDIS_RUN)) {
try {