feat: Adding product-categories endpoint
This commit is contained in:
8
sections/product-categories/routes.js
Normal file
8
sections/product-categories/routes.js
Normal file
@@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
const router = require('express').Router();
|
||||
const services= require('./services.js');
|
||||
|
||||
router.get('/', services.getProductCategoriesList);
|
||||
router.get('/:id', services.getProductCategory );
|
||||
|
||||
module.exports = router;
|
||||
17
sections/product-categories/services.js
Normal file
17
sections/product-categories/services.js
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
const { ROOT_PATH, LIB_PATH, MODELS_PATH, HANDLERS_PATH } = process.env;
|
||||
const { getPagination , queryPage } = require( `${ROOT_PATH}/${LIB_PATH}/Misc.js` );
|
||||
const productCategoriesModel = require( `${ROOT_PATH}/${MODELS_PATH}/product-categories.model.js` );
|
||||
|
||||
const getProductCategoriesList = async(req, res) => {
|
||||
const { page , elements } = getPagination( req.query );
|
||||
const retVal = await queryPage( page , elements, productCategoriesModel );
|
||||
res.send( retVal );
|
||||
};
|
||||
|
||||
const getProductCategory = async(req, res) => {
|
||||
const retVal = await productCategoriesModel.findById( req.params.id );
|
||||
res.send( retVal );
|
||||
};
|
||||
|
||||
module.exports = { getProductCategoriesList , getProductCategory };
|
||||
Reference in New Issue
Block a user