apps gain kiosk_path/kiosk_caps (hvac registered first). One shared kiosk password mints a long-lived hnf_kiosk_session carrying only each registered app's kiosk caps; /verify answers for kiosk sessions; changing the password bumps an epoch that invalidates signed-in tablets. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
import Fastify from 'fastify'
|
|
import cookie from '@fastify/cookie'
|
|
import cors from '@fastify/cors'
|
|
import { initDb } from './db.js'
|
|
import { authRoutes } from './routes/auth.js'
|
|
import { adminRoutes } from './routes/admin.js'
|
|
import { internalRoutes } from './routes/internal.js'
|
|
import { registerRoutes } from './routes/register.js'
|
|
import { kioskRoutes } from './routes/kiosk.js'
|
|
import { startSyncJob } from './sync.js'
|
|
|
|
const app = Fastify({ logger: true, trustProxy: true })
|
|
|
|
await app.register(cookie)
|
|
await app.register(cors, {
|
|
origin: process.env.CORS_ORIGIN ? process.env.CORS_ORIGIN.split(',') : false,
|
|
credentials: true,
|
|
})
|
|
|
|
app.get('/health', async () => ({ status: 'healthy' }))
|
|
|
|
await app.register(authRoutes, { prefix: '/api/auth' })
|
|
await app.register(registerRoutes, { prefix: '/api/auth' })
|
|
await app.register(kioskRoutes, { prefix: '/api/auth/kiosk' })
|
|
await app.register(adminRoutes, { prefix: '/api/auth/admin' })
|
|
await app.register(internalRoutes, { prefix: '/api/auth/internal' })
|
|
|
|
try {
|
|
await initDb()
|
|
await app.listen({ port: 3001, host: '0.0.0.0' })
|
|
startSyncJob()
|
|
} catch (err) {
|
|
app.log.error(err)
|
|
process.exit(1)
|
|
}
|