diff --git a/server/controllers/index.js b/server/controllers/index.js index 403948e7..05e6d4db 100644 --- a/server/controllers/index.js +++ b/server/controllers/index.js @@ -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('

CA WIKI

'); -}); +Router.use(userRouter); -module.exports = router; +module.exports = Router; diff --git a/server/controllers/routes/user/cohort/getCohortsData.js b/server/controllers/routes/user/cohort/getCohortsData.js new file mode 100644 index 00000000..409e55e6 --- /dev/null +++ b/server/controllers/routes/user/cohort/getCohortsData.js @@ -0,0 +1,7 @@ +const { getCohorts } = require('../../../../database/queries'); + +exports.getCohortsData = async (req, res, next) => { + try { + const result = await getCohorts(result.rows); + } catch (err) {} +}; diff --git a/server/controllers/routes/user/cohort/index.js b/server/controllers/routes/user/cohort/index.js index e69de29b..61018ab5 100644 --- a/server/controllers/routes/user/cohort/index.js +++ b/server/controllers/routes/user/cohort/index.js @@ -0,0 +1,3 @@ +const { getCohortsData } = require('./getCohortsData'); + +module.exports = { getCohortsData }; diff --git a/server/controllers/routes/user/index.js b/server/controllers/routes/user/index.js index e69de29b..975cf763 100644 --- a/server/controllers/routes/user/index.js +++ b/server/controllers/routes/user/index.js @@ -0,0 +1,7 @@ +const userRouter = require('express').Router; + +const { getCohortsData } = require('./cohort'); + +userRouter.get('/cohorts', getCohortsData); + +module.exports = userRouter; diff --git a/server/database/queries/cohort/getCohorts.js b/server/database/queries/cohort/getCohorts.js new file mode 100644 index 00000000..9f7688f8 --- /dev/null +++ b/server/database/queries/cohort/getCohorts.js @@ -0,0 +1,3 @@ +const connection = require('../../config/connection'); + +exports.getCohorts = () => connection.query('SELECT * FROM cohort'); diff --git a/server/database/queries/cohort/index.js b/server/database/queries/cohort/index.js index e69de29b..b11c33ef 100644 --- a/server/database/queries/cohort/index.js +++ b/server/database/queries/cohort/index.js @@ -0,0 +1,3 @@ +const { getCohorts } = require('./getCohorts'); + +module.exports = { getCohorts }; diff --git a/server/database/queries/index.js b/server/database/queries/index.js index e69de29b..fbd07277 100644 --- a/server/database/queries/index.js +++ b/server/database/queries/index.js @@ -0,0 +1,3 @@ +const { getCohorts } = require('./cohort'); + +module.exporets = { getCohorts };