generated from HackYourFuture-CPH/boilerplate-for-fp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from HackYourFuture-CPH/feat/developFetchEmplo…
…yeesAPI developed api for fetch employees data
- Loading branch information
Showing
4 changed files
with
59 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const knex = require('../../config/db'); | ||
|
||
const employees = async (req, res) => { | ||
try { | ||
const existingMembers = await knex('Employees').select('*'); | ||
res.status(200).json({ existingMembers }); | ||
} catch (error) { | ||
res.status(500).json({ message: 'Internal server error' }); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
employees, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const express = require('express'); | ||
|
||
const router = express.Router({ mergeParams: true }); | ||
const employeesController = require('../controllers/employeesController'); | ||
|
||
router.get('/', (req, res, next) => { | ||
employeesController | ||
.fetchExistingMembers(req, res) | ||
.then((result) => res.json(result)) | ||
.catch(next); | ||
}); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters