diff --git a/backend/apis/nodejs/api.js b/backend/apis/nodejs/api.js index fa8fb8e..88b71e2 100644 --- a/backend/apis/nodejs/api.js +++ b/backend/apis/nodejs/api.js @@ -22,6 +22,7 @@ app.post('/blinkapi/login', api_controller.login); // Login app.get('/blinkapi/person/:id', api_controller.verifyToken, api_controller.getPerson); // Obtain Person's details app.delete('/blinkapi/person/delete', api_controller.verifyToken, api_controller.deletePerson); // Delete a Person app.post('/blinkapi/organization', api_controller.verifyToken, api_controller.createOrganization); // Create organization +app.get('/blinkapi/organization/:id', api_controller.verifyToken, api_controller.getOrganization); // Get Organization data app.delete('/blinkapi/organization/:id', api_controller.verifyToken, api_controller.deleteOrganization); // Delete organization app.post('/blinkapi/organization/post', api_controller.verifyToken, api_controller.createOrganizationPost); // Create a organization's post app.delete('/blinkapi/organization/post/:id', api_controller.verifyToken, api_controller.deleteOrganizationPost); // Delete a organization's post diff --git a/backend/apis/nodejs/api_controller.js b/backend/apis/nodejs/api_controller.js index aa9c0eb..5021603 100644 --- a/backend/apis/nodejs/api_controller.js +++ b/backend/apis/nodejs/api_controller.js @@ -216,6 +216,27 @@ async function createOrganizationPost(req, res){ } } +// GET +async function getOrganization(req, res){ + const organizationId = req.params.id; + try { + const organization = await knex('Organization') + .where('id', organizationId) + .select('*') + .first(); + if(organization) { + return res.status(200).json(organization); + } + else{ + return res.status(404).json({error : "Not found"}); + } + } + catch (error) { + console.error("Error retrieving an organization: " + error); + return res.status(500).json({error : "Internal server error"}); + } +} + // DELETE async function deleteOrganizationPost(req, res){ const organizationPostIdToDelete = req.params.id; @@ -370,6 +391,7 @@ module.exports = { deletePerson, verifyToken, createOrganization, + getOrganization, deleteOrganization, createOrganizationPost, deleteOrganizationPost,