2 Commits
Author SHA1 Message Date
AImighty Bot 5fe8562774 Courier 26.11.26: Scaleway als optionaler Versanddienst
ci / build (push) Successful in 36s
2026-11-27 10:08:51 +00:00
AImighty Bot 8d735a7e80 Courier 26.11.25: Abstand zwischen Hinweis und Karte
ci / build (push) Successful in 40s
2026-11-25 10:31:28 +00:00
22 changed files with 257 additions and 62 deletions

No files matched your search

+6 -1
View File
@@ -1,7 +1,7 @@
# Datenbank (lokal oder Olares-Middleware)
DATABASE_URL=postgresql://courier@127.0.0.1:55432/courier
# dry-run | resend | ses
# dry-run | resend | ses | scaleway
MAIL_TRANSPORT=dry-run
MAIL_FROM_DOMAIN=hubsport.club
@@ -23,3 +23,8 @@ RESEND_API_KEY=
# Öffentliche Adresse (für SNS-Webhook/Anzeige)
PUBLIC_BASE_URL=http://127.0.0.1:3400
# Scaleway Transactional Email (optional)
SCW_SECRET_KEY=
SCW_PROJECT_ID=
SCW_REGION=fr-par
+27 -6
View File
@@ -10,9 +10,9 @@ metadata:
name: courier
appid: courier
title: Courier
description: Transaktionsmail für deine Apps über Amazon SES.
description: Transaktionsmail für deine Apps über Amazon SES oder Scaleway.
icon: https://git.aimighty.olares.de/aimighty/courier/raw/branch/main/icon.png
version: 26.11.24
version: 26.11.26
categories:
- Applications
@@ -79,6 +79,27 @@ envs:
editable: false
applyOnChange: false
default: "arn:aws:sns:eu-west-1:945831802901:courier-ses-events"
- envName: SCW_SECRET_KEY
required: false
type: password
editable: true
applyOnChange: true
default: ""
description: "Scaleway API Secret Key (Transactional Email)."
- envName: SCW_PROJECT_ID
required: false
type: string
editable: true
applyOnChange: true
default: ""
description: "Scaleway Project ID für Transactional Email."
- envName: SCW_REGION
required: false
type: string
editable: true
applyOnChange: true
default: "fr-par"
description: "Scaleway-Region für Transactional Email."
- envName: MAIL_FROM_DOMAIN
required: true
type: string
@@ -94,8 +115,8 @@ envs:
options:
- title: Amazon SES
value: ses
- title: Resend (Übergang)
value: resend
- title: Scaleway Transactional Email
value: scaleway
- title: Dry-Run
value: dry-run
- envName: GLOBAL_DAILY_LIMIT
@@ -106,11 +127,11 @@ envs:
default: "1000"
spec:
versionName: '26.11.24'
versionName: '26.11.26'
fullDescription: |
**Courier** ist ein kleiner Versanddienst für transaktionale E-Mails:
eine Resend-kompatible HTTP-API, Warteschlange, Retry, Logs und
Zustellereignisse. Der Versand läuft über Amazon SES.
Zustellereignisse. Der Versand läuft über Amazon SES; optional über Scaleway Transactional Email.
**Funktionen**
- `POST /api/emails` und `/api/emails/batch` (Resend-kompatibel)
+1
View File
@@ -12,6 +12,7 @@ export async function GET() {
transport: config.transport,
fromDomain: config.fromDomain,
sesConfigured: Boolean(process.env.AWS_ACCESS_KEY_ID || process.env.AWS_PROFILE),
scalewayConfigured: Boolean(process.env.SCW_SECRET_KEY && process.env.SCW_PROJECT_ID),
});
} catch (error) {
return Response.json(
+18
View File
@@ -40,6 +40,24 @@ export default function Docs() {
</p>
</section>
<section className="karte app-panel app-section">
<h2>Versanddienst wählen</h2>
<p className="app-muted">
Amazon SES bleibt der Standard. Ein API-Key kann optional über Scaleway
Transactional Email senden; die Auswahl steht beim Erzeugen des Keys unter{" "}
<a href="/keys">API-Keys</a>.
</p>
<pre className="app-code">{`# Scaleway (EU)
SCW_SECRET_KEY=SCW...
SCW_PROJECT_ID=<project-id>
SCW_REGION=fr-par`}</pre>
<p className="app-muted">
Die Absenderdomain muss im Scaleway-Konto verifiziert sein. Scaleway
unterstützt keine SES-SNS-Ereignisse; der Status bleibt dort zunächst
<code>sent</code>, bis ein eigener Webhook angebunden ist.
</p>
</section>
<section className="karte app-panel app-section">
<h2>Gemeinsame Vorlage (optional)</h2>
<p className="app-muted">
+4
View File
@@ -735,6 +735,10 @@ body {
flex-wrap: wrap;
}
.app-main > .ds-alert {
margin-bottom: var(--ds-space-6);
}
.app-section {
margin-top: var(--ds-space-6);
}
+5 -3
View File
@@ -11,12 +11,14 @@ export async function createKey(_previous: KeyState, formData: FormData): Promis
const app = String(formData.get("app") ?? "").trim().toLowerCase();
const name = String(formData.get("name") ?? "").trim();
const domain = String(formData.get("domain") ?? "hubsport.club").trim().toLowerCase();
const provider = String(formData.get("provider") ?? "").trim() || null;
const from = String(formData.get("from") ?? "").trim().toLowerCase();
const daily = Number(formData.get("daily") ?? 500);
const monthly = Number(formData.get("monthly") ?? 15000);
if (!/^[a-z0-9][a-z0-9_-]{1,30}$/.test(app)) return { error: "App-Name: 2–31 Zeichen, a–z, 0–9, _ oder -" };
if (!name) return { error: "Bezeichnung fehlt" };
if (provider && provider !== "ses" && provider !== "scaleway") return { error: "Unbekannter Versanddienst" };
if (!/^[a-z0-9.-]+\.[a-z]{2,}$/.test(domain)) return { error: "Ungültige Domain" };
if (!Number.isInteger(daily) || daily < 1 || daily > 100000) return { error: "Tageslimit ungültig" };
if (!Number.isInteger(monthly) || monthly < 1 || monthly > 1000000) return { error: "Monatslimit ungültig" };
@@ -25,9 +27,9 @@ export async function createKey(_previous: KeyState, formData: FormData): Promis
const key = generateKey();
try {
await query(
`insert into api_keys (app, name, prefix, key_hash, from_domain, allowed_from, daily_limit, monthly_limit)
values ($1,$2,$3,$4,$5,$6,$7,$8)`,
[app, name, keyPrefix(key), hashKey(key), domain, from ? [from] : null, daily, monthly],
`insert into api_keys (app, name, prefix, key_hash, from_domain, provider, allowed_from, daily_limit, monthly_limit)
values ($1,$2,$3,$4,$5,$6,$7,$8,$9)`,
[app, name, keyPrefix(key), hashKey(key), domain, provider, from ? [from] : null, daily, monthly],
);
} catch (error) {
return { error: error instanceof Error ? error.message : "Key konnte nicht gespeichert werden" };
+5
View File
@@ -74,6 +74,7 @@ export default async function Keys() {
<th>Bezeichnung</th>
<th>Prefix</th>
<th className="app-hide-sm">Domain</th>
<th>Versand</th>
<th>Limit</th>
<th className="app-hide-sm">Zuletzt</th>
<th>Status</th>
@@ -87,6 +88,7 @@ export default async function Keys() {
<td>{key.name}</td>
<td className="app-mono">{key.prefix}…</td>
<td className="app-hide-sm">{key.from_domain}</td>
<td>{key.provider === "scaleway" ? "Scaleway" : key.provider === "resend" ? "Resend" : "Amazon SES"}</td>
<td className="app-mono app-nowrap">
{key.daily_limit}/Tag · {key.monthly_limit}/Monat
</td>
@@ -132,6 +134,9 @@ export default async function Keys() {
</div>
<div className="app-mobile-item__meta">
<span className="app-mono">{key.prefix}…</span>
<span>
{key.provider === "scaleway" ? "Scaleway" : key.provider === "resend" ? "Resend" : "Amazon SES"}
</span>
<span className="app-mono">
{key.daily_limit}/Tag · {key.monthly_limit}/Monat
</span>
+4 -2
View File
@@ -67,7 +67,9 @@ export default async function Nachricht({ params }: { params: Promise<{ id: stri
<dd>
{message.cc_emails.join(", ") || "–"} / {message.bcc_emails.join(", ") || "–"}
</dd>
<dt>SES-ID</dt>
<dt>Versand</dt>
<dd>{message.provider === "scaleway" ? "Scaleway" : message.provider === "resend" ? "Resend" : "Amazon SES"}</dd>
<dt>Provider-ID</dt>
<dd className="app-mono">{message.provider_message_id || "–"}</dd>
<dt>Erstellt</dt>
<dd className="app-mono">{datum(message.created_at)}</dd>
@@ -110,7 +112,7 @@ export default async function Nachricht({ params }: { params: Promise<{ id: stri
<div className="ds-empty">
<p className="ds-empty__title">Noch keine Zustellereignisse</p>
<p className="ds-empty__text">
SES meldet Zustellung, Bounce und Beschwerde über SNS zurück.
SES meldet Zustellung, Bounce und Beschwerde über SNS zurück. Für Scaleway sind noch keine Ereignisse angebunden.
</p>
</div>
)}
+11
View File
@@ -0,0 +1,11 @@
-- Optionaler Versandweg pro API-Key. NULL bedeutet: MAIL_TRANSPORT verwenden.
alter table api_keys
add column if not exists provider text;
alter table messages
add column if not exists provider text;
create index if not exists messages_provider_idx on messages (provider);
comment on column api_keys.provider is 'Optional provider override: ses, scaleway or resend; null uses MAIL_TRANSPORT';
comment on column messages.provider is 'Provider chosen at enqueue time; null uses MAIL_TRANSPORT at send time';
+5 -2
View File
@@ -1,13 +1,14 @@
import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
import { config } from "./config";
import { config, type TransportName } from "./config";
import { query } from "./db";
export type ApiKey = {
id: string;
app: string;
fromDomain: string;
provider: TransportName | null;
allowedFrom: string[] | null;
dailyLimit: number;
monthlyLimit: number;
@@ -17,6 +18,7 @@ type KeyRow = {
id: string;
app: string;
from_domain: string;
provider: TransportName | null;
allowed_from: string[] | null;
daily_limit: number;
monthly_limit: number;
@@ -47,7 +49,7 @@ export async function authenticate(request: Request): Promise<ApiKey | null> {
if (!token.startsWith("ck_live_")) return null;
const { rows } = await query<KeyRow>(
`select id, app, from_domain, allowed_from, daily_limit, monthly_limit
`select id, app, from_domain, provider, allowed_from, daily_limit, monthly_limit
from api_keys
where key_hash = $1 and revoked_at is null`,
[hashKey(token)],
@@ -60,6 +62,7 @@ export async function authenticate(request: Request): Promise<ApiKey | null> {
id: row.id,
app: row.app,
fromDomain: row.from_domain,
provider: row.provider,
allowedFrom: row.allowed_from,
dailyLimit: row.daily_limit,
monthlyLimit: row.monthly_limit,
+5 -2
View File
@@ -1,7 +1,7 @@
export const config = {
fromDomain: process.env.MAIL_FROM_DOMAIN || "hubsport.club",
transport: (process.env.MAIL_TRANSPORT || "dry-run") as "dry-run" | "ses" | "resend",
transport: (process.env.MAIL_TRANSPORT || "dry-run") as TransportName,
databaseUrl:
process.env.DATABASE_URL ||
`postgresql://courier@127.0.0.1:${process.env.DB_PORT || "55432"}/courier`,
@@ -12,7 +12,10 @@ export const config = {
awsRegion: process.env.AWS_REGION || "eu-west-1",
sesConfigurationSet: process.env.SES_CONFIGURATION_SET || "courier-transactional",
resendApiKey: process.env.RESEND_API_KEY || "",
scalewaySecretKey: process.env.SCW_SECRET_KEY || "",
scalewayProjectId: process.env.SCW_PROJECT_ID || "",
scalewayRegion: process.env.SCW_REGION || "fr-par",
publicBaseUrl: process.env.PUBLIC_BASE_URL || "",
};
export type TransportName = typeof config.transport;
export type TransportName = "dry-run" | "ses" | "resend" | "scaleway";
+2
View File
@@ -88,6 +88,7 @@ export async function messageDetail(id: string) {
const { rows } = await query<{
id: string;
app: string;
provider: string | null;
provider_message_id: string | null;
from_email: string;
from_name: string | null;
@@ -120,6 +121,7 @@ export async function listApiKeys() {
name: string;
prefix: string;
from_domain: string;
provider: string | null;
allowed_from: string[] | null;
daily_limit: number;
monthly_limit: number;
+3 -2
View File
@@ -110,15 +110,16 @@ export async function enqueue(
const id = randomUUID();
const inserted = await client.query<{ id: string }>(
`insert into messages (
id, api_key_id, app, from_email, from_name, to_emails, cc_emails, bcc_emails,
id, api_key_id, app, provider, from_email, from_name, to_emails, cc_emails, bcc_emails,
reply_to, subject, status, payload, idempotency_key
) values ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,'queued',$11,$12)
) values ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,'queued',$12,$13)
on conflict (api_key_id, idempotency_key) do nothing
returning id`,
[
id,
apiKey.id,
apiKey.app,
apiKey.provider,
mail.from.address,
mail.from.name ?? null,
addressesOf(mail.to),
+103 -32
View File
@@ -1,11 +1,10 @@
import { randomUUID } from "node:crypto";
import { SESv2Client, SendEmailCommand } from "@aws-sdk/client-sesv2";
import MailComposer from "nodemailer/lib/mail-composer";
import { addressesOf, formatMailbox } from "./address";
import { config } from "./config";
import { config, type TransportName } from "./config";
import type { StoredPayload } from "./queue";
export type SendResult = { providerMessageId: string };
@@ -43,51 +42,110 @@ function buildRaw(payload: StoredPayload): Promise<Buffer> {
});
}
export async function sendStored(payload: StoredPayload): Promise<SendResult> {
if (config.transport === "dry-run") {
console.log("[courier] dry-run", JSON.stringify({ from: payload.from, to: payload.to, subject: payload.subject }));
return { providerMessageId: `dry-${randomUUID()}` };
function failure(message: string, statusCode?: number, retryable = false): SendFailure {
return Object.assign(new Error(message), { statusCode, retryable });
}
async function sendResend(payload: StoredPayload): Promise<SendResult> {
if (!config.resendApiKey) throw failure("RESEND_API_KEY fehlt");
const response = await fetch("https://api.resend.com/emails", {
method: "POST",
headers: {
authorization: `Bearer ${config.resendApiKey}`,
"content-type": "application/json",
},
body: JSON.stringify({
from: formatMailbox(payload.from),
to: payload.to.map(formatMailbox),
cc: payload.cc.map(formatMailbox),
bcc: payload.bcc.map(formatMailbox),
reply_to: payload.reply_to.map(formatMailbox),
subject: payload.subject,
html: payload.html,
text: payload.text,
headers: payload.headers,
attachments: payload.attachments.map((item) => ({
filename: item.filename,
content: item.content,
content_type: item.content_type,
content_id: item.content_id,
})),
tags: payload.tags,
}),
});
if (!response.ok) {
const detail = await response.text();
throw failure(`Resend ${response.status}: ${detail}`, response.status, response.status === 429 || response.status >= 500);
}
const data = (await response.json()) as { id?: string };
if (!data.id) throw failure("Resend lieferte keine Message-ID");
return { providerMessageId: data.id };
}
function scalewayMailbox(mailbox: { address: string; name?: string }) {
return mailbox.name ? { email: mailbox.address, name: mailbox.name } : { email: mailbox.address };
}
async function sendScaleway(payload: StoredPayload): Promise<SendResult> {
if (!config.scalewaySecretKey) throw failure("SCW_SECRET_KEY fehlt");
if (!config.scalewayProjectId) throw failure("SCW_PROJECT_ID fehlt");
const additionalHeaders = Object.entries(payload.headers).map(([key, value]) => ({ key, value }));
if (payload.reply_to.length) {
additionalHeaders.push({ key: "Reply-To", value: payload.reply_to.map(formatMailbox).join(", ") });
}
if (config.transport === "resend") {
if (!config.resendApiKey) throw Object.assign(new Error("RESEND_API_KEY fehlt"), { retryable: false });
const response = await fetch("https://api.resend.com/emails", {
const endpoint = `https://api.scaleway.com/transactional-email/v1alpha1/regions/${encodeURIComponent(config.scalewayRegion)}/emails`;
let response: Response;
try {
response = await fetch(endpoint, {
method: "POST",
headers: {
authorization: `Bearer ${config.resendApiKey}`,
"X-Auth-Token": config.scalewaySecretKey,
"content-type": "application/json",
},
body: JSON.stringify({
from: formatMailbox(payload.from),
to: payload.to.map(formatMailbox),
cc: payload.cc.map(formatMailbox),
bcc: payload.bcc.map(formatMailbox),
reply_to: payload.reply_to.map(formatMailbox),
project_id: config.scalewayProjectId,
from: scalewayMailbox(payload.from),
to: payload.to.map(scalewayMailbox),
cc: payload.cc.map(scalewayMailbox),
bcc: payload.bcc.map(scalewayMailbox),
subject: payload.subject,
html: payload.html,
text: payload.text,
headers: payload.headers,
html: payload.html,
attachments: payload.attachments.map((item) => ({
filename: item.filename,
name: item.filename,
type: item.content_type || "application/octet-stream",
content: item.content,
content_type: item.content_type,
})),
tags: payload.tags,
additional_headers: additionalHeaders,
}),
});
if (!response.ok) {
const detail = await response.text();
const error = Object.assign(new Error(`Resend ${response.status}: ${detail}`), {
retryable: response.status === 429 || response.status >= 500,
statusCode: response.status,
});
throw error;
}
const data = (await response.json()) as { id?: string };
if (!data.id) throw Object.assign(new Error("Resend lieferte keine Message-ID"), { retryable: false });
return { providerMessageId: data.id };
} catch (error) {
throw Object.assign(error as Error, { retryable: true });
}
if (!response.ok) {
const detail = await response.text();
throw failure(
`Scaleway ${response.status}: ${detail}`,
response.status,
response.status === 429 || response.status >= 500,
);
}
const data = (await response.json()) as {
emails?: { id?: string; message_id?: string }[];
};
const first = data.emails?.[0];
const id = first?.message_id || first?.id;
if (!id) throw failure("Scaleway lieferte keine Message-ID");
return { providerMessageId: id };
}
async function sendSes(payload: StoredPayload): Promise<SendResult> {
const raw = await buildRaw(payload);
const client = new SESv2Client({ region: config.awsRegion });
try {
@@ -105,7 +163,7 @@ export async function sendStored(payload: StoredPayload): Promise<SendResult> {
EmailTags: payload.tags.map((tag) => ({ Name: tag.name, Value: tag.value })),
}),
);
if (!result.MessageId) throw Object.assign(new Error("SES lieferte keine Message-ID"), { retryable: false });
if (!result.MessageId) throw failure("SES lieferte keine Message-ID");
return { providerMessageId: result.MessageId };
} catch (error) {
const status = (error as { $metadata?: { httpStatusCode?: number } }).$metadata?.httpStatusCode;
@@ -118,3 +176,16 @@ export async function sendStored(payload: StoredPayload): Promise<SendResult> {
throw Object.assign(error as Error, { retryable, statusCode: status });
}
}
export async function sendStored(
payload: StoredPayload,
provider: TransportName = config.transport,
): Promise<SendResult> {
if (provider === "dry-run") {
console.log("[courier] dry-run", JSON.stringify({ from: payload.from, to: payload.to, subject: payload.subject }));
return { providerMessageId: `dry-${randomUUID()}` };
}
if (provider === "resend") return sendResend(payload);
if (provider === "scaleway") return sendScaleway(payload);
return sendSes(payload);
}
+2 -2
View File
@@ -2,7 +2,7 @@ apiVersion: v2
name: courier
description: Transaktionsmail-Gateway für hubsport.club über Amazon SES.
type: application
version: 26.11.24
appVersion: "26.11.24"
version: 26.11.26
appVersion: "26.11.26"
icon: https://git.aimighty.olares.de/aimighty/courier/raw/branch/main/icon.png
home: https://git.aimighty.olares.de/aimighty/courier
+27 -6
View File
@@ -10,9 +10,9 @@ metadata:
name: courier
appid: courier
title: Courier
description: Transaktionsmail für deine Apps über Amazon SES.
description: Transaktionsmail für deine Apps über Amazon SES oder Scaleway.
icon: https://git.aimighty.olares.de/aimighty/courier/raw/branch/main/icon.png
version: 26.11.24
version: 26.11.26
categories:
- Applications
@@ -79,6 +79,27 @@ envs:
editable: false
applyOnChange: false
default: "arn:aws:sns:eu-west-1:945831802901:courier-ses-events"
- envName: SCW_SECRET_KEY
required: false
type: password
editable: true
applyOnChange: true
default: ""
description: "Scaleway API Secret Key (Transactional Email)."
- envName: SCW_PROJECT_ID
required: false
type: string
editable: true
applyOnChange: true
default: ""
description: "Scaleway Project ID für Transactional Email."
- envName: SCW_REGION
required: false
type: string
editable: true
applyOnChange: true
default: "fr-par"
description: "Scaleway-Region für Transactional Email."
- envName: MAIL_FROM_DOMAIN
required: true
type: string
@@ -94,8 +115,8 @@ envs:
options:
- title: Amazon SES
value: ses
- title: Resend (Übergang)
value: resend
- title: Scaleway Transactional Email
value: scaleway
- title: Dry-Run
value: dry-run
- envName: GLOBAL_DAILY_LIMIT
@@ -106,11 +127,11 @@ envs:
default: "1000"
spec:
versionName: '26.11.24'
versionName: '26.11.26'
fullDescription: |
**Courier** ist ein kleiner Versanddienst für transaktionale E-Mails:
eine Resend-kompatible HTTP-API, Warteschlange, Retry, Logs und
Zustellereignisse. Der Versand läuft über Amazon SES.
Zustellereignisse. Der Versand läuft über Amazon SES; optional über Scaleway Transactional Email.
**Funktionen**
- `POST /api/emails` und `/api/emails/batch` (Resend-kompatibel)
+9
View File
@@ -46,6 +46,10 @@ spec:
value: {{ .Values.olaresEnv.SES_CONFIGURATION_SET | quote }}
- name: SNS_TOPIC_ARN
value: {{ .Values.olaresEnv.SNS_TOPIC_ARN | quote }}
- name: SCW_PROJECT_ID
value: {{ .Values.olaresEnv.SCW_PROJECT_ID | quote }}
- name: SCW_REGION
value: {{ .Values.olaresEnv.SCW_REGION | quote }}
- name: TZ
value: {{ .Values.app.timezone | quote }}
- name: PORT
@@ -72,6 +76,11 @@ spec:
secretKeyRef:
name: courier-secrets
key: SNS_WEBHOOK_TOKEN
- name: SCW_SECRET_KEY
valueFrom:
secretKeyRef:
name: courier-secrets
key: SCW_SECRET_KEY
readinessProbe:
httpGet:
path: /api/health/
+9
View File
@@ -42,6 +42,10 @@ spec:
value: {{ .Values.olaresEnv.SES_CONFIGURATION_SET | quote }}
- name: SNS_TOPIC_ARN
value: {{ .Values.olaresEnv.SNS_TOPIC_ARN | quote }}
- name: SCW_PROJECT_ID
value: {{ .Values.olaresEnv.SCW_PROJECT_ID | quote }}
- name: SCW_REGION
value: {{ .Values.olaresEnv.SCW_REGION | quote }}
- name: TZ
value: {{ .Values.app.timezone | quote }}
- name: AWS_ACCESS_KEY_ID
@@ -64,6 +68,11 @@ spec:
secretKeyRef:
name: courier-secrets
key: SNS_WEBHOOK_TOKEN
- name: SCW_SECRET_KEY
valueFrom:
secretKeyRef:
name: courier-secrets
key: SCW_SECRET_KEY
resources:
requests:
cpu: 50m
+1
View File
@@ -10,3 +10,4 @@ stringData:
AWS_SECRET_ACCESS_KEY: {{ .Values.olaresEnv.AWS_SECRET_ACCESS_KEY | quote }}
API_KEY_PEPPER: {{ .Values.olaresEnv.API_KEY_PEPPER | quote }}
SNS_WEBHOOK_TOKEN: {{ .Values.olaresEnv.SNS_WEBHOOK_TOKEN | quote }}
SCW_SECRET_KEY: {{ .Values.olaresEnv.SCW_SECRET_KEY | quote }}
+3
View File
@@ -24,6 +24,9 @@ olaresEnv:
SNS_WEBHOOK_TOKEN: ""
SES_CONFIGURATION_SET: "courier-transactional"
SNS_TOPIC_ARN: "arn:aws:sns:eu-west-1:945831802901:courier-ses-events"
SCW_SECRET_KEY: ""
SCW_PROJECT_ID: ""
SCW_REGION: "fr-par"
MAIL_FROM_DOMAIN: "hubsport.club"
MAIL_TRANSPORT: "ses"
GLOBAL_DAILY_LIMIT: "1000"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "courier",
"version": "26.11.24",
"version": "26.11.26",
"private": true,
"scripts": {
"dev": "next dev -H 0.0.0.0 -p 3400",
+6 -3
View File
@@ -1,3 +1,4 @@
import { config } from "../lib/config";
import { query } from "../lib/db";
import { sendStored, type SendFailure } from "../lib/transport";
import type { StoredPayload } from "../lib/queue";
@@ -8,6 +9,7 @@ const POLL_MS = 1000;
type Claimed = {
id: string;
attempts: number;
provider: string | null;
payload: StoredPayload;
};
@@ -34,7 +36,7 @@ async function claim(): Promise<Claimed | null> {
limit 1
for update skip locked
)
returning id, attempts, payload`,
returning id, attempts, provider, payload`,
);
return rows[0] ?? null;
}
@@ -49,14 +51,15 @@ async function run() {
}
try {
const result = await sendStored(job.payload);
const provider = (job.provider || config.transport) as typeof config.transport;
const result = await sendStored(job.payload, provider);
await query(
`update messages
set status = 'sent', provider_message_id = $2, sent_at = now(), error = null
where id = $1`,
[job.id, result.providerMessageId],
);
console.log(`[courier-worker] ${job.id} gesendet (${result.providerMessageId})`);
console.log(`[courier-worker] ${job.id} über ${provider} gesendet (${result.providerMessageId})`);
} catch (error) {
const failure = error as SendFailure;
const retry = failure.retryable !== false && job.attempts < MAX_ATTEMPTS;