0
0
Fork 0

Create the update channel endpoint

This commit is contained in:
Oliver Akins 2022-07-26 18:45:31 -06:00
parent fc8c62f3ea
commit 7614b9560f
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99

View file

@ -0,0 +1,31 @@
import { ServerRoute } from "@hapi/hapi";
import boom from "@hapi/boom";
import { db } from "@/main";
import Joi from "joi";
const data: ServerRoute = {
method: `PATCH`, path: `/manage/{channel}`,
options: {
validate: {
params: Joi.object({
channel: Joi.string().alphanum(),
}),
payload: Joi.object({
default_unlurk: Joi.string().min(1),
}),
},
},
async handler(request, h) {
const { channel } = request.params;
const { default_unlurk } = request.payload as any;
if (!db[channel]) {
throw boom.notFound(`Invalid channel`);
};
db[channel].unlurk_default = default_unlurk;
return h.response().code(200);
},
};
export default data;