0
0
Fork 0
This commit is contained in:
Oliver Akins 2022-07-22 00:22:49 -06:00
parent 6a5f642fb4
commit 48dffc112a
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99
21 changed files with 1327 additions and 0 deletions

View file

@ -0,0 +1,33 @@
import { ServerRoute } from "@hapi/hapi";
import boom from "@hapi/boom";
import { db } from "@/main";
import Joi from "joi";
const data: ServerRoute = {
method: `DELETE`, path: `/manage/{channel}/message/{id}`,
options: {
validate: {
params: Joi.object({
channel: Joi.string().alphanum(),
id: Joi.string().uuid(),
}),
},
},
async handler(request, h) {
const { channel, id } = request.params;
if (!db[channel]) {
throw boom.notFound(`Invalid channel`);
};
if (!db[channel].messages[id]) {
throw boom.notFound(`Invalid ID`);
};
let message = db[channel].messages[id];
delete db[channel].messages[id];
return h.response(message).code(200);
},
};
export default data;