actionhero
Version:
The reusable, scalable, and quick node.js API server for stateless and stateful applications
21 lines (16 loc) • 517 B
text/typescript
import { chatRoom, Action, ParamsFrom } from "./../index";
export class CreateChatRoom extends Action {
name = "createChatRoom";
description = "I will create a chatroom with the given name";
inputs = {
name: { required: true as true },
};
async run({ params }: { params: ParamsFrom<CreateChatRoom> }) {
let didCreate = false;
if (!(await chatRoom.exists(params.name))) {
await chatRoom.add(params.name);
didCreate = true;
}
return { name: params.name, didCreate };
}
}