Merge branch 'feature/auth'

This commit is contained in:
2025-12-04 01:28:21 +07:00
3 changed files with 146 additions and 34 deletions
+16 -6
View File
@@ -1,9 +1,9 @@
import { Elysia } from 'elysia'
import { Elysia, t } from 'elysia'
import { createMerchantBody, createMerchantResponseSchema } from './schema'
import CreateMerchantService from './commands/service'
import { basicAuthMiddleware } from '~/middlewares/basicAuth'
import { DataAlreadyExistsError } from '~/helpers/errors'
import { apiKeyAuth } from '~/middlewares/apiKeyAuth'
import { apiKeyAuthMacro } from '~/middlewares/apiKeyAuth'
export const router = new Elysia({
name: 'modules.auth',
@@ -41,13 +41,23 @@ export const router = new Elysia({
security: [{ basicAuth: [] }],
},
})
.use(apiKeyAuth)
.get('/test-key', async ({ body }) => {
.use(apiKeyAuthMacro)
.post('/test-key', async ({ body }) => {
return body
}, {
verifyKey: true,
detail: {
security: [{ basicAuth: [] }],
body: t.Object({
foo: t.String(),
bar: t.Object({
lorem: t.Integer(),
ipsum: t.Boolean(),
}),
}),
response: {
200: t.Any(),
401: t.Object({
message: t.String(),
}),
},
})