Add v1.0
This commit is contained in:
parent
6a5f642fb4
commit
48dffc112a
21 changed files with 1327 additions and 0 deletions
27
src/endpoints/management/list_messages.ts
Normal file
27
src/endpoints/management/list_messages.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { ServerRoute } from "@hapi/hapi";
|
||||
import boom from "@hapi/boom";
|
||||
import { db } from "@/main";
|
||||
|
||||
const data: ServerRoute = {
|
||||
method: `GET`, path: `/manage/{channel}`,
|
||||
async handler(request, h) {
|
||||
const { channel } = request.params;
|
||||
|
||||
if (!db[channel]) {
|
||||
throw boom.notFound(`Invalid channel`);
|
||||
};
|
||||
|
||||
let messages = [];
|
||||
for (const messageId in db[channel].messages) {
|
||||
let message = db[channel].messages[messageId];
|
||||
messages.push({
|
||||
id: messageId,
|
||||
lurk: message.lurk,
|
||||
unlurk: message.unlurk,
|
||||
});
|
||||
};
|
||||
|
||||
return h.response(messages).code(200);
|
||||
},
|
||||
};
|
||||
export default data;
|
||||
Loading…
Add table
Add a link
Reference in a new issue