wow
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
4c3d96778d
commit
3253e91d95
4 changed files with 89 additions and 27 deletions
|
|
@ -217,7 +217,17 @@ export default new Elysia({ prefix: "/post" })
|
|||
})
|
||||
})
|
||||
|
||||
.get("/list", async ({ query }) => {
|
||||
.get("/list", async ({ query, jwt, cookie: { mizuki }, status }) => {
|
||||
const rawToken = mizuki.value;
|
||||
if (typeof rawToken !== "string" || rawToken.length === 0) {
|
||||
return status(401, "Unauthorized");
|
||||
}
|
||||
|
||||
const payload = await jwt.verify(rawToken);
|
||||
if (!payload || typeof payload !== "object" || !("id" in payload) || typeof payload.id !== "string") {
|
||||
return status(401, "Unauthorized");
|
||||
}
|
||||
|
||||
const page = query.page;
|
||||
const pageSize = query.size || 10;
|
||||
const filterTags = normalizeQueryTags(query.tags);
|
||||
|
|
@ -260,22 +270,7 @@ export default new Elysia({ prefix: "/post" })
|
|||
}),
|
||||
})
|
||||
|
||||
.get("/detail/:id", async ({ params, status, jwt, cookie: { mizuki } }) => {
|
||||
const rawToken = mizuki.value;
|
||||
if (typeof rawToken !== "string" || rawToken.length === 0) {
|
||||
return status(401, "Unauthorized");
|
||||
}
|
||||
|
||||
const payload = await jwt.verify(rawToken);
|
||||
if (!payload || typeof payload !== "object" || !("id" in payload) || typeof payload.id !== "string") {
|
||||
return status(401, "Unauthorized");
|
||||
}
|
||||
|
||||
const user = await User.findOne({ userId: payload.id });
|
||||
if (!user) {
|
||||
return status(401, "Unauthorized");
|
||||
}
|
||||
|
||||
.get("/detail/:id", async ({ params, status }) => {
|
||||
const post = await MediaUpload.findById(params.id);
|
||||
if (!post) {
|
||||
return status(404, "포스트를 찾을 수 없습니다.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue