mailship/src/index.ts
Agent 21e7058862 Initial mailship fork from anchor
Fork anchor, strip all push notification code (APNs, FCM, WebPush),
rename from anchor to mailship, add new database schema for
subscriptions + events tables, and add HTTP API for email
notification registration and NIP-9a relay push callbacks.

- POST /subscription/email — register for email digests
- DELETE /subscription/:key — unsubscribe
- POST /notify/:id — NIP-9a relay push callback
- GET /confirm?token=... — confirm email
- GET /unsubscribe?token=... — unsubscribe

Co-authored-by: mplorentz
2026-08-18 12:21:22 -04:00

26 lines
No EOL
673 B
TypeScript

import 'localstorage-polyfill'
import { PORT } from './env.js'
import { server } from './server.js'
import { migrate, getActiveSubscriptions } from './database.js'
import { registerSubscription } from './worker/index.js'
process.on('unhandledRejection', (error: Error) => {
console.error('Unhandled rejection:', error.stack)
process.exit(1)
})
process.on('uncaughtException', (error: Error) => {
console.error('Uncaught exception:', error.stack)
process.exit(1)
})
migrate().then(async () => {
server.listen(PORT, () => {
console.log('Running on port', PORT)
})
for (const sub of await getActiveSubscriptions()) {
registerSubscription(sub)
}
})