mirror of
https://github.com/bitbonsai/mcpvault.git
synced 2026-09-19 07:37:47 +08:00
feat(website-shibumi): add dev server with mocked Resend client
Lets the newsletter subscribe/unsubscribe flow run in a browser without credentials; calls log to the console. Production entry stays server.ts.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Local dev server with a mocked Resend client, so the newsletter
|
||||
* subscribe/unsubscribe flow can be exercised in a browser without real
|
||||
* credentials. Every Resend call is logged to the console instead of
|
||||
* hitting the API. Never used in production; the container runs server.ts.
|
||||
*
|
||||
* bun scripts/dev-mock.ts # http://localhost:8788
|
||||
* PORT=9000 bun scripts/dev-mock.ts
|
||||
*/
|
||||
import { createApp } from "../src/app";
|
||||
|
||||
const mockEnv = { RESEND_API_KEY: "mock", RESEND_AUDIENCE_ID: "mock" };
|
||||
|
||||
const app = createApp({
|
||||
subscribe: {
|
||||
env: mockEnv,
|
||||
resendClient: {
|
||||
contacts: {
|
||||
async create(payload) {
|
||||
console.log(`[mock resend] contacts.create ${payload.email}`);
|
||||
return { error: null };
|
||||
},
|
||||
},
|
||||
emails: {
|
||||
async send(payload, options) {
|
||||
console.log(
|
||||
`[mock resend] emails.send to=${payload.to.join(",")} subject="${payload.subject}" idempotencyKey=${options?.idempotencyKey}`,
|
||||
);
|
||||
return { error: null };
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
unsubscribe: {
|
||||
env: mockEnv,
|
||||
resendClient: {
|
||||
contacts: {
|
||||
async remove(payload) {
|
||||
console.log(`[mock resend] contacts.remove ${payload.email}`);
|
||||
return { error: null };
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const port = Number(process.env.PORT ?? 8788);
|
||||
Bun.serve({ port, fetch: app.fetch });
|
||||
console.log(`website-shibumi (mock Resend) listening on http://localhost:${port}`);
|
||||
Reference in New Issue
Block a user