init project

This commit is contained in:
@kirill.komarov
2026-04-28 11:02:08 +05:00
commit 55480d4aa5
50 changed files with 9241 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
import 'dotenv/config'
import Fastify from 'fastify'
import cors from '@fastify/cors'
import { registerAuth } from './plugins/auth.js'
import { registerApiRoutes } from './routes/api.js'
const port = Number(process.env.PORT) || 3333
const origin = (process.env.CORS_ORIGIN ?? '')
.split(',')
.map((s) => s.trim())
.filter(Boolean)
const fastify = Fastify({ logger: true })
await fastify.register(cors, {
origin: origin.length ? origin : true,
credentials: true,
})
registerAuth(fastify)
await registerApiRoutes(fastify)
fastify.get('/health', async () => ({ ok: true }))
try {
await fastify.listen({ port, host: '0.0.0.0' })
} catch (err) {
fastify.log.error(err)
process.exit(1)
}