Skip to content

Commit

Permalink
Merge pull request #10 from HackYourFuture-CPH/feat/developFetchEmplo…
Browse files Browse the repository at this point in the history
…yeesAPI

developed api for fetch employees data
  • Loading branch information
nishadipri committed Apr 4, 2024
2 parents 6c1a456 + 19a35fd commit 24d2485
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 5 deletions.
14 changes: 14 additions & 0 deletions packages/server/api/controllers/employeesController.js
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,
};
13 changes: 13 additions & 0 deletions packages/server/api/routes/employees.router.js
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;
3 changes: 3 additions & 0 deletions packages/server/api/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const router = express.Router();

const exampleResources = require('./exampleResources.router');
const teamsRouter = require('./teams.router');
const employeesRouter = require('./employees.router');

/* GET home page. */
// router.get('/', function(req, res, next) {
Expand Down Expand Up @@ -37,4 +38,6 @@ router.use('/exampleResources', exampleResources);

router.use('/teams', teamsRouter);

router.use('/employees', employeesRouter);

module.exports = router;
34 changes: 29 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7191,7 +7191,7 @@ eslint-config-airbnb-base@^15.0.0:
object.entries "^1.1.5"
semver "^6.3.0"

eslint-config-airbnb@19.0.4, eslint-config-airbnb@^19.0.4:
eslint-config-airbnb@^19.0.4:
version "19.0.4"
resolved "https://registry.yarnpkg.com/eslint-config-airbnb/-/eslint-config-airbnb-19.0.4.tgz#84d4c3490ad70a0ffa571138ebcdea6ab085fdc3"
integrity sha512-T75QYQVQX57jiNgpF9r1KegMICE94VYwoFQyMGhrvc+lB8YF2E/M/PYDaQe1AJcWaEgqLE+ErXV1Og/+6Vyzew==
Expand Down Expand Up @@ -7313,7 +7313,7 @@ eslint-plugin-react-hooks@^4.3.0, eslint-plugin-react-hooks@^4.4.0:
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3"
integrity sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==

eslint-plugin-react@^7.27.1, eslint-plugin-react@^7.28.0, eslint-plugin-react@^7.29.4:
eslint-plugin-react@^7.27.1, eslint-plugin-react@^7.29.4:
version "7.34.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.34.1.tgz#6806b70c97796f5bbfb235a5d3379ece5f4da997"
integrity sha512-N97CxlouPT1AHt8Jn0mhhN2RrADlUAsk1/atcT2KyA/l9Q/E6ll7OIGwNumFmWfZ9skV3XXccYS19h80rHtgkw==
Expand Down Expand Up @@ -7394,7 +7394,7 @@ eslint-webpack-plugin@^3.1.1:
normalize-path "^3.0.0"
schema-utils "^4.0.0"

eslint@^8.14.0, eslint@^8.2.0, eslint@^8.3.0:
eslint@^8.14.0, eslint@^8.3.0:
version "8.57.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.57.0.tgz#c786a6fd0e0b68941aaf624596fb987089195668"
integrity sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==
Expand Down Expand Up @@ -7595,7 +7595,7 @@ expect@^29.0.0:
jest-message-util "^29.7.0"
jest-util "^29.7.0"

express@^4.17.1, express@^4.17.3, express@^4.19.2:
express@^4.17.1, express@^4.17.3:
version "4.19.2"
resolved "https://registry.yarnpkg.com/express/-/express-4.19.2.tgz#e25437827a3aa7f2a827bc8171bbbb664a356465"
integrity sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==
Expand Down Expand Up @@ -8785,6 +8785,11 @@ human-signals@^5.0.0:
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-5.0.0.tgz#42665a284f9ae0dade3ba41ebc37eb4b852f3a28"
integrity sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==

husky@^7.0.4:
version "7.0.4"
resolved "https://registry.yarnpkg.com/husky/-/husky-7.0.4.tgz#242048245dc49c8fb1bf0cc7cfb98dd722531535"
integrity sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==

iconv-lite@0.4.24:
version "0.4.24"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"
Expand Down Expand Up @@ -14243,7 +14248,26 @@ stylelint-config-prettier@^9.0.3:
resolved "https://registry.yarnpkg.com/stylelint-config-prettier/-/stylelint-config-prettier-9.0.5.tgz#9f78bbf31c7307ca2df2dd60f42c7014ee9da56e"
integrity sha512-U44lELgLZhbAD/xy/vncZ2Pq8sh2TnpiPvo38Ifg9+zeioR+LAkHu0i6YORIOxFafZoVg0xqQwex6e6F25S5XA==

stylelint@14:
stylelint-config-recommended@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/stylelint-config-recommended/-/stylelint-config-recommended-7.0.0.tgz#7497372ae83ab7a6fffc18d7d7b424c6480ae15e"
integrity sha512-yGn84Bf/q41J4luis1AZ95gj0EQwRX8lWmGmBwkwBNSkpGSpl66XcPTulxGa/Z91aPoNGuIGBmFkcM1MejMo9Q==

stylelint-config-standard@^25.0.0:
version "25.0.0"
resolved "https://registry.yarnpkg.com/stylelint-config-standard/-/stylelint-config-standard-25.0.0.tgz#2c916984e6655d40d6e8748b19baa8603b680bff"
integrity sha512-21HnP3VSpaT1wFjFvv9VjvOGDtAviv47uTp3uFmzcN+3Lt+RYRv6oAplLaV51Kf792JSxJ6svCJh/G18E9VnCA==
dependencies:
stylelint-config-recommended "^7.0.0"

stylelint-prettier@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/stylelint-prettier/-/stylelint-prettier-2.0.0.tgz#ead781aea522379f2ffa2d136bafdfc451d699a5"
integrity sha512-jvT3G+9lopkeB0ARmDPszyfaOnvnIF+30QCjZxyt7E6fynI1T9mOKgYDNb9bXX17M7PXMZaX3j/26wqakjp1tw==
dependencies:
prettier-linter-helpers "^1.0.0"

stylelint@14, stylelint@^14.8.2:
version "14.16.1"
resolved "https://registry.yarnpkg.com/stylelint/-/stylelint-14.16.1.tgz#b911063530619a1bbe44c2b875fd8181ebdc742d"
integrity sha512-ErlzR/T3hhbV+a925/gbfc3f3Fep9/bnspMiJPorfGEmcBbXdS+oo6LrVtoUZ/w9fqD6o6k7PtUlCOsCRdjX/A==
Expand Down

0 comments on commit 24d2485

Please sign in to comment.