湯本 開 1ced5ef66d Merged PR 123: API実装(I/F実装)
## 概要
[Task1836: API実装(I/F実装)](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/1836)

- タスクのソート条件更新APIのI/Fを実装
- タスク一覧APIのI/Fを修正
- TODO/XXXですぐ対処可能、または単純に消し忘れているものを対処

## レビューポイント
- API I/Fの修正は妥当な内容であるか
  - 特にfilterはカンマ区切りでいいか、指定したものを除外という形式でいいか等
- TODO/XXXの対処は妥当な対処であるか

## 動作確認状況
- ローカルでswagger表示されることを確認
2023-06-02 06:12:35 +00:00

55 lines
1.8 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);
//XXX 特定のオリジンからのリクエストは許可する
app.enableCors({
origin: 'http://localhost:8180',
methods: 'GET,PUT,POST,DELETE,OPTION',
allowedHeaders: 'Origin,Content-Type,Accept,Authorization',
});
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);
}
await app.listen(process.env.PORT || 80);
}
bootstrap();