From 747097af03e422c72c2fe0065637e59a1685d219 Mon Sep 17 00:00:00 2001 From: kartofen Date: Sun, 23 Oct 2022 21:34:48 +0300 Subject: nearly completed, forgot to make a repo --- src/routes/board.ts | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/routes/board.ts (limited to 'src/routes/board.ts') diff --git a/src/routes/board.ts b/src/routes/board.ts new file mode 100644 index 0000000..caa2d53 --- /dev/null +++ b/src/routes/board.ts @@ -0,0 +1,44 @@ +import express from 'express'; +import type { Thread, Comment } from '../models/Thread'; +import { CreateBoard, CustomQuery, GetBoards } from '../database/postgres' + +const router = express.Router(); + +router.post('/custom', (req, res) => { + CustomQuery(req.body, (r) => { + res.status(r.status).send(r.data); + }); +}); + +router.get('/boards', (req, res) => { + GetBoards((r) => { + res.status(r.status).send(r.data); + }); +}); + +router.post('/boards/:board', (req, res) => { + CreateBoard(req.params.board, (r) => { + res.status(r.status).send(r.data); + }); +}); + +router.get('/board/:board', (req, res) => { + res.status(404).send(req.params.board); +}); + +router.post('/board/:board', (req, res) => { + let t: Thread = req.body; + console.log(t); + res.status(403).send({board: req.params.board, thread: t}); +}); + +router.get('/board/:board/:tid', (req, res) => { + res.status(404).send([req.params.board, req.params.tid]); +}); + +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}); +}); + +export default router; -- cgit v1.2.3