1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-13 14:12:41 +01:00

Update index.ts

This commit is contained in:
Intevel ツ 2021-04-24 00:21:57 +02:00
parent e1d06e35ef
commit b213e2931a

View File

@ -1,15 +1,18 @@
import { Router, Request, Response } from "express"; import { Router, Request, Response } from "express";
import { UserModel } from "@fosscord/server-util"; import { UserModel} from "@fosscord/server-util";
import { getPublicUser } from "../../../util/User";
import { HTTPError } from "lambert-server"; import { HTTPError } from "lambert-server";
const router: Router = Router(); const router: Router = Router();
router.get("/", async (req: Request, res: Response) => { router.get("/", async (req: Request, res: Response) => {
const { id } = req.params; const { id } = req.params;
const user = await UserModel.findOne({ id: id }).exec(); const user = await getPublicUser(id);
if (!user) throw new HTTPError("User not found", 404); if (!user) throw new HTTPError("User not found", 404);
res.json(user); res.json(user);
}); });
export default router; export default router;