🐛 fix entity types and projection

This commit is contained in:
Flam3rboy
2021-09-01 23:34:55 +02:00
parent 1a76c663d2
commit cba341a6d6
11 changed files with 67 additions and 89 deletions
+2 -23
View File
@@ -1,5 +1,5 @@
import { Router, Request, Response } from "express";
import { User } from "@fosscord/util";
import { User, PrivateUserProjection } from "@fosscord/util";
import { UserModifySchema } from "../../../schema/User";
import { check } from "../../../util/instanceOf";
import { handleFile } from "../../../util/cdn";
@@ -7,30 +7,9 @@ import { handleFile } from "../../../util/cdn";
const router: Router = Router();
router.get("/", async (req: Request, res: Response) => {
res.json(await User.getPublicUser(req.user_id));
res.json(await User.getPublicUser(req.user_id, { select: PrivateUserProjection }));
});
const UserUpdateProjection = [
"accent_color",
"avatar",
"banner",
"bio",
"bot",
"discriminator",
"email",
"flags",
"id",
"locale",
"mfa_enabled",
"nsfw_alllowed",
"phone",
"public_flags",
"purchased_flags",
// "token", // this isn't saved in the db and needs to be set manually
"username",
"verified"
];
router.patch("/", check(UserModifySchema), async (req: Request, res: Response) => {
const body = req.body as UserModifySchema;