organize general routes
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
const db = require('../../config/db.config.js'),
|
||||
errorMaker = require('../../helpers/error.maker');
|
||||
|
||||
const { Grant, Cause, Region, Organization } = db;
|
||||
|
||||
// FETCH all causes
|
||||
exports.findAll = (req, res, next) => {
|
||||
Cause.findAll()
|
||||
.then(causes => {
|
||||
res.status(200).json({
|
||||
causes,
|
||||
number_items: causes.length
|
||||
});
|
||||
})
|
||||
.catch(error => next(error));
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
cause: require('./cause.controller'),
|
||||
region: require('./cause.controller'),
|
||||
organization: require('./organization.controller')
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
const db = require('../../config/db.config.js'),
|
||||
errorMaker = require('../../helpers/error.maker');
|
||||
|
||||
const { Grant, Cause, Region, Organization } = db;
|
||||
|
||||
// FETCH all organizations
|
||||
exports.findAll = (req, res, next) => {
|
||||
Organization.findAll()
|
||||
.then(organizations => {
|
||||
res.status(200).json({
|
||||
organizations,
|
||||
number_items: organizations.length
|
||||
});
|
||||
})
|
||||
.catch(error => next(error));
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
const db = require('../../config/db.config.js'),
|
||||
errorMaker = require('../../helpers/error.maker');
|
||||
|
||||
const { Grant, Cause, Region, Organization } = db;
|
||||
|
||||
// FETCH all regions
|
||||
exports.findAll = (req, res, next) => {
|
||||
Region.findAll()
|
||||
.then(regions => {
|
||||
res.status(200).json({
|
||||
regions,
|
||||
number_items: regions.length
|
||||
});
|
||||
})
|
||||
.catch(error => next(error));
|
||||
};
|
||||
Reference in New Issue
Block a user