diff options
author | kartofen <mladenovnasko0@gmail.com> | 2022-10-24 19:08:52 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2022-10-24 19:08:52 +0300 |
commit | 001f07780c7dca212fb19edaab30f6068eb2c97b (patch) | |
tree | 647d3bc2da48ceeefeaae5294784ce8e3cec0cc0 /src/routes | |
parent | 747097af03e422c72c2fe0065637e59a1685d219 (diff) |
done lol
Diffstat (limited to 'src/routes')
-rw-r--r-- | src/routes/board.ts | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/routes/board.ts b/src/routes/board.ts index caa2d53..1a60b97 100644 --- a/src/routes/board.ts +++ b/src/routes/board.ts @@ -1,6 +1,6 @@ import express from 'express'; import type { Thread, Comment } from '../models/Thread'; -import { CreateBoard, CustomQuery, GetBoards } from '../database/postgres' +import { CustomQuery, GetBoards, CreateBoard, GetBoard, CreateThread, GetThread, CreateComment } from '../database/postgres' const router = express.Router(); @@ -23,22 +23,27 @@ router.post('/boards/:board', (req, res) => { }); router.get('/board/:board', (req, res) => { - res.status(404).send(req.params.board); + GetBoard(req.params.board, (r) => { + res.status(r.status).send(r.data); + }); }); router.post('/board/:board', (req, res) => { - let t: Thread = req.body; - console.log(t); - res.status(403).send({board: req.params.board, thread: t}); + CreateThread(req.params.board, req.body, (r) => { + res.status(r.status).send(r.data); + }); }); router.get('/board/:board/:tid', (req, res) => { - res.status(404).send([req.params.board, req.params.tid]); + GetThread(req.params.board, req.params.tid, (r) => { + res.status(r.status).send(r.data); + }); }); router.post('/board/:board/:tid', (req, res) => { - let c: Comment = req.body; - res.status(404).send({params: [req.params.board, req.params.tid], body: c}); + CreateComment(req.params.board, req.params.tid, req.body, (r) => { + res.status(r.status).send(r.data); + }); }); export default router; |