feat: new module create topic

This commit is contained in:
2026-02-05 13:58:02 +07:00
parent f56f87aa18
commit a6eaba5944
11 changed files with 376 additions and 24 deletions
+65
View File
@@ -0,0 +1,65 @@
import { Elysia } from 'elysia'
import CommandService from './commands/service'
import { listTopicResponseSchema, listTopics, postDeleteTopic, postDeleteTopicResponseSchema } from './schema'
import QueryService from './queries/service'
import { basicAuthMacro } from '../../middlewares/basicAuth'
export const router = new Elysia({
name: 'modules.topics',
detail: { tags: ['Topics'] },
prefix: '/topics/v1',
})
.use(basicAuthMacro)
.get('/state-reply', async ({ query, set }) => {
const result = await QueryService.getStateReply(query)
if (result.status != 200) {
set.status = result.status
return result
}
return result
}, {
query: listTopics,
response: listTopicResponseSchema,
verifyBasicAuth: true,
})
.get('/commands', async ({ query, set }) => {
const result = await QueryService.getCommands(query)
if (result.status != 200) {
set.status = result.status
return result
}
return result
}, {
query: listTopics,
response: listTopicResponseSchema,
verifyBasicAuth: true,
})
.post('/', async ({ body, set }) => {
const result = await CommandService.postTopic(body)
if (result.status != 200) {
set.status = result.status
return result
}
return result
}, {
body: postDeleteTopic,
response: postDeleteTopicResponseSchema,
verifyBasicAuth: true,
})
.patch('/', () => {
return 'Topics'
})
.delete('/', async ({ body, set }) => {
const result = await CommandService.delTopic(body)
if (result.status != 200) {
set.status = result.status
return result
}
return result
}, {
body: postDeleteTopic,
response: postDeleteTopicResponseSchema,
verifyBasicAuth: true,
})
export default router