forked from Yara724/api
Initial commit after migration to gitea
This commit is contained in:
45
src/main.ts
Normal file
45
src/main.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { NestFactory } from "@nestjs/core";
|
||||
import { NestExpressApplication } from "@nestjs/platform-express";
|
||||
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
|
||||
import * as basicAuth from "express-basic-auth";
|
||||
import { AppModule } from "./app.module";
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
|
||||
cors: true,
|
||||
});
|
||||
|
||||
app.enableCors();
|
||||
|
||||
app.enableCors({
|
||||
origin: "*",
|
||||
methods: "GET, PUT, POST, DELETE, PATCH, OPTIONS",
|
||||
allowedHeaders: "Content-Type, Authorization",
|
||||
});
|
||||
|
||||
app.use(
|
||||
["/docs", "/docs-json", "/swagger"],
|
||||
basicAuth({
|
||||
challenge: true,
|
||||
users: {
|
||||
[process.env.SWAGGER_USER]: process.env.SWAGGER_PASSWORD,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle("yara724-backend")
|
||||
.setVersion("1.0.0")
|
||||
.addServer(process.env.BASE_URL + "/api")
|
||||
.addServer(process.env.URL)
|
||||
.addServer("http://192.168.20.249:9001")
|
||||
.addServer("http://192.168.20.170:9001")
|
||||
.addServer("http://localhost:9001")
|
||||
.addBearerAuth()
|
||||
.build();
|
||||
const docs = SwaggerModule.createDocument(app, config);
|
||||
SwaggerModule.setup("/docs", app, docs);
|
||||
await app.listen(process.env.PORT);
|
||||
}
|
||||
|
||||
bootstrap();
|
||||
Reference in New Issue
Block a user