const router = require('express').Router() import { Era } from '../db/models' import donate from '../donate' router.get('/', async (req: any, res: any, next: any) => { try { //Era.findAllWithIncludes().then((a: any) => res.json(a)) Era.findAll().then((a: any) => res.json(a)) } catch (err) { next(err) } }) router.get('/:id', async (req: any, res: any, next: any) => { try { Era.findByIdWithIncludes(req.params.id).then((a: any) => res.json(a)) } catch (err) { next(err) } }) router.post('/', async (req: any, res: any, next: any) => { res.status(402).send(donate) try { Era.create(req.body).then((account: any) => Era.findByIdWithIncludes(account.id).then((a: any) => res.json(a)) ) } catch (err) { next(err) } }) router.put('/:id', async (req: any, res: any, next: any) => { res.status(402).send(donate) try { Era.findByPk(req.params.id).then((account: any) => account .update(req.body) .then(() => Era.findByIdWithIncludes(req.params.id).then((a: any) => res.json(a)) ) ) } catch (err) { next(err) } }) router.post('/:id/delete', async (req: any, res: any, next: any) => { res.status(402).send(donate) try { //Era.findByPk(req.params.id).then((account:any)=>res.json(account.delete()) } catch (err) { next(err) } }) module.exports = router