Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This is a **TypeScript monorepo** for applications on the Tempo blockchain appli
| `apps/tokenlist` | Token registry API |
| `apps/contract-verification` | Smart contract verification |
| `apps/og` | OpenGraph image generation |
| `apps/email` | Transactional email sending via Cloudflare Email Service |

## Commands

Expand Down
3 changes: 3 additions & 0 deletions apps/email/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# No environment variables required for basic email sending.
# The SEND_EMAIL binding is configured in wrangler.json.
# To restrict senders/recipients, update the send_email binding in wrangler.json.
25 changes: 25 additions & 0 deletions apps/email/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "email",
"type": "module",
"private": true,
"scripts": {
"dev": "wrangler dev",
"build": "echo 'No build step needed for Cloudflare Worker'",
"deploy": "wrangler deploy",
"check": "pnpm check:biome && pnpm check:types",
"check:biome": "biome check --write --unsafe",
"check:types": "tsgo --project tsconfig.json --noEmit",
"gen:types": "wrangler types --env-interface='CloudflareBindings' --env-file='.env.example'",
"postinstall": "pnpm gen:types"
},
"dependencies": {
"@hono/zod-validator": "catalog:",
"hono": "catalog:",
"zod": "catalog:"
},
"devDependencies": {
"@cloudflare/workers-types": "catalog:",
"@types/node": "catalog:",
"wrangler": "catalog:"
}
}
36 changes: 36 additions & 0 deletions apps/email/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { zValidator } from '@hono/zod-validator'
import { Hono } from 'hono'
import { cors } from 'hono/cors'
import * as z from 'zod'

const emailAddress = z.object({
email: z.string().email(),
name: z.string(),
})

const sendSchema = z.object({
from: z.union([z.string().email(), emailAddress]),
to: z.union([z.string().email(), z.array(z.string().email()).min(1)]),
subject: z.string().min(1),
replyTo: z.union([z.string().email(), emailAddress]).optional(),
cc: z.union([z.string().email(), z.array(z.string().email())]).optional(),
bcc: z.union([z.string().email(), z.array(z.string().email())]).optional(),
text: z.string().optional(),
html: z.string().optional(),
})

const app = new Hono<{ Bindings: CloudflareBindings }>()

app.use('*', cors())

app.get('/health', (c) => c.text('ok'))

app.post('/send', zValidator('json', sendSchema), async (c) => {
const body = c.req.valid('json')

await c.env.SEND_EMAIL.send(body)

return c.json({ success: true })
})

export default app
29 changes: 29 additions & 0 deletions apps/email/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"target": "ES2024",
"module": "ESNext",
"lib": ["ES2024"],
"types": ["@cloudflare/workers-types", "node"],
"moduleResolution": "bundler",
"noEmit": true,
"strict": true,
"skipLibCheck": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"checkJs": false,
"allowImportingTsExtensions": true,
"resolvePackageJsonImports": true,
"resolvePackageJsonExports": true,
"useUnknownInCatchVariables": true,
"noUncheckedIndexedAccess": true,
"paths": {
"#*": ["./src/*"]
}
},
"files": ["worker-configuration.d.ts"],
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "dist"]
}
23 changes: 23 additions & 0 deletions apps/email/wrangler.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "./node_modules/wrangler/config-schema.json",
"name": "email",
"main": "src/index.ts",
"compatibility_date": "2025-12-17",
"compatibility_flags": ["nodejs_compat"],
"workers_dev": true,
"preview_urls": true,
"send_email": [
{
"name": "SEND_EMAIL"
}
],
"observability": {
"enabled": true,
"logs": {
"enabled": true,
"persist": true,
"head_sampling_rate": 1,
"invocation_logs": true
}
}
}
22 changes: 22 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading