Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 1x 1x 1x | import { BadRequestError, NotFoundError } from '@dss-dev-mathis/dss-core-common'
import express, { Request, Response } from 'express'
import { isValidObjectId } from 'mongoose'
import Sheet from '../models/sheet'
const router = express.Router()
router.get('/api/sheets', async (req: Request, res: Response) => {
const sheets = await Sheet.find({})
res.send({ sheets })
})
router.get('/api/sheets/:id', async (req: Request, res: Response) => {
if (!isValidObjectId(req.params.id)) throw new BadRequestError('Invalid Sheet ID')
const ticket = await Sheet.findById(req.params.id)
if (!ticket) throw new NotFoundError()
res.json({ ticket })
})
export default router
|