Skip to content

Commit

Permalink
make get /cohort route
Browse files Browse the repository at this point in the history
relates #14
  • Loading branch information
AlaaSaadeddin committed Mar 30, 2020
1 parent e9dd11b commit 9a72cc8
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 5 deletions.
9 changes: 4 additions & 5 deletions server/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const router = require('express').Router();
const Router = require('express').Router();
const userRouter = require('./routes/user');

router.get('/', (req, res) => {
res.send('<h1>CA WIKI</h1>');
});
Router.use(userRouter);

module.exports = router;
module.exports = Router;
7 changes: 7 additions & 0 deletions server/controllers/routes/user/cohort/getCohortsData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { getCohorts } = require('../../../../database/queries');

exports.getCohortsData = async (req, res, next) => {
try {
const result = await getCohorts(result.rows);
} catch (err) {}
};
3 changes: 3 additions & 0 deletions server/controllers/routes/user/cohort/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { getCohortsData } = require('./getCohortsData');

module.exports = { getCohortsData };
7 changes: 7 additions & 0 deletions server/controllers/routes/user/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const userRouter = require('express').Router;

const { getCohortsData } = require('./cohort');

userRouter.get('/cohorts', getCohortsData);

module.exports = userRouter;
3 changes: 3 additions & 0 deletions server/database/queries/cohort/getCohorts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const connection = require('../../config/connection');

exports.getCohorts = () => connection.query('SELECT * FROM cohort');
3 changes: 3 additions & 0 deletions server/database/queries/cohort/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { getCohorts } = require('./getCohorts');

module.exports = { getCohorts };
3 changes: 3 additions & 0 deletions server/database/queries/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { getCohorts } = require('./cohort');

module.exporets = { getCohorts };

0 comments on commit 9a72cc8

Please sign in to comment.