bootstrap

This commit is contained in:
kislovdm
2026-07-08 16:43:29 +03:00
parent 10b5eafd53
commit d2819ff03c
74 changed files with 8174 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
import type { FastifyInstance } from 'fastify'
import { getAuthKey, signIn } from '../services/auth-service.js'
import { getTokenTTL, hasToken } from '../services/token-cache.js'
export async function authRoutes(app: FastifyInstance): Promise<void> {
app.get('/auth/key', async () => {
const authKey = await getAuthKey()
return { uuid: authKey.uuid, data: authKey.data }
})
app.post<{ Body: { uuid: string; data: string } }>('/auth/signin', async (request) => {
const { uuid, data } = request.body
const result = await signIn({ uuid, data })
return result
})
app.get('/auth/status', async () => {
const authenticated = hasToken()
const ttl = getTokenTTL()
return {
authenticated,
tokenExpiresAt: ttl ? new Date(ttl).toISOString() : null,
}
})
}