From 001f07780c7dca212fb19edaab30f6068eb2c97b Mon Sep 17 00:00:00 2001 From: kartofen Date: Mon, 24 Oct 2022 19:08:52 +0300 Subject: done lol --- src/routes/board.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/routes/board.ts') 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; -- cgit v1.2.3