Merge branch 'feature/auth'
This commit is contained in:
@@ -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(),
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user