init studio auth backend

This commit is contained in:
2026-07-01 17:36:34 +09:00
commit 87f6f46d3c
35 changed files with 2492 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
import { serve } from '@hono/node-server'
import { Hono } from 'hono'
import { cors } from 'hono/cors'
import { logger } from 'hono/logger'
import { config } from './config'
import { prisma } from './prisma'
import { closeRedis, redis } from './redis'
import { authRoutes } from './auth/routes'
const app = new Hono()
app.use('*', logger())
app.use(
'*',
cors({
origin: (origin) => {
if (!origin) return null
return config.corsOrigins.includes(origin) ? origin : null
},
allowHeaders: ['authorization', 'content-type'],
allowMethods: ['GET', 'POST', 'PUT', 'OPTIONS'],
credentials: true
})
)
app.get('/health', async (c) => {
const redisOk = (await redis.send('PING', [])) === 'PONG'
return c.json({ ok: true, service: 'atnmy-stdo-auth', redis: redisOk ? 'ok' : 'error' }, redisOk ? 200 : 503)
})
app.route('/auth', authRoutes)
process.on('SIGINT', async () => {
await closeRedis()
await prisma.$disconnect()
process.exit(0)
})
serve({ fetch: app.fetch, port: config.port }, (info) => {
console.log(`Auth server listening on http://localhost:${info.port}`)
})