Skip to content

Commit

Permalink
feat(context): add context details
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbeau committed Feb 24, 2017
1 parent aa67c23 commit c110e81
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/contexts/context.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,23 @@ export default class ContextController {
reply(Boom.badImplementation(error));
});
}

public getContextDetailsById(request: Hapi.Request, reply: Hapi.IReply) {
const id = request.params['id'];

this.database.context.findAll({
include: [
this.database.layer,
this.database.tool
],
where: {
id: id
}
}).then((layersContexts: Array<any>) => {
reply(layersContexts);
}).catch((error) => {
reply(Boom.badImplementation(error));
});
}

}
30 changes: 30 additions & 0 deletions src/contexts/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,36 @@ export default function (server: Hapi.Server,
}
});

server.route({
method: 'GET',
path: '/contexts/{id}/details',
config: {
handler: contextController.getContextDetailsById,
// auth: 'jwt',
auth: false,
tags: ['api', 'tools', 'layers', 'contexts'],
description: 'Get details of context by context id.',
validate: {
params: {
id: Joi.string().required()
}
// headers: jwtValidator
},
plugins: {
'hapi-swagger': {
responses: {
'200': {
'description': 'Context founded.'
},
'404': {
'description': 'Context does not exists.'
}
}
}
}
}
});

server.route({
method: 'GET',
path: '/contexts',
Expand Down
2 changes: 0 additions & 2 deletions src/layersContexts/layerContext.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ export default class LayerContextController {
public getLayersByContextId(request: Hapi.Request, reply: Hapi.IReply) {
const id = request.params['id'];



this.database.context.findAll({
include: [ this.database.layer ],
where: {
Expand Down

0 comments on commit c110e81

Please sign in to comment.