Skip to content

Commit

Permalink
取得するAPIを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
taisan11 committed May 28, 2024
1 parent b620379 commit e97f119
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { vValidator } from "@hono/valibot-validator";
import { newPost, newThread } from './types';
import { kakiko } from './module/kakiko';
import { kakikoAPI } from './module/kakiko-api';
import { subjectpaser } from './module/pase';
import { getSubject, getThread } from './module/storage';

const app = new Hono({});

Expand All @@ -11,7 +13,7 @@ app.get('/', (c) => {
})

app.post(
"/thread",
"/thread/:BBSKEY",
vValidator("json", newThread, (result, c) => {
if (!result.success) {
return c.json({ message: "errorだよん" }, 400);
Expand All @@ -24,7 +26,7 @@ app.post(
}
);
app.post(
"/thread/:ThID",
"/thread/:BBSKEY/:ThID",
vValidator("json", newPost, (result, c) => {
if (!result.success) {
return c.json({ message: "errorだよん" }, 400);
Expand All @@ -36,4 +38,25 @@ app.post(
return c.json(result);
}
);
app.get("/thread/:BBSKEY",async(c)=>{
const BBSKEY = c.req.param().BBSKEY
const SUBJECTJSON = await getSubject(BBSKEY)
if (!SUBJECTJSON?.has) {
return c.json({"error":"指定された板がありません"})
}
if (!SUBJECTJSON.data) {
return c.json({"error":"板にスレッドがありません"})
}
return c.json(SUBJECTJSON.data)
})
app.get("/thread/:BBSKEY/:ThID",async(c)=>{
const BBSKEY = c.req.param().BBSKEY
const ThID = c.req.param().ThID
const THD = await getThread(BBSKEY,ThID)
if (!THD?.has) {
return c.json({"error":"スレッドがねえ"})
}
return c.json(THD.date)
})

export default app;

0 comments on commit e97f119

Please sign in to comment.