Add endpoints and game utilities
This commit is contained in:
parent
56f2195962
commit
6a174e4d36
7 changed files with 213 additions and 1 deletions
20
src/endpoints/setup_channel.ts
Normal file
20
src/endpoints/setup_channel.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { database } from "$/main";
|
||||
import { ServerRoute } from "@hapi/hapi";
|
||||
import Joi from "joi";
|
||||
|
||||
const route: ServerRoute = {
|
||||
method: `POST`, path: `/channels`,
|
||||
options: {
|
||||
validate: {
|
||||
payload: Joi.object({
|
||||
channel: Joi.string().alphanum(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
async handler(request, h) {
|
||||
// @ts-ignore
|
||||
await database.createChannel(request.payload.channel);
|
||||
return h.close;
|
||||
},
|
||||
};
|
||||
export default route;
|
||||
Loading…
Add table
Add a link
Reference in a new issue