feat: integration with API Vega Cloud
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user