feat: Clan creation & persistence #146

Merged
Sainan merged 5 commits from clans into main 2024-05-04 06:42:25 -07:00
2 changed files with 7 additions and 8 deletions
Showing only changes of commit 6c5020ac1b - Show all commits

View File

@ -2,19 +2,14 @@ import { RequestHandler } from "express";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
import { Guild } from "@/src/models/guildModel";
import { IGuild, guildDbToResponse } from "@/src/types/guildTypes";
import { IGuild, guildDbToResponse, ICreateGuildRequest } from "@/src/types/guildTypes";
const createGuildController: RequestHandler = async (req, res) => {
let payload = getJSONfromString(req.body.toString());
if (!payload.guildName) {
res.status(400);
return;
}
let payload: ICreateGuildRequest = getJSONfromString(req.body.toString());
// Create guild on database
let guild = new Guild({
Name: payload.guildName as string
Name: payload.guildName
} satisfies IGuild);
await guild.save();

View File

@ -18,3 +18,7 @@ export function guildDbToResponse(guild: IDatabaseGuild): IGuildResponse {
(guild as IGuild as IGuildResponse)._id = toOid(guild._id);
return guild as IGuild as IGuildResponse;
}
export interface ICreateGuildRequest {
guildName: string;
}