/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/providers/email-sendgrid/src/index.ts
61 строка
1 KB
Arthur
feat(provider-email-sendgrid): add region option for EU data residency (#25907)
26 июн 2026, 20:20
Не верифицирован
26 июн 2026, 20:20
a9aea4e
Код
Авторство
О чём код?
import sendgrid, { MailDataRequired } from '@sendgrid/mail'; interface Settings { defaultFrom: string; defaultReplyTo: string; } interface SendOptions { from?: string; to: string; cc: string; bcc: string; replyTo?: string; subject: string; text: string; html: string; [key: string]: unknown; } interface ProviderOptions { apiKey: string; region?: 'eu' | 'global'; } export default { init(providerOptions: ProviderOptions, settings: Settings) { sendgrid.setApiKey(providerOptions.apiKey); if (providerOptions.region) { (sendgrid as any).client.setDataResidency(providerOptions.region); } return { send(options: SendOptions): Promise<void> { return new Promise((resolve, reject) => { const { from, to, cc, bcc, replyTo, subject, text, html, ...rest } = options; const msg: MailDataRequired = { from: from || settings.defaultFrom, to, cc, bcc, replyTo: replyTo || settings.defaultReplyTo, subject, text, html, ...rest, }; sendgrid.send(msg, false, (err) => { if (err) { reject(err); } else { resolve(); } }); }); }, }; }, };