Skip to content

Create room endpoint

Alvin Cheng edited this page Apr 23, 2023 · 3 revisions

Description

The create room endpoint is also pretty self-explanatory, this endpoint will create a new document of a room in the MongoDB database following the structure and scheme of /src/schema/roomSchema.ts. This endpoint will return a status of '201' on success, '401' on an invalid API key or '500' on an internal server error. Furthermore, there are 4 arguments to be supplied to the endpoint. The 'id' argument is the id of the room, usually created with the uuid package. The 'name' argument is the display name of the room, a 'user' argument is the starting user in the room, a 'public' argument for if the room is public, and a 'passcode' argument is the passcode of the room(you can pass null for public rooms). I hope all of these arguments are very self-explanatory.

Example

post("http://<URL>/api/create-room?key=<YOUR_API_KEY>", {
    id: "<ID>", // I suggest creating a id using v4() function from the uuid library.
    name: "<ROOM_NAME>",
    user: "<USER>",
    passcode:"<PASSCODE>"
    public: false
}).then((res) => {
    console.log(res);
}).catch((err) => {
    console.error(err);
});
Clone this wiki locally