mirror of https://github.com/xfarrow/blink
Get Organization
This commit is contained in:
parent
414b99a462
commit
b0e793c5fc
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue