[guild] finished POST
This commit is contained in:
parent
b1a20e05ae
commit
c083310a93
@ -1,5 +1,5 @@
|
|||||||
import { Router, Request, Response } from "express";
|
import { Router, Request, Response } from "express";
|
||||||
import { db, GuildSchema, Guild } from "fosscord-server-util";
|
import { db, GuildSchema, Guild, Snowflake } from "fosscord-server-util";
|
||||||
import { HTTPError } from "lambert-server";
|
import { HTTPError } from "lambert-server";
|
||||||
import { check } from "./../../../../util/instanceOf";
|
import { check } from "./../../../../util/instanceOf";
|
||||||
|
|
||||||
@ -63,68 +63,69 @@ router.get("/:id", async (req: Request, res: Response) => {
|
|||||||
return res.json(guild);
|
return res.json(guild);
|
||||||
});
|
});
|
||||||
|
|
||||||
// router.put("/:id", check(GuildSchema), async (req: Request, res: Response) => {}); // TODO: add addGuildSchema & createGuildSchema
|
// TODO: add addGuildSchema & createGuildSchema
|
||||||
|
// router.put("/:id", check(GuildSchema), async (req: Request, res: Response) => {});
|
||||||
|
|
||||||
// TODO: finish POST route
|
// // TODO: finish POST route
|
||||||
// router.post("/", check(GuildSchema), async (req: Request, res: Response) => {
|
router.post("/", check(GuildSchema), async (req: Request, res: Response) => {
|
||||||
// const body = req.body as GuildSchema;
|
const body = req.body as GuildSchema;
|
||||||
// const guildID = BigInt();
|
const guildID = Snowflake.generate();
|
||||||
// const guild: Guild = {
|
const guild: Guild = {
|
||||||
// ...body, // ! contains name & icon values
|
...body, // ! contains name & icon values
|
||||||
// afk_channel_id: undefined,
|
afk_channel_id: undefined,
|
||||||
// afk_timeout: undefined,
|
afk_timeout: undefined,
|
||||||
// application_id: undefined,
|
application_id: undefined,
|
||||||
// approximate_member_count: undefined,
|
approximate_member_count: undefined,
|
||||||
// approximate_presence_count: undefined,
|
approximate_presence_count: undefined,
|
||||||
// banner: undefined,
|
banner: undefined,
|
||||||
// channels: [],
|
channels: [],
|
||||||
// default_message_notifications: undefined,
|
default_message_notifications: undefined,
|
||||||
// description: undefined,
|
description: undefined,
|
||||||
// discovery_splash: undefined,
|
discovery_splash: undefined,
|
||||||
// emojis: [],
|
emojis: [],
|
||||||
// explicit_content_filter: undefined,
|
explicit_content_filter: undefined,
|
||||||
// features: [],
|
features: [],
|
||||||
// // icon: undefined,
|
// icon: undefined,
|
||||||
// id: guildID,
|
id: guildID,
|
||||||
// // joined_at: undefined,
|
// joined_at: undefined,
|
||||||
// large: undefined,
|
large: undefined,
|
||||||
// max_members: undefined,
|
max_members: undefined,
|
||||||
// max_presences: undefined,
|
max_presences: undefined,
|
||||||
// max_video_channel_users: undefined,
|
max_video_channel_users: undefined,
|
||||||
// member_count: undefined,
|
member_count: undefined,
|
||||||
// members: undefined,
|
members: undefined,
|
||||||
// mfa_level: undefined,
|
mfa_level: undefined,
|
||||||
// // name: undefined,
|
// name: undefined,
|
||||||
// owner_id: req.userid, // ! important
|
owner_id: req.userid, // ! important
|
||||||
// // owner: undefined,
|
// owner: undefined,
|
||||||
// permissions: undefined,
|
permissions: undefined,
|
||||||
// preferred_locale: undefined,
|
preferred_locale: undefined,
|
||||||
// premium_subscription_count: undefined,
|
premium_subscription_count: undefined,
|
||||||
// premium_tier: undefined,
|
premium_tier: undefined,
|
||||||
// presences: [],
|
presences: [],
|
||||||
// public_updates_channel_id: undefined,
|
public_updates_channel_id: undefined,
|
||||||
// region: undefined,
|
region: undefined,
|
||||||
// roles: [],
|
roles: [],
|
||||||
// rules_channel_id: undefined,
|
rules_channel_id: undefined,
|
||||||
// splash: undefined,
|
splash: undefined,
|
||||||
// system_channel_flags: undefined,
|
system_channel_flags: undefined,
|
||||||
// system_channel_id: undefined,
|
system_channel_id: undefined,
|
||||||
// unavailable: undefined,
|
unavailable: undefined,
|
||||||
// vanity_url_code: undefined,
|
vanity_url_code: undefined,
|
||||||
// verification_level: undefined,
|
verification_level: undefined,
|
||||||
// voice_states: [],
|
voice_states: [],
|
||||||
// welcome_screen: [],
|
welcome_screen: [],
|
||||||
// widget_channel_id: undefined,
|
widget_channel_id: undefined,
|
||||||
// widget_enabled: undefined,
|
widget_enabled: undefined,
|
||||||
// };
|
};
|
||||||
|
|
||||||
// try {
|
try {
|
||||||
// await db.data.guilds.push(guild);
|
await db.data.guilds.push(guild);
|
||||||
// } catch (error) {
|
} catch (error) {
|
||||||
// throw new HTTPError("Couldnt create Guild", 500);
|
throw new HTTPError("Couldnt create Guild", 500);
|
||||||
// }
|
}
|
||||||
// res.status(201).json({ id: guild.id });
|
res.status(201).json({ id: guild.id });
|
||||||
// });
|
});
|
||||||
|
|
||||||
router.delete("/:id", async (req: Request, res: Response) => {
|
router.delete("/:id", async (req: Request, res: Response) => {
|
||||||
const { id: guildID } = req.params;
|
const { id: guildID } = req.params;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user