feat: integration with API Vega Cloud

This commit is contained in:
2025-10-14 11:16:23 +07:00
parent 8b24695a75
commit 1d341c3a7c
23 changed files with 468 additions and 431 deletions
-38
View File
@@ -1,38 +0,0 @@
import { Elysia } from 'elysia'
import { basicAuthMiddleware, bearerAuthMiddleware } from '~/middlewares'
import { getInfoSchema, loginBody, loginResponseSchema } from './schema'
import CommandService from './commands/service'
export const router = new Elysia({
name: 'modules.auth',
detail: { tags: ['Authentication'] },
prefix: '/auth/v1',
})
.post('/login', async ({ headers, set, body }) => {
// basic auth middleware
basicAuthMiddleware(headers, set)
const user = await CommandService.login(body)
return {
message: 'Logged in.',
data: user,
}
}, {
body: loginBody,
response: loginResponseSchema,
detail: {
security: [{ basicAuth: [] }],
},
})
.get('/info', async ({ headers, set }) => {
// bearer auth middleware
const user = await bearerAuthMiddleware(headers, set)
return {
message: 'Get user info.',
data: user,
}
}, {
response: getInfoSchema,
})
export default router