-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptions.ts
22 lines (20 loc) · 899 Bytes
/
options.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { default as express } from 'express';
import type * as schema from '../db/schema';
import {
getOptionUsersHandler,
getOptionCommentsHandler,
getOptionHandler,
saveOptionHandler,
updateOptionHandler,
} from '../handlers/options';
import { isLoggedIn } from '../middleware/is-logged-in';
import { NodePgDatabase } from 'drizzle-orm/node-postgres';
const router = express.Router();
export function optionsRouter({ dbPool }: { dbPool: NodePgDatabase<typeof schema> }) {
router.post('/', isLoggedIn(dbPool), saveOptionHandler(dbPool));
router.put('/:optionId', isLoggedIn(dbPool)), updateOptionHandler(dbPool);
router.get('/:optionId', isLoggedIn(dbPool), getOptionHandler(dbPool));
router.get('/:optionId/comments', isLoggedIn(dbPool), getOptionCommentsHandler(dbPool));
router.get('/:optionId/users', isLoggedIn(dbPool), getOptionUsersHandler(dbPool));
return router;
}