## 概要 [Task2656: 画面実装(テンプレートファイルアップロードPopup)](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2656) - テンプレートファイルアップロードのAPI呼び出し周りを実装 - SASトークン付きURL取得 - Blobストレージへファイルアップロード - アップロード完了 - server側 - `helmet`の`connect-src`を修正 - SASトークン付きURLが想定と違っていたため修正 - DBに保存するURLが想定と違っていたため修正 ## レビューポイント - `connect-src`の`self`以外はローカル環境のみの設定でよさそう? - Popupの挙動で不足している箇所はあるか - アップロードファイルでチェックすべき内容等 ## UIの変更 - https://ndstokyo.sharepoint.com/:f:/r/sites/Piranha/Shared%20Documents/General/OMDS/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88/Task2656?csf=1&web=1&e=iU1huG ## 動作確認状況 - ローカルで確認 ## 補足 - 相談、参考資料などがあれば
56 lines
1.6 KiB
TypeScript
56 lines
1.6 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'] =
|
|
process.env.STAGE === 'local'
|
|
? [
|
|
"'self'",
|
|
process.env.ADB2C_ORIGIN,
|
|
process.env.STORAGE_ACCOUNT_ENDPOINT_US,
|
|
process.env.STORAGE_ACCOUNT_ENDPOINT_AU,
|
|
process.env.STORAGE_ACCOUNT_ENDPOINT_EU,
|
|
]
|
|
: ["'self'"];
|
|
|
|
helmetDirectives['navigate-to'] = ["'self'"];
|
|
helmetDirectives['style-src'] = ["'self'", 'https:'];
|
|
helmetDirectives['report-uri'] = ["'self'"];
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create(AppModule);
|
|
|
|
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();
|