feat: add env variables for port, database url and data dir

This commit is contained in:
Elias Schneider
2023-05-05 11:37:02 +02:00
parent 5132d177b8
commit 98c0de78e8
11 changed files with 43 additions and 26 deletions

View File

@@ -6,6 +6,7 @@ import * as bodyParser from "body-parser";
import * as cookieParser from "cookie-parser";
import * as fs from "fs";
import { AppModule } from "./app.module";
import { DATA_DIRECTORY } from "./constants";
async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule);
@@ -16,7 +17,9 @@ async function bootstrap() {
app.use(cookieParser());
app.set("trust proxy", true);
await fs.promises.mkdir("./data/uploads/_temp", { recursive: true });
await fs.promises.mkdir(`${DATA_DIRECTORY}/uploads/_temp`, {
recursive: true,
});
app.setGlobalPrefix("api");
@@ -30,6 +33,6 @@ async function bootstrap() {
SwaggerModule.setup("api/swagger", app, document);
}
await app.listen(process.env.PORT || 8080);
await app.listen(parseInt(process.env.PORT) || 8080);
}
bootstrap();