mailship/src/index.ts

26 lines
673 B
TypeScript
Raw Normal View History

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)
}
})