38 lines
983 B
TypeScript
38 lines
983 B
TypeScript
|
|
import { NestFactory } from "@nestjs/core"
|
||
|
|
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger"
|
||
|
|
|
||
|
|
import { AppModule } from "./app.module"
|
||
|
|
|
||
|
|
async function bootstrap() {
|
||
|
|
const app = await NestFactory.create(AppModule)
|
||
|
|
|
||
|
|
app.setGlobalPrefix("api")
|
||
|
|
app.enableShutdownHooks()
|
||
|
|
|
||
|
|
const openApiConfig = new DocumentBuilder()
|
||
|
|
.setTitle("Image Platform API")
|
||
|
|
.setDescription("Control plane for image assets, variants, S3 storage and external imgproxy.")
|
||
|
|
.setVersion("0.1.0")
|
||
|
|
.addTag("system")
|
||
|
|
.addTag("assets")
|
||
|
|
.addTag("variants")
|
||
|
|
.addTag("allowed-hosts")
|
||
|
|
.addTag("internal-images")
|
||
|
|
.build()
|
||
|
|
|
||
|
|
const openApiDocument = SwaggerModule.createDocument(app, openApiConfig)
|
||
|
|
|
||
|
|
SwaggerModule.setup("docs", app, openApiDocument, {
|
||
|
|
jsonDocumentUrl: "docs-json",
|
||
|
|
swaggerOptions: {
|
||
|
|
persistAuthorization: true,
|
||
|
|
},
|
||
|
|
})
|
||
|
|
|
||
|
|
const port = Number.parseInt(process.env.API_PORT ?? "3001", 10)
|
||
|
|
|
||
|
|
await app.listen(port)
|
||
|
|
}
|
||
|
|
|
||
|
|
void bootstrap()
|