feat(Countries): Adding countries endpoint
This commit is contained in:
17
sections/countries/services.js
Normal file
17
sections/countries/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 countriesModel = require( `${ROOT_PATH}/${MODELS_PATH}/countries.model.js` );
|
||||
|
||||
const getCountriesList = async(req, res) => {
|
||||
const { page , elements } = getPagination( req.query );
|
||||
const retVal = await queryPage( page , elements, countriesModel );
|
||||
res.send( retVal );
|
||||
};
|
||||
|
||||
const getCountry = async(req, res) => {
|
||||
const retVal = await countriesModel.findById( req.params.id );
|
||||
res.send( retVal );
|
||||
};
|
||||
|
||||
module.exports = { getCountriesList , getCountry };
|
||||
Reference in New Issue
Block a user