@joelincc/mailroom 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -5
- package/SECURITY.md +1 -1
- package/bin/mailroom.mjs +26 -0
- package/dist/broadcast/config.js +79 -0
- package/dist/broadcast/explain.js +50 -0
- package/dist/cli/args.js +29 -0
- package/dist/cli/errors.js +31 -0
- package/dist/cli/main.js +475 -0
- package/dist/compose/clicks.js +29 -0
- package/dist/compose/compose.js +224 -0
- package/dist/compose/index.js +8 -0
- package/dist/compose/markdown.js +637 -0
- package/dist/compose/personalize.js +123 -0
- package/dist/compose/preflight.js +251 -0
- package/dist/compose/preview.js +41 -0
- package/dist/compose/render.js +136 -0
- package/dist/compose/template.js +118 -0
- package/docs/broadcast.md +199 -0
- package/docs/composing.md +135 -0
- package/docs/desk-commands.md +52 -0
- package/docs/export.md +51 -0
- package/docs/lists.md +66 -0
- package/docs/security-model.md +4 -4
- package/docs/ses.md +116 -0
- package/docs/unsubscribe.md +117 -0
- package/migrations/0004_last_error.sql +2 -0
- package/migrations/0005_lists.sql +41 -0
- package/migrations/0006_broadcast.sql +154 -0
- package/migrations/0007_unsubscribe.sql +12 -0
- package/package.json +19 -3
- package/src/alert.ts +123 -0
- package/src/aws-sigv4.ts +100 -0
- package/src/broadcast/audience.ts +96 -0
- package/src/broadcast/campaigns.ts +339 -0
- package/src/broadcast/config.ts +136 -0
- package/src/broadcast/dispatch.ts +766 -0
- package/src/broadcast/events.ts +107 -0
- package/src/broadcast/explain.ts +73 -0
- package/src/broadcast/freeze.ts +93 -0
- package/src/broadcast/index.ts +21 -0
- package/src/broadcast/postman.ts +229 -0
- package/src/broadcast/reconcile.ts +120 -0
- package/src/broadcast/routes.ts +181 -0
- package/src/broadcast/ses.ts +181 -0
- package/src/broadcast/stats.ts +59 -0
- package/src/broadcast/status.ts +60 -0
- package/src/broadcast/test-send.ts +88 -0
- package/src/broadcast/warmup.ts +150 -0
- package/src/broadcast/worker.ts +177 -0
- package/src/cf-events.ts +4 -3
- package/src/cli/args.ts +27 -0
- package/src/cli/errors.ts +33 -0
- package/src/cli/main.ts +466 -0
- package/src/compose/clicks.ts +45 -0
- package/src/compose/compose.ts +257 -0
- package/src/compose/index.ts +8 -0
- package/src/compose/markdown.ts +624 -0
- package/src/compose/personalize.ts +130 -0
- package/src/compose/preflight.ts +250 -0
- package/src/compose/preview.ts +58 -0
- package/src/compose/render.ts +153 -0
- package/src/compose/template.ts +197 -0
- package/src/core.ts +42 -1
- package/src/export.ts +184 -0
- package/src/feedback.ts +111 -0
- package/src/http.ts +17 -0
- package/src/index.ts +120 -31
- package/src/list-routes.ts +42 -0
- package/src/lists.ts +370 -0
- package/src/ses-events.ts +426 -0
- package/src/unsub-wiring.ts +64 -0
- package/src/unsub.ts +499 -0
- package/src/webhook.ts +5 -3
- package/wrangler.example.jsonc +16 -2
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// 信件樣板:把「正文」包進頁首/頁尾,變成完整信件。
|
|
2
|
+
// 樣板是設定,不是程式:引擎只給一個通用的樣板工廠 createTemplate(),品牌樣板(名稱、頁尾、地址、文案)放私有設定。
|
|
3
|
+
// 表格排版+內嵌 CSS(Outlook 看得到)、深色模式用 class 覆寫(不把底色反白)。
|
|
4
|
+
|
|
5
|
+
export interface Theme {
|
|
6
|
+
font: string;
|
|
7
|
+
text: string;
|
|
8
|
+
muted: string;
|
|
9
|
+
link: string;
|
|
10
|
+
bg: string;
|
|
11
|
+
card: string;
|
|
12
|
+
border: string;
|
|
13
|
+
accent: string;
|
|
14
|
+
codeBg: string;
|
|
15
|
+
/** 內容寬度(px)。 */
|
|
16
|
+
width: number;
|
|
17
|
+
dark: { bg: string; card: string; text: string; muted: string; link: string; border: string; codeBg: string };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const DEFAULT_THEME: Theme = {
|
|
21
|
+
font: "-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang TC','Noto Sans TC','Microsoft JhengHei',Helvetica,Arial,sans-serif",
|
|
22
|
+
text: '#222222',
|
|
23
|
+
muted: '#6b6b6b',
|
|
24
|
+
link: '#1a56c4',
|
|
25
|
+
bg: '#f3f3f3',
|
|
26
|
+
card: '#ffffff',
|
|
27
|
+
border: '#dddddd',
|
|
28
|
+
accent: '#333333',
|
|
29
|
+
codeBg: '#f5f5f5',
|
|
30
|
+
width: 600,
|
|
31
|
+
dark: { bg: '#111111', card: '#1c1c1c', text: '#e8e8e8', muted: '#a0a0a0', link: '#8ab4f8', border: '#3a3a3a', codeBg: '#262626' },
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export interface Labels {
|
|
35
|
+
/** 頁首小字連結:「在瀏覽器開啟」。 */
|
|
36
|
+
viewInBrowser: string;
|
|
37
|
+
/** 頁尾退訂連結文字。 */
|
|
38
|
+
unsubscribe: string;
|
|
39
|
+
/** 頁尾「這封信寄給 {email}」;用 {email} 代表位置。 */
|
|
40
|
+
sentTo: string;
|
|
41
|
+
/** 嵌入內容(影片、互動圖表)換成的連結卡文字。 */
|
|
42
|
+
embedCard: string;
|
|
43
|
+
/** 純文字版的圖片標記;alt 為原稿的替代文字。 */
|
|
44
|
+
image: (alt: string) => string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const DEFAULT_LABELS: Labels = {
|
|
48
|
+
viewInBrowser: 'View in browser',
|
|
49
|
+
unsubscribe: 'Unsubscribe',
|
|
50
|
+
sentTo: 'This email was sent to {email}',
|
|
51
|
+
embedCard: 'This content is best viewed on the website →',
|
|
52
|
+
image: (alt) => (alt ? `[Image: ${alt}]` : '[Image]'),
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type FooterLine = string | { text: string; href: string };
|
|
56
|
+
|
|
57
|
+
export interface TemplateConfig {
|
|
58
|
+
/** 頁首名稱(純文字)。 */
|
|
59
|
+
brandName: string;
|
|
60
|
+
tagline?: string;
|
|
61
|
+
/** 頁首圖示(絕對 https 網址);沒有就只放名稱。 */
|
|
62
|
+
logoUrl?: string;
|
|
63
|
+
/** <html lang>。 */
|
|
64
|
+
lang?: string;
|
|
65
|
+
theme?: Partial<Theme> & { dark?: Partial<Theme['dark']> };
|
|
66
|
+
labels?: Partial<Labels>;
|
|
67
|
+
/** 正文前的問候語;可含 {{name}}。整段包在 {{#name}} 內,沒有名字就整段不出現。例:「Hi {{name}},」。 */
|
|
68
|
+
greeting?: string;
|
|
69
|
+
/** 頁尾每行(純文字,會被跳脫;{ text, href } 為連結)。 */
|
|
70
|
+
footerLines?: FooterLine[];
|
|
71
|
+
/** 頁尾的自訂區塊(受信任的 HTML,由設定的擁有者提供,不經跳脫;可含 {{web_url}} 等佔位)。放在 footerLines 之前。 */
|
|
72
|
+
footerHtml?: string;
|
|
73
|
+
/** footerHtml 的純文字版(純文字信用);同樣可含佔位。 */
|
|
74
|
+
footerText?: string;
|
|
75
|
+
/** 退訂連結前面的引導句,例「Don't want these emails?」;沒給就只有連結。 */
|
|
76
|
+
unsubscribeLead?: string;
|
|
77
|
+
/** 實體地址(寄前檢查要求一定有、且不能是待補標記)。 */
|
|
78
|
+
postalAddress: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface TemplateParts {
|
|
82
|
+
subject: string;
|
|
83
|
+
preheader: string;
|
|
84
|
+
bodyHtml: string;
|
|
85
|
+
bodyText: string;
|
|
86
|
+
/** 開信圖網址(含 {{o}} 佔位);沒開追蹤就是 undefined。 */
|
|
87
|
+
pixelUrl?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface EmailTemplate {
|
|
91
|
+
theme: Theme;
|
|
92
|
+
labels: Labels;
|
|
93
|
+
postalAddress: string;
|
|
94
|
+
renderHtml(p: TemplateParts): string;
|
|
95
|
+
renderText(p: TemplateParts): string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function escapeHtml(s: string): string {
|
|
99
|
+
return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\uE000/g, '{');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function mergeTheme(t: TemplateConfig['theme']): Theme {
|
|
103
|
+
return { ...DEFAULT_THEME, ...t, dark: { ...DEFAULT_THEME.dark, ...(t?.dark ?? {}) } };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function createTemplate(cfg: TemplateConfig): EmailTemplate {
|
|
107
|
+
const theme = mergeTheme(cfg.theme);
|
|
108
|
+
const labels: Labels = { ...DEFAULT_LABELS, ...cfg.labels };
|
|
109
|
+
const lang = cfg.lang ?? 'en';
|
|
110
|
+
const w = theme.width;
|
|
111
|
+
const d = theme.dark;
|
|
112
|
+
const footer = cfg.footerLines ?? [];
|
|
113
|
+
|
|
114
|
+
const css = `
|
|
115
|
+
body,table,td,a{-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}
|
|
116
|
+
table{border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0}
|
|
117
|
+
img{border:0;outline:none;text-decoration:none;-ms-interpolation-mode:bicubic}
|
|
118
|
+
a{word-break:break-word}
|
|
119
|
+
@media only screen and (max-width:${w + 20}px){.mr-wrap{width:100%!important}.mr-pad{padding-left:16px!important;padding-right:16px!important}}
|
|
120
|
+
@media (prefers-color-scheme:dark){
|
|
121
|
+
.mr-bg{background:${d.bg}!important}
|
|
122
|
+
.mr-card{background:${d.card}!important}
|
|
123
|
+
.mr-text{color:${d.text}!important}
|
|
124
|
+
.mr-muted{color:${d.muted}!important}
|
|
125
|
+
.mr-link{color:${d.link}!important}
|
|
126
|
+
.mr-bd{border-color:${d.border}!important}
|
|
127
|
+
.mr-code{background:${d.codeBg}!important}
|
|
128
|
+
}`;
|
|
129
|
+
|
|
130
|
+
const renderHtml = (p: TemplateParts): string => {
|
|
131
|
+
const pre = escapeHtml(p.preheader);
|
|
132
|
+
const header = cfg.logoUrl
|
|
133
|
+
? `<img src="${escapeHtml(cfg.logoUrl)}" alt="${escapeHtml(cfg.brandName)}" height="36" style="display:block;border:0;height:36px;width:auto">`
|
|
134
|
+
: `<span class="mr-text" style="font-size:20px;font-weight:700;color:${theme.accent}">${escapeHtml(cfg.brandName)}</span>`;
|
|
135
|
+
const tagline = cfg.tagline ? `<div class="mr-muted" style="font-size:13px;color:${theme.muted};margin-top:2px">${escapeHtml(cfg.tagline)}</div>` : '';
|
|
136
|
+
const greeting = cfg.greeting ? `{{#name}}<p class="mr-text" style="margin:0 0 18px;font-size:16px;line-height:1.8;color:${theme.text}">${escapeHtml(cfg.greeting)}</p>{{/name}}` : '';
|
|
137
|
+
const footLines = footer
|
|
138
|
+
.map((l) =>
|
|
139
|
+
typeof l === 'string'
|
|
140
|
+
? `<p class="mr-muted" style="margin:0 0 6px;font-size:12px;line-height:1.7;color:${theme.muted}">${escapeHtml(l)}</p>`
|
|
141
|
+
: `<p style="margin:0 0 6px;font-size:12px;line-height:1.7"><a class="mr-link" href="${escapeHtml(l.href)}" style="color:${theme.link}">${escapeHtml(l.text)}</a></p>`,
|
|
142
|
+
)
|
|
143
|
+
.join('');
|
|
144
|
+
const sentTo = labels.sentTo.replace('{email}', '{{email}}');
|
|
145
|
+
const lead = cfg.unsubscribeLead ? `${escapeHtml(cfg.unsubscribeLead)} ` : '';
|
|
146
|
+
return `<!doctype html>
|
|
147
|
+
<html lang="${escapeHtml(lang)}" xmlns="http://www.w3.org/1999/xhtml">
|
|
148
|
+
<head>
|
|
149
|
+
<meta charset="utf-8">
|
|
150
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
151
|
+
<meta name="color-scheme" content="light dark">
|
|
152
|
+
<meta name="supported-color-schemes" content="light dark">
|
|
153
|
+
<title>${escapeHtml(p.subject)}</title>
|
|
154
|
+
<style>${css}</style>
|
|
155
|
+
</head>
|
|
156
|
+
<body class="mr-bg" style="margin:0;padding:0;background:${theme.bg};word-break:break-word">
|
|
157
|
+
<div style="display:none;max-height:0;overflow:hidden;opacity:0;mso-hide:all;font-size:1px;line-height:1px;color:${theme.bg}">${pre}${'‌ '.repeat(40)}</div>
|
|
158
|
+
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" class="mr-bg" style="background:${theme.bg}"><tr><td align="center" style="padding:20px 10px">
|
|
159
|
+
<!--[if mso]><table role="presentation" width="${w}" cellpadding="0" cellspacing="0" border="0"><tr><td><![endif]-->
|
|
160
|
+
<table role="presentation" class="mr-wrap" width="${w}" cellpadding="0" cellspacing="0" border="0" style="width:${w}px;max-width:100%">
|
|
161
|
+
<tr><td class="mr-pad" style="padding:0 4px 12px;font-family:${theme.font}">
|
|
162
|
+
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="font-family:${theme.font}">${header}${tagline}</td>
|
|
163
|
+
<td align="right" style="font-family:${theme.font};font-size:12px"><a class="mr-link" href="{{web_url}}" style="color:${theme.link}">${escapeHtml(labels.viewInBrowser)}</a></td></tr></table>
|
|
164
|
+
</td></tr>
|
|
165
|
+
<tr><td class="mr-card mr-bd mr-pad" style="background:${theme.card};border:1px solid ${theme.border};padding:28px 32px;font-family:${theme.font};color:${theme.text}">
|
|
166
|
+
${greeting}${p.bodyHtml}
|
|
167
|
+
</td></tr>
|
|
168
|
+
<tr><td class="mr-pad" style="padding:16px 4px;font-family:${theme.font}">
|
|
169
|
+
${cfg.footerHtml ?? ''}${footLines}<p class="mr-muted" style="margin:0 0 6px;font-size:12px;line-height:1.7;color:${theme.muted}">${escapeHtml(cfg.postalAddress)}</p>
|
|
170
|
+
{{#email}}<p class="mr-muted" style="margin:0 0 6px;font-size:12px;line-height:1.7;color:${theme.muted}">${escapeHtml(sentTo)}</p>{{/email}}
|
|
171
|
+
<p class="mr-muted" style="margin:0;font-size:12px;line-height:1.7;color:${theme.muted}">${lead}<a class="mr-link" href="{{unsubscribe_url}}" style="color:${theme.link}">${escapeHtml(labels.unsubscribe)}</a></p>
|
|
172
|
+
${p.pixelUrl ? `<img src="${escapeHtml(p.pixelUrl)}" width="1" height="1" alt="" style="display:block;border:0;width:1px;height:1px">` : ''}
|
|
173
|
+
</td></tr>
|
|
174
|
+
</table>
|
|
175
|
+
<!--[if mso]></td></tr></table><![endif]-->
|
|
176
|
+
</td></tr></table>
|
|
177
|
+
</body>
|
|
178
|
+
</html>`;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const renderText = (p: TemplateParts): string => {
|
|
182
|
+
const lines: string[] = [];
|
|
183
|
+
lines.push(cfg.brandName + (cfg.tagline ? ` — ${cfg.tagline}` : ''));
|
|
184
|
+
lines.push(`${labels.viewInBrowser}: {{web_url}}`);
|
|
185
|
+
lines.push('');
|
|
186
|
+
if (cfg.greeting) lines.push(`{{#name}}${cfg.greeting}{{/name}}`, '');
|
|
187
|
+
lines.push(p.bodyText.trim(), '', '--');
|
|
188
|
+
if (cfg.footerText) lines.push(cfg.footerText.trim());
|
|
189
|
+
for (const l of footer) lines.push(typeof l === 'string' ? l : `${l.text}: ${l.href}`);
|
|
190
|
+
lines.push(cfg.postalAddress);
|
|
191
|
+
lines.push(`{{#email}}${labels.sentTo.replace('{email}', '{{email}}')}{{/email}}`);
|
|
192
|
+
lines.push(`${cfg.unsubscribeLead ? `${cfg.unsubscribeLead} ` : ''}${labels.unsubscribe}: {{unsubscribe_url}}`);
|
|
193
|
+
return lines.join('\n').replace(/\n{3,}/g, '\n\n').replace(/\n{{#email}}{{\/email}}/g, '') + '\n';
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
return { theme, labels, postalAddress: cfg.postalAddress, renderHtml, renderText };
|
|
197
|
+
}
|
package/src/core.ts
CHANGED
|
@@ -61,7 +61,7 @@ export interface SendResult {
|
|
|
61
61
|
|
|
62
62
|
export interface MessageRow {
|
|
63
63
|
id: number; stream: Stream; tier: Tier | null; site: string; dedupe_key: string; kind: string | null; to_email: string; from_addr: string;
|
|
64
|
-
subject: string; status: string; route: string | null; provider_id: string | null; error: string | null; attempts: number;
|
|
64
|
+
subject: string; status: string; route: string | null; provider_id: string | null; error: string | null; last_error: string | null; attempts: number;
|
|
65
65
|
last_event: string | null; created_at: string; updated_at: string; sent_at: string | null;
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -217,6 +217,46 @@ export async function pruneRate(db: Db, now = new Date()): Promise<void> {
|
|
|
217
217
|
await db.prepare("DELETE FROM rate_counters WHERE (win LIKE 'm:%' AND win < ?) OR (win LIKE 'd:%' AND win < ?)").bind(`m:${cutoff.slice(0, 16)}`, `d:${cutoff.slice(0, 10)}`).run();
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
/**
|
|
221
|
+
* 走公開網址的站的寄件白名單檢查。該站沒列白名單=拒收('allowlist_required');
|
|
222
|
+
* 有列但這封的寄件人不在內='from_not_allowed';通過回 null。
|
|
223
|
+
*/
|
|
224
|
+
export function checkHttpFrom(table: Record<string, string[]> | undefined, site: string, rawFrom: unknown): 'allowlist_required' | 'from_not_allowed' | null {
|
|
225
|
+
const allowed = table?.[site];
|
|
226
|
+
if (!Array.isArray(allowed) || allowed.length === 0) return 'allowlist_required';
|
|
227
|
+
const from = parseAddress(String(rawFrom ?? ''));
|
|
228
|
+
if (!from || !allowed.map((a) => String(a).toLowerCase()).includes(from.addr)) return 'from_not_allowed';
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** 帳本保存天數設定:沒設、空白或不合法=null(不自動清);只接受 ≥1 的整數(0 不算,避免誤設成把帳本全清)。 */
|
|
233
|
+
export function retentionDays(v: unknown): number | null {
|
|
234
|
+
const n = typeof v === 'number' ? v : typeof v === 'string' && /^\d+$/.test(v.trim()) ? Number(v.trim()) : NaN;
|
|
235
|
+
return Number.isInteger(n) && n >= 1 ? n : null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* 清掉超過保存天數的帳本列(messages 看 created_at、webhook_events 看 received_at)。
|
|
240
|
+
* 「正在寄」的列不動;拒收名單不清(那是防線不是紀錄)。一次最多清 limit 列,沒清完下一輪排程接著清。
|
|
241
|
+
* 回傳實際刪掉的列數。
|
|
242
|
+
*/
|
|
243
|
+
/** 電子報的帳本列至少留這麼多天(去重與網域滾動比率都靠它;保存天數設得再短也不清)。 */
|
|
244
|
+
export const MIN_MARKETING_RETENTION_DAYS = 400;
|
|
245
|
+
|
|
246
|
+
export async function purgeLedger(db: Db, days: number, now = new Date(), limit = 5000): Promise<{ messages: number; webhookEvents: number }> {
|
|
247
|
+
const cutoff = new Date(now.getTime() - days * 86_400_000).toISOString();
|
|
248
|
+
const marketingCutoff = new Date(now.getTime() - Math.max(days, MIN_MARKETING_RETENTION_DAYS) * 86_400_000).toISOString();
|
|
249
|
+
const m = await db
|
|
250
|
+
.prepare("DELETE FROM messages WHERE id IN (SELECT id FROM messages WHERE created_at < ? AND status != 'sending' AND (stream != 'marketing' OR created_at < ?) ORDER BY id LIMIT ?)")
|
|
251
|
+
.bind(cutoff, marketingCutoff, limit)
|
|
252
|
+
.run();
|
|
253
|
+
const w = await db
|
|
254
|
+
.prepare('DELETE FROM webhook_events WHERE id IN (SELECT id FROM webhook_events WHERE received_at < ? LIMIT ?)')
|
|
255
|
+
.bind(cutoff, limit)
|
|
256
|
+
.run();
|
|
257
|
+
return { messages: m.meta.changes ?? 0, webhookEvents: w.meta.changes ?? 0 };
|
|
258
|
+
}
|
|
259
|
+
|
|
220
260
|
export async function lookup(db: Db, site: string, key: string): Promise<MessageRow | null> {
|
|
221
261
|
return db.prepare('SELECT * FROM messages WHERE site = ? AND dedupe_key = ?').bind(site, key).first<MessageRow>();
|
|
222
262
|
}
|
|
@@ -247,6 +287,7 @@ export async function send(deps: CoreDeps, req: SendRequest, opts: { forceInvali
|
|
|
247
287
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)
|
|
248
288
|
ON CONFLICT (site, dedupe_key) DO UPDATE SET
|
|
249
289
|
status = excluded.status, error = excluded.error, attempts = messages.attempts + 1, updated_at = excluded.updated_at,
|
|
290
|
+
last_error = COALESCE(messages.error, messages.last_error),
|
|
250
291
|
to_email = excluded.to_email, from_addr = excluded.from_addr, subject = excluded.subject, tier = excluded.tier
|
|
251
292
|
WHERE messages.status IN ('failed', 'suppressed') OR (messages.status = 'sending' AND messages.updated_at < ?)
|
|
252
293
|
RETURNING id`,
|
package/src/export.ts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// 分析匯出:把事件、期別、凍結名單、名單成員用 NDJSON 一頁一頁交給外面的分析管線(帶管理口令)。見 docs/export.md。
|
|
2
|
+
//
|
|
3
|
+
// GET /v1/export/events?cursor=&limit= 事件(依 id 遞增;cursor=上一頁回的 x-export-next-cursor)
|
|
4
|
+
// POST /v1/export/events/ack { through } 分析端「已經安全存好」到哪個事件 id:標 exported_at(可重複執行)
|
|
5
|
+
// GET /v1/export/campaigns?cursor=&limit= 每期一列(寄送時間、狀態)
|
|
6
|
+
// GET /v1/export/recipients?campaign=&cursor=&limit= 某一期的凍結名單(寄的當下每人的分群;不含信箱)
|
|
7
|
+
// GET /v1/export/members?list=&cursor=&limit= 某份名單目前所有成員(含信箱,每週快照用)
|
|
8
|
+
//
|
|
9
|
+
// 設計重點:
|
|
10
|
+
// - 讀取本身不改任何東西:同一個 cursor 重拉一定拿到同一批(除了新進來的)。中途失敗的人只要從上次存好的 cursor 再來,不會漏也不會重。
|
|
11
|
+
// - 「分析端存好了」才呼叫 ack;ack 只是標記(exported_at),不影響下一次從哪裡拉,拉到哪由分析端自己記 cursor。
|
|
12
|
+
// - 事件只帶 contact_id,不帶信箱(記事件時與匯出時都會把 detail 裡信箱形狀的字串遮掉);要對到信箱用 members 快照。
|
|
13
|
+
// - D1 的寫入是一筆一筆依序提交,AUTOINCREMENT 的 id 看得到 N+1 就代表 N 已提交,依 id 往後拉不會跳過。
|
|
14
|
+
// - 自己一組速度上限(_export),不跟其他管理入口搶額度。
|
|
15
|
+
|
|
16
|
+
import { takeRate, type Db } from './core.ts';
|
|
17
|
+
import { bearer, json, notFound, sameToken } from './http.ts';
|
|
18
|
+
|
|
19
|
+
export const EXPORT_LIMITS = { perMinute: 60, perDay: 1000 };
|
|
20
|
+
export const EXPORT_DEFAULT_PAGE = 2000;
|
|
21
|
+
export const EXPORT_MAX_PAGE = 5000;
|
|
22
|
+
|
|
23
|
+
const PATH = /^\/v1\/export\/(events|campaigns|recipients|members)$/;
|
|
24
|
+
const ACK_PATH = '/v1/export/events/ack';
|
|
25
|
+
const LIST_ID = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
26
|
+
const CAMPAIGN_ID = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
27
|
+
|
|
28
|
+
const EMAIL = /[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+/g;
|
|
29
|
+
/** 事件的 detail 不該帶信箱:遞迴走訪,只在每個字串值上把信箱形狀的字串遮成 [email](@頻道 這類不是信箱,原樣保留)。
|
|
30
|
+
* 不碰 JSON 原文,所以字串裡的跳脫字元(\t、\n、控制字元)後面接信箱也安全;任何情況都不丟例外——
|
|
31
|
+
* 萬一出事,整個 detail 換成固定標記,事件照樣寫入/匯出。已知限制:像 pkg@1.2.3 的版本號會被誤遮、%40 編碼的信箱不會被遮。 */
|
|
32
|
+
export function scrubEmails(value: unknown, depth = 0): unknown {
|
|
33
|
+
try {
|
|
34
|
+
if (typeof value === 'string') return value.includes('@') ? value.replace(EMAIL, '[email]') : value;
|
|
35
|
+
if (value === null || typeof value !== 'object') return value;
|
|
36
|
+
if (depth > 20) return '[scrub-depth-limit]';
|
|
37
|
+
if (Array.isArray(value)) return value.map((v) => scrubEmails(v, depth + 1));
|
|
38
|
+
const out: Record<string, unknown> = {};
|
|
39
|
+
for (const [k, v] of Object.entries(value)) out[k.includes('@') ? k.replace(EMAIL, '[email]') : k] = scrubEmails(v, depth + 1);
|
|
40
|
+
return out;
|
|
41
|
+
} catch {
|
|
42
|
+
return { scrub_failed: true };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const ndjson = (rows: unknown[], next: string | null): Response =>
|
|
47
|
+
new Response(rows.map((r) => JSON.stringify(r)).join('\n') + (rows.length ? '\n' : ''), {
|
|
48
|
+
headers: {
|
|
49
|
+
'content-type': 'application/x-ndjson; charset=utf-8',
|
|
50
|
+
'cache-control': 'no-store',
|
|
51
|
+
'x-export-count': String(rows.length),
|
|
52
|
+
'x-export-has-more': next === null ? '0' : '1',
|
|
53
|
+
'x-export-next-cursor': next ?? '',
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
function parseJson(text: string | null | undefined): unknown {
|
|
58
|
+
if (!text) return null;
|
|
59
|
+
try {
|
|
60
|
+
return JSON.parse(text);
|
|
61
|
+
} catch {
|
|
62
|
+
return { _unparsed: String(text).slice(0, 500) };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function pageLimit(raw: string | null): number {
|
|
67
|
+
const n = Math.trunc(Number(raw));
|
|
68
|
+
return Math.min(Math.max(Number.isFinite(n) && n > 0 ? n : EXPORT_DEFAULT_PAGE, 1), EXPORT_MAX_PAGE);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** cursor 只收十進位整數;沒給=從頭(0)。 */
|
|
72
|
+
function parseCursor(raw: string | null): number | null {
|
|
73
|
+
if (raw === null || raw === '') return 0;
|
|
74
|
+
return /^\d{1,15}$/.test(raw) ? Number(raw) : null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function exportEvents(db: Db, cursor: number, limit: number): Promise<{ rows: unknown[]; next: string | null }> {
|
|
78
|
+
const r = await db
|
|
79
|
+
.prepare(
|
|
80
|
+
`SELECT id, provider, provider_event_id, message_id, provider_message_id, campaign_id, contact_id, type, subtype, at, detail, exported_at
|
|
81
|
+
FROM events WHERE id > ? ORDER BY id LIMIT ?`,
|
|
82
|
+
)
|
|
83
|
+
.bind(cursor, limit + 1)
|
|
84
|
+
.all<Record<string, unknown> & { id: number; detail: string | null }>();
|
|
85
|
+
const more = r.results.length > limit;
|
|
86
|
+
const page = r.results.slice(0, limit);
|
|
87
|
+
return { rows: page.map((e) => ({ ...e, detail: scrubEmails(parseJson(e.detail)) })), next: more ? String(page[page.length - 1].id) : null };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** 標記 id ≤ through 的事件已匯出。through 不能超過目前最大 id(防呼叫端算錯把還沒拉的也標掉)。 */
|
|
91
|
+
export async function ackEvents(db: Db, through: unknown, now: Date): Promise<{ ok: true; marked: number } | { ok: false; reason: 'bad_through' | 'beyond_max' }> {
|
|
92
|
+
if (typeof through !== 'number' || !Number.isInteger(through) || through < 0) return { ok: false, reason: 'bad_through' };
|
|
93
|
+
const max = await db.prepare('SELECT COALESCE(MAX(id), 0) AS m FROM events').first<{ m: number }>();
|
|
94
|
+
if (through > Number(max?.m ?? 0)) return { ok: false, reason: 'beyond_max' };
|
|
95
|
+
const r = await db.prepare('UPDATE events SET exported_at = ? WHERE id <= ? AND exported_at IS NULL').bind(now.toISOString(), through).run();
|
|
96
|
+
return { ok: true, marked: Number(r.meta.changes ?? 0) };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export async function exportCampaigns(db: Db, cursor: number, limit: number): Promise<{ rows: unknown[]; next: string | null }> {
|
|
100
|
+
const r = await db
|
|
101
|
+
.prepare(
|
|
102
|
+
`SELECT rowid AS seq, id, list_id, subject, from_addr, status, scheduled_at, started_at, finished_at, frozen_at, pause_reason, created_at, updated_at
|
|
103
|
+
FROM campaigns WHERE rowid > ? ORDER BY rowid LIMIT ?`,
|
|
104
|
+
)
|
|
105
|
+
.bind(cursor, limit + 1)
|
|
106
|
+
.all<Record<string, unknown> & { seq: number }>();
|
|
107
|
+
const more = r.results.length > limit;
|
|
108
|
+
const page = r.results.slice(0, limit);
|
|
109
|
+
return { rows: page, next: more ? String(page[page.length - 1].seq) : null };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export async function exportRecipients(db: Db, campaign: string, cursor: number, limit: number): Promise<{ rows: unknown[]; next: string | null }> {
|
|
113
|
+
const r = await db
|
|
114
|
+
.prepare(
|
|
115
|
+
`SELECT campaign_id, contact_id, segment, wave, state, skip_reason, enqueued_at, done_at
|
|
116
|
+
FROM campaign_recipients WHERE campaign_id = ? AND contact_id > ? ORDER BY contact_id LIMIT ?`,
|
|
117
|
+
)
|
|
118
|
+
.bind(campaign, cursor, limit + 1)
|
|
119
|
+
.all<Record<string, unknown> & { contact_id: number }>();
|
|
120
|
+
const more = r.results.length > limit;
|
|
121
|
+
const page = r.results.slice(0, limit);
|
|
122
|
+
return { rows: page, next: more ? String(page[page.length - 1].contact_id) : null };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export async function exportMembers(db: Db, list: string, cursor: number, limit: number): Promise<{ rows: unknown[]; next: string | null }> {
|
|
126
|
+
const r = await db
|
|
127
|
+
.prepare(
|
|
128
|
+
`SELECT m.list_id, m.contact_id, c.email AS email, m.status, m.subscribed_at, m.unsubscribed_at, m.unsub_source, m.source,
|
|
129
|
+
m.segment, m.segment_label, m.segment_at, m.imported_from, m.last_open_at, m.last_click_at, m.updated_at
|
|
130
|
+
FROM list_members m JOIN contacts c ON c.id = m.contact_id
|
|
131
|
+
WHERE m.list_id = ? AND m.contact_id > ? ORDER BY m.contact_id LIMIT ?`,
|
|
132
|
+
)
|
|
133
|
+
.bind(list, cursor, limit + 1)
|
|
134
|
+
.all<Record<string, unknown> & { contact_id: number }>();
|
|
135
|
+
const more = r.results.length > limit;
|
|
136
|
+
const page = r.results.slice(0, limit);
|
|
137
|
+
return { rows: page, next: more ? String(page[page.length - 1].contact_id) : null };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** 路徑不是匯出入口=回 null(交給後面的路由);口令不對一律 404(不透露入口存在)。 */
|
|
141
|
+
export async function routeExport(request: Request, db: Db, adminToken: string | undefined, now: () => Date = () => new Date()): Promise<Response | null> {
|
|
142
|
+
const url = new URL(request.url);
|
|
143
|
+
const m = PATH.exec(url.pathname);
|
|
144
|
+
const isAck = url.pathname === ACK_PATH;
|
|
145
|
+
if (!m && !isAck) return null;
|
|
146
|
+
const wanted = isAck ? 'POST' : 'GET';
|
|
147
|
+
if (request.method !== wanted) return notFound();
|
|
148
|
+
if (!sameToken(bearer(request), adminToken ?? '')) return notFound();
|
|
149
|
+
const over = await takeRate(db, '_export', EXPORT_LIMITS, now());
|
|
150
|
+
if (over) return new Response('rate limited', { status: 429, headers: { 'retry-after': over === 'day' ? '3600' : '60' } });
|
|
151
|
+
|
|
152
|
+
if (isAck) {
|
|
153
|
+
const body = (await request.json().catch(() => null)) as { through?: unknown } | null;
|
|
154
|
+
if (!body || typeof body !== 'object' || Array.isArray(body)) return json({ ok: false, reason: 'bad_json' }, 400);
|
|
155
|
+
const r = await ackEvents(db, body.through, now());
|
|
156
|
+
return json(r, r.ok ? 200 : 400);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const cursor = parseCursor(url.searchParams.get('cursor'));
|
|
160
|
+
if (cursor === null) return json({ ok: false, reason: 'bad_cursor' }, 400);
|
|
161
|
+
const limit = pageLimit(url.searchParams.get('limit'));
|
|
162
|
+
switch (m![1]) {
|
|
163
|
+
case 'events': {
|
|
164
|
+
const r = await exportEvents(db, cursor, limit);
|
|
165
|
+
return ndjson(r.rows, r.next);
|
|
166
|
+
}
|
|
167
|
+
case 'campaigns': {
|
|
168
|
+
const r = await exportCampaigns(db, cursor, limit);
|
|
169
|
+
return ndjson(r.rows, r.next);
|
|
170
|
+
}
|
|
171
|
+
case 'recipients': {
|
|
172
|
+
const campaign = url.searchParams.get('campaign') ?? '';
|
|
173
|
+
if (!CAMPAIGN_ID.test(campaign)) return json({ ok: false, reason: 'bad_campaign' }, 400);
|
|
174
|
+
const r = await exportRecipients(db, campaign, cursor, limit);
|
|
175
|
+
return ndjson(r.rows, r.next);
|
|
176
|
+
}
|
|
177
|
+
default: {
|
|
178
|
+
const list = url.searchParams.get('list') ?? '';
|
|
179
|
+
if (!LIST_ID.test(list)) return json({ ok: false, reason: 'bad_list' }, 400);
|
|
180
|
+
const r = await exportMembers(db, list, cursor, limit);
|
|
181
|
+
return ndjson(r.rows, r.next);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
package/src/feedback.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// 退信與檢舉怎麼進拒收:吃「已經正規化的事件」。事件從哪家郵差來、簽章怎麼驗,不在這裡(由接郵差的那一層做完再呼叫)。
|
|
2
|
+
// 不 import cloudflare:*,測試用 Node 內建 SQLite 跑同一份 SQL。
|
|
3
|
+
//
|
|
4
|
+
// 規則:
|
|
5
|
+
// - 永久退信 → 全域拒收 hard_bounce(所有信都不寄,包含登入類通知信)。
|
|
6
|
+
// - 檢舉 → 全域拒收 complaint(同上),並把這個人在所有名單標 unsubscribed(unsub_source='complaint')。
|
|
7
|
+
// - 暫時性退信 → 不擋;信箱層級(cause=mailbox)的,同一人連續 3 期(三個不同的期別、中間沒有送達)→ 當硬退信處理;內容被拒這類不累計。
|
|
8
|
+
// - 送達 → 清掉這個人的暫時退信紀錄(連續中斷)。
|
|
9
|
+
// 全部可重複執行:同一則事件送兩次,結果一樣。
|
|
10
|
+
|
|
11
|
+
import { addSuppression, type Db } from './core.ts';
|
|
12
|
+
import { normalizeEmail } from './lists.ts';
|
|
13
|
+
|
|
14
|
+
export type FeedbackEvent =
|
|
15
|
+
| { type: 'bounce'; kind: 'permanent'; email: string; source: string; detail?: string | null }
|
|
16
|
+
| {
|
|
17
|
+
type: 'bounce';
|
|
18
|
+
kind: 'transient';
|
|
19
|
+
email: string;
|
|
20
|
+
/** 這封信屬於哪一期;沒有期別就不計入連續。 */
|
|
21
|
+
campaign?: string | null;
|
|
22
|
+
/**
|
|
23
|
+
* 為什麼暫時退信。只有 'mailbox'(信箱層級:信箱滿了、收信伺服器暫時掛了、對方限速)才累計;
|
|
24
|
+
* 'content'(內容被拒、附件被拒、信太大)跟信箱無關,不累計,免得把正常讀者誤判成硬退信。沒給=不累計。
|
|
25
|
+
* SES 對照(ses-events.ts):Transient 的 MailboxFull → mailbox;ContentRejected、AttachmentRejected、MessageTooLarge → content;
|
|
26
|
+
* Transient 的 General、CustomTimeoutExceeded 與 Undetermined 都不帶(原因不明,寧可不累計也不要誤判成硬退信)。
|
|
27
|
+
*/
|
|
28
|
+
cause?: TransientCause;
|
|
29
|
+
source: string;
|
|
30
|
+
detail?: string | null;
|
|
31
|
+
}
|
|
32
|
+
| { type: 'complaint'; email: string; source: string; detail?: string | null }
|
|
33
|
+
| { type: 'delivery'; email: string };
|
|
34
|
+
|
|
35
|
+
export type TransientCause = 'mailbox' | 'content';
|
|
36
|
+
|
|
37
|
+
export type FeedbackOutcome =
|
|
38
|
+
| 'hard_bounce'
|
|
39
|
+
| 'complaint'
|
|
40
|
+
| 'transient_counted'
|
|
41
|
+
| 'transient_promoted'
|
|
42
|
+
| 'transient_no_campaign'
|
|
43
|
+
| 'transient_not_counted'
|
|
44
|
+
| 'delivery'
|
|
45
|
+
| 'rejected';
|
|
46
|
+
|
|
47
|
+
/** 連續幾期暫時性退信就當硬退信。 */
|
|
48
|
+
export const TRANSIENT_LIMIT = 3;
|
|
49
|
+
|
|
50
|
+
export interface FeedbackOptions {
|
|
51
|
+
now?: () => Date;
|
|
52
|
+
/** 連續幾期暫時性退信算硬退信(預設 3)。 */
|
|
53
|
+
transientLimit?: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const CAMPAIGN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,39}$/;
|
|
57
|
+
|
|
58
|
+
export async function applyFeedback(db: Db, ev: FeedbackEvent, opts: FeedbackOptions = {}): Promise<FeedbackOutcome> {
|
|
59
|
+
const email = normalizeEmail((ev as { email?: unknown })?.email);
|
|
60
|
+
if (!email) return 'rejected';
|
|
61
|
+
const now = (opts.now ?? (() => new Date()))();
|
|
62
|
+
const t = now.toISOString();
|
|
63
|
+
const source = 'source' in ev && typeof ev.source === 'string' && ev.source.trim() ? ev.source.trim().slice(0, 40) : 'feedback';
|
|
64
|
+
|
|
65
|
+
if (ev.type === 'delivery') {
|
|
66
|
+
await db.prepare('DELETE FROM bounce_streaks WHERE email = ?').bind(email).run();
|
|
67
|
+
return 'delivery';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (ev.type === 'complaint') {
|
|
71
|
+
await addSuppression(db, email, 'complaint', source, ev.detail ?? null, now);
|
|
72
|
+
// 這個人明白說了「不要」:所有名單一起退出。已經退訂的保留原本的時間與來源。
|
|
73
|
+
await db
|
|
74
|
+
.prepare(
|
|
75
|
+
`UPDATE list_members SET
|
|
76
|
+
unsubscribed_at = CASE WHEN status = 'unsubscribed' THEN unsubscribed_at ELSE ? END,
|
|
77
|
+
unsub_source = CASE WHEN status = 'unsubscribed' THEN unsub_source ELSE 'complaint' END,
|
|
78
|
+
updated_at = CASE WHEN status = 'unsubscribed' THEN updated_at ELSE ? END,
|
|
79
|
+
status = 'unsubscribed'
|
|
80
|
+
WHERE contact_id = (SELECT id FROM contacts WHERE email = ?)`,
|
|
81
|
+
)
|
|
82
|
+
.bind(t, t, email)
|
|
83
|
+
.run();
|
|
84
|
+
await db.prepare('DELETE FROM bounce_streaks WHERE email = ?').bind(email).run();
|
|
85
|
+
return 'complaint';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (ev.type === 'bounce' && ev.kind === 'permanent') {
|
|
89
|
+
// 名單裡的狀態不動(不是讀者的決定);拒收名單擋住所有寄送,人工解除拒收後就恢復。
|
|
90
|
+
await addSuppression(db, email, 'hard_bounce', source, ev.detail ?? null, now);
|
|
91
|
+
await db.prepare('DELETE FROM bounce_streaks WHERE email = ?').bind(email).run();
|
|
92
|
+
return 'hard_bounce';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (ev.type === 'bounce' && ev.kind === 'transient') {
|
|
96
|
+
if (ev.cause !== 'mailbox') return 'transient_not_counted';
|
|
97
|
+
if (typeof ev.campaign !== 'string' || !CAMPAIGN.test(ev.campaign)) return 'transient_no_campaign';
|
|
98
|
+
// 同一期同一人只算一次(重送的事件不會重複計數)。
|
|
99
|
+
await db.prepare('INSERT INTO bounce_streaks (email, campaign_id, at) VALUES (?, ?, ?) ON CONFLICT (email, campaign_id) DO NOTHING').bind(email, ev.campaign, t).run();
|
|
100
|
+
const n = await db.prepare('SELECT COUNT(*) AS n FROM bounce_streaks WHERE email = ?').bind(email).first<{ n: number }>();
|
|
101
|
+
const limit = Math.max(1, Math.trunc(opts.transientLimit ?? TRANSIENT_LIMIT));
|
|
102
|
+
if (Number(n?.n ?? 0) >= limit) {
|
|
103
|
+
await addSuppression(db, email, 'hard_bounce', source, `transient_streak:${limit}`, now);
|
|
104
|
+
await db.prepare('DELETE FROM bounce_streaks WHERE email = ?').bind(email).run();
|
|
105
|
+
return 'transient_promoted';
|
|
106
|
+
}
|
|
107
|
+
return 'transient_counted';
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return 'rejected';
|
|
111
|
+
}
|
package/src/http.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// 小工具:比對口令、讀 Bearer。獨立成檔,路由模組與測試不必 import cloudflare:workers。
|
|
2
|
+
|
|
3
|
+
export function sameToken(a: string, b: string): boolean {
|
|
4
|
+
if (!a || !b || a.length !== b.length) return false;
|
|
5
|
+
let diff = 0;
|
|
6
|
+
for (let i = 0; i < a.length; i++) diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
7
|
+
return diff === 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function bearer(request: Request): string {
|
|
11
|
+
const m = /^Bearer\s+(.+)$/i.exec(request.headers.get('authorization') ?? '');
|
|
12
|
+
return m ? m[1].trim() : '';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const json = (body: unknown, status = 200) =>
|
|
16
|
+
new Response(JSON.stringify(body), { status, headers: { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' } });
|
|
17
|
+
export const notFound = () => new Response('Not found', { status: 404 });
|