AI Implementation feature(899): Data and run (#39)
This commit was merged in pull request #39.
This commit is contained in:
@@ -63,7 +63,7 @@ export function buildMulter(config: ConfigService, opts: MulterOptions = {}): mu
|
||||
const limits = opts.fileSize !== undefined
|
||||
? { fileSize: opts.fileSize }
|
||||
: buildUploadLimits(config);
|
||||
const dest = opts.destination ?? path.resolve(config.get<string>('UPLOAD_DIR', '/data/hipctf/uploads'));
|
||||
const dest = opts.destination ?? path.resolve(config.get<string>('UPLOAD_DIR', './data/uploads'));
|
||||
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
|
||||
return multer({
|
||||
storage: multer.diskStorage({
|
||||
|
||||
@@ -4,8 +4,8 @@ export const envSchema = z.object({
|
||||
NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
|
||||
PORT: z.coerce.number().int().positive().default(3000),
|
||||
|
||||
DATABASE_PATH: z.string().min(1).default('/data/hipctf/db.sqlite'),
|
||||
UPLOAD_DIR: z.string().min(1).default('/data/hipctf/uploads'),
|
||||
DATABASE_PATH: z.string().min(1).default('./data/db.sqlite'),
|
||||
UPLOAD_DIR: z.string().min(1).default('./data/uploads'),
|
||||
THEMES_DIR: z.string().min(1).default('./themes'),
|
||||
FRONTEND_DIST: z.string().min(1).default('../frontend/dist'),
|
||||
|
||||
|
||||
@@ -113,6 +113,6 @@ export class DatabaseInitService implements OnApplicationBootstrap {
|
||||
}
|
||||
|
||||
getDbPath(): string {
|
||||
return this.config.get<string>('DATABASE_PATH', '/data/hipctf/db.sqlite');
|
||||
return this.config.get<string>('DATABASE_PATH', './data/db.sqlite');
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ const MIGRATIONS = [
|
||||
imports: [ConfigModule],
|
||||
inject: [ConfigService],
|
||||
useFactory: (config: ConfigService) => {
|
||||
const dbPath = config.get<string>('DATABASE_PATH', '/data/hipctf/db.sqlite');
|
||||
const dbPath = config.get<string>('DATABASE_PATH', './data/db.sqlite');
|
||||
const isMemory = dbPath === ':memory:' || dbPath.startsWith('file:');
|
||||
if (!isMemory) {
|
||||
const dir = path.dirname(dbPath);
|
||||
|
||||
@@ -9,7 +9,7 @@ export class UploadsStaticMiddleware implements NestMiddleware {
|
||||
private rootDir = '/tmp';
|
||||
|
||||
constructor(config: ConfigService) {
|
||||
const dir = path.resolve(config.get<string>('UPLOAD_DIR', '/data/hipctf/uploads'));
|
||||
const dir = path.resolve(config.get<string>('UPLOAD_DIR', './data/uploads'));
|
||||
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
||||
this.rootDir = dir;
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ async function bootstrap(): Promise<void> {
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
const bodyLimit = config.get<string>('BODY_SIZE_LIMIT', '1mb');
|
||||
const uploadDir = path.resolve(config.get<string>('UPLOAD_DIR', '/data/hipctf/uploads'));
|
||||
const uploadDir = path.resolve(config.get<string>('UPLOAD_DIR', './data/uploads'));
|
||||
const tlsEnabled = config.get<boolean>('TLS_ENABLED', false);
|
||||
const frontendDist = path.resolve(config.get<string>('FRONTEND_DIST', '../frontend/dist'));
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export class UploadsController {
|
||||
private readonly globalLimit: number;
|
||||
|
||||
constructor(private readonly config: ConfigService) {
|
||||
this.uploadDir = path.resolve(this.config.get<string>('UPLOAD_DIR', '/data/hipctf/uploads'));
|
||||
this.uploadDir = path.resolve(this.config.get<string>('UPLOAD_DIR', './data/uploads'));
|
||||
this.globalLimit = parseUploadSizeLimit(this.config.get<string>('UPLOAD_SIZE_LIMIT', '50mb'));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user