built cuisine route
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { Express, Router } from 'express';
|
||||
import { CuisineCtl } from '../controllers';
|
||||
const CuisineInstance = new CuisineCtl();
|
||||
|
||||
const router = Router();
|
||||
|
||||
export const cuisineRouter = (app: Express) => {
|
||||
app.use('/cuisine', router);
|
||||
|
||||
router.get('/', async (req, res, next) => {
|
||||
try {
|
||||
const result = await CuisineInstance.getAll();
|
||||
res.status(200).send(result);
|
||||
} catch(e) {
|
||||
next(e);
|
||||
}
|
||||
})
|
||||
|
||||
router.get('/:id', async (req, res, next) => {
|
||||
const { id } = req.params;
|
||||
|
||||
try {
|
||||
const result = await CuisineInstance.getOne(id);
|
||||
res.status(200).send(result);
|
||||
} catch(e) {
|
||||
next(e);
|
||||
}
|
||||
})
|
||||
|
||||
router.post('/', async (req, res, next) => {
|
||||
const data = req.body;
|
||||
|
||||
try {
|
||||
const result = await CuisineInstance.post(data);
|
||||
res.status(201).send(result);
|
||||
} catch(e) {
|
||||
next(e);
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { groceryListRoute } from "./groceryList";
|
||||
import { authRoute } from "./auth";
|
||||
import { subscriptionRoute } from "./subscription";
|
||||
import { friendRouter } from "./friend";
|
||||
import { cuisineRouter } from "./cuisine";
|
||||
|
||||
export const routes = async (app: Express, passport: PassportStatic) => {
|
||||
console.log('routes called');
|
||||
@@ -15,6 +16,7 @@ export const routes = async (app: Express, passport: PassportStatic) => {
|
||||
authRoute(app, passport);
|
||||
userRoute(app);
|
||||
friendRouter(app);
|
||||
cuisineRouter(app);
|
||||
recipeRoute(app);
|
||||
collectionRoute(app);
|
||||
subscriptionRoute(app);
|
||||
|
||||
Reference in New Issue
Block a user