makabe.t 904d65780b Merged PR 96: 外部連携APISwaggerエラー修正
## 概要
[Task1732: 外部連携APISwaggerエラー修正](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/1732)

- Swaggerの構文で不要な文言が残ったままでしたので削除しました。

## レビューポイント
- 共有

## UIの変更
無し

## 動作確認状況
- ローカルで確認
  - Swaggerでエラーがないことを確認
2023-05-10 23:54:20 +00:00

53 lines
1.7 KiB
TypeScript

import { NestFactory } from '@nestjs/core';
import cookieParser from 'cookie-parser';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';
import helmet from 'helmet';
const helmetDirectives = helmet.contentSecurityPolicy.getDefaultDirectives();
helmetDirectives['connect-src'] = [
"'self'",
'https://adb2codmsdev.b2clogin.com/adb2codmsdev.onmicrosoft.com/b2c_1_signin_dev/v2.0/.well-known/openid-configuration',
'https://adb2codmsdev.b2clogin.com/adb2codmsdev.onmicrosoft.com/b2c_1_signin_dev/oauth2/v2.0/token',
];
helmetDirectives['navigate-to'] = ["'self'"];
helmetDirectives['style-src'] = ["'self'", 'https:'];
helmetDirectives['report-uri'] = ["'self'"];
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
cors: process.env.CORS === 'TRUE',
});
app.use(
helmet({
contentSecurityPolicy: {
directives: helmetDirectives,
},
}),
cookieParser(),
);
// バリデーター(+型の自動変換機能)を適用
app.useGlobalPipes(
new ValidationPipe({ transform: true, forbidUnknownValues: false }),
);
if (process.env.STAGE === 'local') {
const options = new DocumentBuilder()
.setTitle('ODMSOpenAPI')
.setVersion('1.0.0')
.addBearerAuth({
type: 'http',
scheme: 'bearer',
bearerFormat: 'JWT',
})
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document);
}
// TODO:検証のためポートを固定 後で直す
// await app.listen(process.env.PORT || 80);
await app.listen(process.env.PORT || 80);
}
bootstrap();