Get Organization

This commit is contained in:
xfarrow 2023-10-18 09:33:47 +02:00
parent 414b99a462
commit b0e793c5fc
2 changed files with 23 additions and 0 deletions

View File

@ -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.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.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.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.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.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 app.delete('/blinkapi/organization/post/:id', api_controller.verifyToken, api_controller.deleteOrganizationPost); // Delete a organization's post

View File

@ -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 // DELETE
async function deleteOrganizationPost(req, res){ async function deleteOrganizationPost(req, res){
const organizationPostIdToDelete = req.params.id; const organizationPostIdToDelete = req.params.id;
@ -370,6 +391,7 @@ module.exports = {
deletePerson, deletePerson,
verifyToken, verifyToken,
createOrganization, createOrganization,
getOrganization,
deleteOrganization, deleteOrganization,
createOrganizationPost, createOrganizationPost,
deleteOrganizationPost, deleteOrganizationPost,