Files
chestno-api/backend/src/index.ts
T
Your Name 3a217f0dd0 Revert "12"
This reverts commit 2d4eee2950.
2026-08-06 04:52:21 +00:00

35 lines
963 B
TypeScript

import Fastify from 'fastify'
import cors from '@fastify/cors'
import multipart from '@fastify/multipart'
import { config } from './config.js'
import { authRoutes } from './routes/auth.js'
import { cisesRoutes } from './routes/cises.js'
import { updRoutes } from './routes/upd.js'
import { plansRoutes } from './routes/plans.js'
const app = Fastify({ logger: true })
await app.register(cors, { origin: config.corsOrigin })
await app.register(multipart, {
limits: {
fileSize: 10 * 1024 * 1024,
files: 1,
},
throwFileSizeLimit: true,
})
await app.register(authRoutes)
await app.register(cisesRoutes)
await app.register(updRoutes)
await app.register(plansRoutes)
app.get('/health', async () => ({ status: 'ok', timestamp: new Date().toISOString() }))
try {
await app.listen({ port: config.port, host: config.host })
console.log(`Server running on http://${config.host}:${config.port}`)
} catch (err) {
app.log.error(err)
process.exit(1)
}