1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
import express from 'express';
import type { Thread, Comment } from '../models/Thread';
import { CustomQuery, GetBoards, CreateBoard, GetBoard, CreateThread, GetThread, CreateComment } 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) => {
GetBoard(req.params.board, (r) => {
res.status(r.status).send(r.data);
});
});
router.post('/board/:board', (req, res) => {
CreateThread(req.params.board, req.body, (r) => {
res.status(r.status).send(r.data);
});
});
router.get('/board/:board/:tid', (req, res) => {
GetThread(req.params.board, req.params.tid, (r) => {
res.status(r.status).send(r.data);
});
});
router.post('/board/:board/:tid', (req, res) => {
CreateComment(req.params.board, req.params.tid, req.body, (r) => {
res.status(r.status).send(r.data);
});
});
export default router;
|