Merged PR 483: strictNullCheck修正④(gateways ,notification)
## 概要 [Task2838: 修正④(gateways ,notification)](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2838) - strictNullCheckの対応 - gateways配下 - feartures - notification ## レビューポイント ## UIの変更 - Before/Afterのスクショなど - スクショ置き場 ## 動作確認状況 - ローカルで確認、develop環境で確認など ## 補足 - 相談、参考資料などがあれば
This commit is contained in:
parent
273ba588ce
commit
d258d569f7
@ -1,6 +1,7 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Post,
|
||||
Req,
|
||||
@ -21,6 +22,7 @@ import { retrieveAuthorizationToken } from '../../common/http/helper';
|
||||
import { AccessToken } from '../../common/token';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { makeContext } from '../../common/log';
|
||||
import { makeErrorResponse } from '../../common/error/makeErrorResponse';
|
||||
|
||||
@ApiTags('notification')
|
||||
@Controller('notification')
|
||||
@ -57,7 +59,20 @@ export class NotificationController {
|
||||
const { handler, pns } = body;
|
||||
|
||||
const accessToken = retrieveAuthorizationToken(req);
|
||||
const { userId } = jwt.decode(accessToken, { json: true }) as AccessToken;
|
||||
if (!accessToken) {
|
||||
throw new HttpException(
|
||||
makeErrorResponse('E000107'),
|
||||
HttpStatus.UNAUTHORIZED,
|
||||
);
|
||||
}
|
||||
const decodedAccessToken = jwt.decode(accessToken, { json: true });
|
||||
if (!decodedAccessToken) {
|
||||
throw new HttpException(
|
||||
makeErrorResponse('E000101'),
|
||||
HttpStatus.UNAUTHORIZED,
|
||||
);
|
||||
}
|
||||
const { userId } = decodedAccessToken as AccessToken;
|
||||
|
||||
const context = makeContext(userId);
|
||||
|
||||
|
||||
@ -1,4 +1,11 @@
|
||||
import { Controller, Get, HttpException, HttpStatus, Req, UseGuards } from '@nestjs/common';
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Req,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
ApiBearerAuth,
|
||||
ApiOperation,
|
||||
@ -47,7 +54,7 @@ export class TemplatesController {
|
||||
@UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] }))
|
||||
@Get()
|
||||
async getTemplates(@Req() req: Request): Promise<GetTemplatesResponse> {
|
||||
const accessToken = retrieveAuthorizationToken(req) as string;
|
||||
const accessToken = retrieveAuthorizationToken(req);
|
||||
if (!accessToken) {
|
||||
throw new HttpException(
|
||||
makeErrorResponse('E000107'),
|
||||
@ -60,7 +67,7 @@ export class TemplatesController {
|
||||
makeErrorResponse('E000101'),
|
||||
HttpStatus.UNAUTHORIZED,
|
||||
);
|
||||
}
|
||||
}
|
||||
const { userId } = decodedAccessToken as AccessToken;
|
||||
|
||||
const context = makeContext(userId);
|
||||
|
||||
@ -67,7 +67,7 @@ export class WorkflowsController {
|
||||
@Get()
|
||||
async getWorkflows(@Req() req: Request): Promise<GetWorkflowsResponse> {
|
||||
// TODO strictNullChecks対応
|
||||
const accessToken = retrieveAuthorizationToken(req) as string;
|
||||
const accessToken = retrieveAuthorizationToken(req);
|
||||
if (!accessToken) {
|
||||
throw new HttpException(
|
||||
makeErrorResponse('E000107'),
|
||||
@ -124,7 +124,7 @@ export class WorkflowsController {
|
||||
): Promise<CreateWorkflowsResponse> {
|
||||
const { authorId, worktypeId, templateId, typists } = body;
|
||||
// TODO strictNullChecks対応
|
||||
const accessToken = retrieveAuthorizationToken(req) as string;
|
||||
const accessToken = retrieveAuthorizationToken(req);
|
||||
if (!accessToken) {
|
||||
throw new HttpException(
|
||||
makeErrorResponse('E000107'),
|
||||
@ -189,7 +189,7 @@ export class WorkflowsController {
|
||||
const { authorId, worktypeId, templateId, typists } = body;
|
||||
const { workflowId } = param;
|
||||
// TODO strictNullChecks対応
|
||||
const accessToken = retrieveAuthorizationToken(req) as string;
|
||||
const accessToken = retrieveAuthorizationToken(req);
|
||||
if (!accessToken) {
|
||||
throw new HttpException(
|
||||
makeErrorResponse('E000107'),
|
||||
@ -253,7 +253,7 @@ export class WorkflowsController {
|
||||
): Promise<DeleteWorkflowResponse> {
|
||||
const { workflowId } = param;
|
||||
// TODO strictNullChecks対応
|
||||
const accessToken = retrieveAuthorizationToken(req) as string;
|
||||
const accessToken = retrieveAuthorizationToken(req);
|
||||
if (!accessToken) {
|
||||
throw new HttpException(
|
||||
makeErrorResponse('E000107'),
|
||||
|
||||
@ -58,7 +58,7 @@ export class WorkflowsService {
|
||||
});
|
||||
// externalIdsからundefinedを除外
|
||||
const filteredExternalIds = externalIds.filter(
|
||||
(externalId):externalId is string => externalId !== undefined,
|
||||
(externalId): externalId is string => externalId !== undefined,
|
||||
);
|
||||
// externalIdsから重複を除外
|
||||
const distinctedExternalIds = [...new Set(filteredExternalIds)];
|
||||
@ -98,7 +98,7 @@ export class WorkflowsService {
|
||||
(adb2cUser) => adb2cUser.id === typist.external_id,
|
||||
)?.displayName
|
||||
: typistGroup?.name;
|
||||
|
||||
|
||||
if (!typistName) {
|
||||
throw new Error('typistName is undefined');
|
||||
}
|
||||
|
||||
@ -30,8 +30,10 @@ export const isConflictError = (arg: unknown): arg is ConflictError => {
|
||||
@Injectable()
|
||||
export class AdB2cService {
|
||||
private readonly logger = new Logger(AdB2cService.name);
|
||||
private readonly tenantName = this.configService.getOrThrow<string>('TENANT_NAME');
|
||||
private readonly flowName = this.configService.getOrThrow<string>('SIGNIN_FLOW_NAME');
|
||||
private readonly tenantName =
|
||||
this.configService.getOrThrow<string>('TENANT_NAME');
|
||||
private readonly flowName =
|
||||
this.configService.getOrThrow<string>('SIGNIN_FLOW_NAME');
|
||||
private graphClient: Client;
|
||||
|
||||
constructor(private readonly configService: ConfigService) {
|
||||
|
||||
@ -28,31 +28,31 @@ export class BlobstorageService {
|
||||
private readonly sasTokenExpireHour: number;
|
||||
constructor(private readonly configService: ConfigService) {
|
||||
this.sharedKeyCredentialUS = new StorageSharedKeyCredential(
|
||||
this.configService.get('STORAGE_ACCOUNT_NAME_US'),
|
||||
this.configService.get('STORAGE_ACCOUNT_KEY_US'),
|
||||
this.configService.getOrThrow<string>('STORAGE_ACCOUNT_NAME_US'),
|
||||
this.configService.getOrThrow<string>('STORAGE_ACCOUNT_KEY_US'),
|
||||
);
|
||||
this.sharedKeyCredentialAU = new StorageSharedKeyCredential(
|
||||
this.configService.get('STORAGE_ACCOUNT_NAME_AU'),
|
||||
this.configService.get('STORAGE_ACCOUNT_KEY_AU'),
|
||||
this.configService.getOrThrow<string>('STORAGE_ACCOUNT_NAME_AU'),
|
||||
this.configService.getOrThrow<string>('STORAGE_ACCOUNT_KEY_AU'),
|
||||
);
|
||||
this.sharedKeyCredentialEU = new StorageSharedKeyCredential(
|
||||
this.configService.get('STORAGE_ACCOUNT_NAME_EU'),
|
||||
this.configService.get('STORAGE_ACCOUNT_KEY_EU'),
|
||||
this.configService.getOrThrow<string>('STORAGE_ACCOUNT_NAME_EU'),
|
||||
this.configService.getOrThrow<string>('STORAGE_ACCOUNT_KEY_EU'),
|
||||
);
|
||||
this.blobServiceClientUS = new BlobServiceClient(
|
||||
this.configService.get('STORAGE_ACCOUNT_ENDPOINT_US'),
|
||||
this.configService.getOrThrow<string>('STORAGE_ACCOUNT_ENDPOINT_US'),
|
||||
this.sharedKeyCredentialUS,
|
||||
);
|
||||
this.blobServiceClientAU = new BlobServiceClient(
|
||||
this.configService.get('STORAGE_ACCOUNT_ENDPOINT_AU'),
|
||||
this.configService.getOrThrow<string>('STORAGE_ACCOUNT_ENDPOINT_AU'),
|
||||
this.sharedKeyCredentialAU,
|
||||
);
|
||||
this.blobServiceClientEU = new BlobServiceClient(
|
||||
this.configService.get('STORAGE_ACCOUNT_ENDPOINT_EU'),
|
||||
this.configService.getOrThrow<string>('STORAGE_ACCOUNT_ENDPOINT_EU'),
|
||||
this.sharedKeyCredentialEU,
|
||||
);
|
||||
this.sasTokenExpireHour = Number(
|
||||
this.configService.get('STORAGE_TOKEN_EXPIRE_TIME'),
|
||||
this.sasTokenExpireHour = this.configService.getOrThrow<number>(
|
||||
'STORAGE_TOKEN_EXPIRE_TIME',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -18,8 +18,8 @@ export class NotificationhubService {
|
||||
private readonly client: NotificationHubsClient;
|
||||
constructor(private readonly configService: ConfigService) {
|
||||
this.client = new NotificationHubsClient(
|
||||
this.configService.get<string>('NOTIFICATION_HUB_CONNECT_STRING')??"",
|
||||
this.configService.get<string>('NOTIFICATION_HUB_NAME')??"",
|
||||
this.configService.getOrThrow<string>('NOTIFICATION_HUB_CONNECT_STRING'),
|
||||
this.configService.getOrThrow<string>('NOTIFICATION_HUB_NAME'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import { Context } from '../../common/log';
|
||||
export class SendGridService {
|
||||
private readonly logger = new Logger(SendGridService.name);
|
||||
constructor(private readonly configService: ConfigService) {
|
||||
const key = this.configService.get<string>('SENDGRID_API_KEY');
|
||||
const key = this.configService.getOrThrow<string>('SENDGRID_API_KEY');
|
||||
sendgrid.setApiKey(key);
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,6 @@ helmetDirectives['connect-src'] =
|
||||
process.env.STORAGE_ACCOUNT_ENDPOINT_EU ?? '',
|
||||
]
|
||||
: ["'self'"];
|
||||
|
||||
|
||||
helmetDirectives['navigate-to'] = ["'self'"];
|
||||
helmetDirectives['style-src'] = ["'self'", 'https:'];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user