masaaki fee99a0974 Merged PR 583: [ライセンスアラート改善]AzureAdB2Cアクセスの効率化
## 概要
[Task3023: [ライセンスアラート改善]AzureAdB2Cアクセスの効率化](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3023)

ADB2Cからユーザーを取得する際に、Redisによるキャッシュ保存・キャッシュからの取得を行う処理を実装しました。

## レビューポイント
処理の妥当性などを全体的にお願いします。

## UIの変更
なし

## 動作確認状況
ローカルで動作確認済み

## 補足
なし
2023-12-01 01:39:18 +00:00

47 lines
846 B
TypeScript

import sendgrid from "@sendgrid/mail";
import { error } from "console";
export class SendGridService {
constructor() {
if (!process.env.SENDGRID_API_KEY) {
throw error;
}
sendgrid.setApiKey(process.env.SENDGRID_API_KEY);
}
/**
* メールを送信する
* @param to
* @param from
* @param subject
* @param text
* @param html
* @returns mail
*/
async sendMail(
to: string,
from: string,
subject: string,
text: string,
html: string
): Promise<void> {
try {
const res = await sendgrid
.send({
from: {
email: from,
},
to: {
email: to,
},
subject: subject,
text: text,
html: html,
})
.then((v) => v[0]);
} catch (e) {
throw e;
}
}
}