From be14bc8f2928531b41c5e9805d542936ee25907a Mon Sep 17 00:00:00 2001 From: Fuxing Loh <4266087+fuxingloh@users.noreply.github.com> Date: Mon, 31 May 2021 15:47:27 +0800 Subject: [PATCH] level db to use a fixed database in production (#133) enabled cors --- apps/whale-api/src/main.ts | 7 ++++++- .../whale-api/src/module.database/provider.level/module.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/whale-api/src/main.ts b/apps/whale-api/src/main.ts index b4d7aabe5e..ae3aa3a512 100644 --- a/apps/whale-api/src/main.ts +++ b/apps/whale-api/src/main.ts @@ -11,7 +11,12 @@ async function bootstrap (): Promise { AppModule.forRoot(), newFastifyAdapter() ) - app.enableCors() + app.enableCors({ + origin: '*', + methods: ['GET', 'PUT', 'POST', 'DELETE'], + allowedHeaders: ['Content-Type'], + maxAge: 60 * 24 * 7 + }) await app.listen(3000, '0.0.0.0') } diff --git a/apps/whale-api/src/module.database/provider.level/module.ts b/apps/whale-api/src/module.database/provider.level/module.ts index bd963e8631..3c5e577606 100644 --- a/apps/whale-api/src/module.database/provider.level/module.ts +++ b/apps/whale-api/src/module.database/provider.level/module.ts @@ -22,7 +22,7 @@ function mkdir (location: string): void { useFactory: (configService: ConfigService): string => { const location = configService.get( 'database.level.location', - `.level/unnamed/${Date.now()}` + process.env.NODE_ENV === 'production ' ? '.level/index' : `.level/unnamed/${Date.now()}` ) mkdir(location) return location