Skip to content

Commit af9535a

Browse files
authored
Merge pull request #176 from hackmcgill/feature/hacker-self
create /hacker/self method for logged in hacker to view their own info
2 parents 757032c + 1eb3e79 commit af9535a

10 files changed

Lines changed: 255 additions & 123 deletions

File tree

constants/role.constant.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const hackerRole = {
3636
Constants.Routes.hackerRoutes.getSelfById,
3737
Constants.Routes.hackerRoutes.getSelfResumeById,
3838
Constants.Routes.hackerRoutes.patchSelfById,
39-
Constants.Routes.hackerRoutes.patchSelfConfirmationById
39+
Constants.Routes.hackerRoutes.patchSelfConfirmationById,
40+
Constants.Routes.hackerRoutes.getSelf,
4041
]
4142
};
4243

constants/routes.constant.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ const accountRoutes = {
5656
};
5757

5858
const hackerRoutes = {
59+
"getSelf": {
60+
requestType: Constants.REQUEST_TYPES.GET,
61+
uri: "/api/hacker/self/"
62+
},
5963
"getSelfById": {
6064
requestType: Constants.REQUEST_TYPES.GET,
6165
uri: "/api/hacker/" + Constants.ROLE_CATEGORIES.SELF,

controllers/hacker.controller.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,28 @@ async function findById(req, res) {
3232
}
3333
}
3434

35+
/**
36+
* @function showHacker
37+
* @param {{body: {hacker: Object}}} req
38+
* @param {*} res
39+
* @return {JSON} Success status and hacker object
40+
* @description Returns the JSON of hacker object located in req.body.hacker
41+
*/
42+
function showHacker(req, res) {
43+
return res.status(200).json({
44+
message: "Hacker retrieval successful",
45+
data: req.body.hacker.toJSON()
46+
});
47+
}
48+
3549
/**
3650
* @function createdHacker
3751
* @param {{body: {hacker: {_id: ObjectId, accountId: ObjectId, school: string, gender: string, needsBus: boolean, application: {Object}}}}} req
3852
* @param {*} res
3953
* @return {JSON} Success status
4054
* @description returns success message
4155
*/
42-
async function createdHacker(req, res) {
56+
function createdHacker(req, res) {
4357
return res.status(200).json({
4458
message: "Hacker creation successful",
4559
data: req.body.hacker.toJSON()
@@ -88,5 +102,6 @@ module.exports = {
88102
findById: Util.asyncMiddleware(findById),
89103
createdHacker: createdHacker,
90104
uploadedResume: uploadedResume,
91-
downloadedResume: downloadedResume
105+
downloadedResume: downloadedResume,
106+
showHacker: showHacker,
92107
};

docs/api/api_data.js

Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -257,63 +257,6 @@ define({
257257
"url": "https://api.mchacks.ca/api/account/invite"
258258
}]
259259
},
260-
{
261-
"type": "post",
262-
"url": "/account/invite",
263-
"title": "invites a user to create an account with the specified accountType",
264-
"name": "inviteAccount",
265-
"group": "Account",
266-
"version": "0.0.8",
267-
"description": "<p>sends link with token to be used with the account/create route</p>",
268-
"parameter": {
269-
"fields": {
270-
"body": [{
271-
"group": "body",
272-
"type": "String",
273-
"optional": true,
274-
"field": "email",
275-
"description": "<p>email of the account to be created and where to send the link</p>"
276-
},
277-
{
278-
"group": "body",
279-
"type": "String",
280-
"optional": true,
281-
"field": "accountType",
282-
"description": "<p>the type of the account which the user can create, for sponsor this should specify tier as well</p>"
283-
}
284-
]
285-
}
286-
},
287-
"success": {
288-
"fields": {
289-
"Success 200": [{
290-
"group": "Success 200",
291-
"type": "string",
292-
"optional": false,
293-
"field": "message",
294-
"description": "<p>Success message</p>"
295-
},
296-
{
297-
"group": "Success 200",
298-
"type": "object",
299-
"optional": false,
300-
"field": "data",
301-
"description": "<p>Account object</p>"
302-
}
303-
]
304-
},
305-
"examples": [{
306-
"title": "Success-Response: ",
307-
"content": "{\n \"message\": \"Successfully invited user \", \n \"data\": {}\n }",
308-
"type": "object"
309-
}]
310-
},
311-
"filename": "routes/api/account.js",
312-
"groupTitle": "Account",
313-
"sampleRequest": [{
314-
"url": "https://mchacks.ca/api/account/invite"
315-
}]
316-
},
317260
{
318261
"type": "get",
319262
"url": "/account/self",
@@ -1056,7 +999,7 @@ define({
1056999
"filename": "routes/api/hacker.js",
10571000
"groupTitle": "Hacker",
10581001
"sampleRequest": [{
1059-
"url": "https://mchacks.ca/api/hacker/checkin/:id"
1002+
"url": "https://api.mchacks.ca/api/hacker/checkin/:id"
10601003
}]
10611004
},
10621005
{
@@ -1473,7 +1416,7 @@ define({
14731416
"filename": "routes/api/hacker.js",
14741417
"groupTitle": "Hacker",
14751418
"sampleRequest": [{
1476-
"url": "https://mchacks.ca/api/hacker/confirmation/:id Allows confirmation of hacker attendence if they are accepted."
1419+
"url": "https://api.mchacks.ca/api/hacker/confirmation/:id Allows confirmation of hacker attendence if they are accepted."
14771420
}]
14781421
},
14791422
{
@@ -1586,6 +1529,67 @@ define({
15861529
"url": "https://api.mchacks.ca/api/hacker/resume/:id"
15871530
}]
15881531
},
1532+
{
1533+
"type": "get",
1534+
"url": "/hacker/self",
1535+
"title": "get information about own hacker",
1536+
"name": "self",
1537+
"group": "Hacker",
1538+
"version": "0.0.8",
1539+
"success": {
1540+
"fields": {
1541+
"Success 200": [{
1542+
"group": "Success 200",
1543+
"type": "string",
1544+
"optional": false,
1545+
"field": "message",
1546+
"description": "<p>Success message</p>"
1547+
},
1548+
{
1549+
"group": "Success 200",
1550+
"type": "object",
1551+
"optional": false,
1552+
"field": "data",
1553+
"description": "<p>Hacker object</p>"
1554+
}
1555+
]
1556+
},
1557+
"examples": [{
1558+
"title": "Success-Response: ",
1559+
"content": "{\n \"message\": \"Hacker found by logged in account id\", \n \"data\": {HackerObject}\n }",
1560+
"type": "object"
1561+
}]
1562+
},
1563+
"error": {
1564+
"fields": {
1565+
"Error 4xx": [{
1566+
"group": "Error 4xx",
1567+
"type": "string",
1568+
"optional": false,
1569+
"field": "message",
1570+
"description": "<p>Error message</p>"
1571+
},
1572+
{
1573+
"group": "Error 4xx",
1574+
"type": "object",
1575+
"optional": false,
1576+
"field": "data",
1577+
"description": "<p>empty</p>"
1578+
}
1579+
]
1580+
},
1581+
"examples": [{
1582+
"title": "Error-Response: ",
1583+
"content": "{\"message\": \"Hacker not found\", \"data\": {}}",
1584+
"type": "object"
1585+
}]
1586+
},
1587+
"filename": "routes/api/hacker.js",
1588+
"groupTitle": "Hacker",
1589+
"sampleRequest": [{
1590+
"url": "https://api.mchacks.ca/api/hacker/self"
1591+
}]
1592+
},
15891593
{
15901594
"type": "get",
15911595
"url": "/",

docs/api/api_data.json

Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -256,63 +256,6 @@
256256
"url": "https://api.mchacks.ca/api/account/invite"
257257
}]
258258
},
259-
{
260-
"type": "post",
261-
"url": "/account/invite",
262-
"title": "invites a user to create an account with the specified accountType",
263-
"name": "inviteAccount",
264-
"group": "Account",
265-
"version": "0.0.8",
266-
"description": "<p>sends link with token to be used with the account/create route</p>",
267-
"parameter": {
268-
"fields": {
269-
"body": [{
270-
"group": "body",
271-
"type": "String",
272-
"optional": true,
273-
"field": "email",
274-
"description": "<p>email of the account to be created and where to send the link</p>"
275-
},
276-
{
277-
"group": "body",
278-
"type": "String",
279-
"optional": true,
280-
"field": "accountType",
281-
"description": "<p>the type of the account which the user can create, for sponsor this should specify tier as well</p>"
282-
}
283-
]
284-
}
285-
},
286-
"success": {
287-
"fields": {
288-
"Success 200": [{
289-
"group": "Success 200",
290-
"type": "string",
291-
"optional": false,
292-
"field": "message",
293-
"description": "<p>Success message</p>"
294-
},
295-
{
296-
"group": "Success 200",
297-
"type": "object",
298-
"optional": false,
299-
"field": "data",
300-
"description": "<p>Account object</p>"
301-
}
302-
]
303-
},
304-
"examples": [{
305-
"title": "Success-Response: ",
306-
"content": "{\n \"message\": \"Successfully invited user \", \n \"data\": {}\n }",
307-
"type": "object"
308-
}]
309-
},
310-
"filename": "routes/api/account.js",
311-
"groupTitle": "Account",
312-
"sampleRequest": [{
313-
"url": "https://mchacks.ca/api/account/invite"
314-
}]
315-
},
316259
{
317260
"type": "get",
318261
"url": "/account/self",
@@ -1055,7 +998,7 @@
1055998
"filename": "routes/api/hacker.js",
1056999
"groupTitle": "Hacker",
10571000
"sampleRequest": [{
1058-
"url": "https://mchacks.ca/api/hacker/checkin/:id"
1001+
"url": "https://api.mchacks.ca/api/hacker/checkin/:id"
10591002
}]
10601003
},
10611004
{
@@ -1472,7 +1415,7 @@
14721415
"filename": "routes/api/hacker.js",
14731416
"groupTitle": "Hacker",
14741417
"sampleRequest": [{
1475-
"url": "https://mchacks.ca/api/hacker/confirmation/:id Allows confirmation of hacker attendence if they are accepted."
1418+
"url": "https://api.mchacks.ca/api/hacker/confirmation/:id Allows confirmation of hacker attendence if they are accepted."
14761419
}]
14771420
},
14781421
{
@@ -1585,6 +1528,67 @@
15851528
"url": "https://api.mchacks.ca/api/hacker/resume/:id"
15861529
}]
15871530
},
1531+
{
1532+
"type": "get",
1533+
"url": "/hacker/self",
1534+
"title": "get information about own hacker",
1535+
"name": "self",
1536+
"group": "Hacker",
1537+
"version": "0.0.8",
1538+
"success": {
1539+
"fields": {
1540+
"Success 200": [{
1541+
"group": "Success 200",
1542+
"type": "string",
1543+
"optional": false,
1544+
"field": "message",
1545+
"description": "<p>Success message</p>"
1546+
},
1547+
{
1548+
"group": "Success 200",
1549+
"type": "object",
1550+
"optional": false,
1551+
"field": "data",
1552+
"description": "<p>Hacker object</p>"
1553+
}
1554+
]
1555+
},
1556+
"examples": [{
1557+
"title": "Success-Response: ",
1558+
"content": "{\n \"message\": \"Hacker found by logged in account id\", \n \"data\": {HackerObject}\n }",
1559+
"type": "object"
1560+
}]
1561+
},
1562+
"error": {
1563+
"fields": {
1564+
"Error 4xx": [{
1565+
"group": "Error 4xx",
1566+
"type": "string",
1567+
"optional": false,
1568+
"field": "message",
1569+
"description": "<p>Error message</p>"
1570+
},
1571+
{
1572+
"group": "Error 4xx",
1573+
"type": "object",
1574+
"optional": false,
1575+
"field": "data",
1576+
"description": "<p>empty</p>"
1577+
}
1578+
]
1579+
},
1580+
"examples": [{
1581+
"title": "Error-Response: ",
1582+
"content": "{\"message\": \"Hacker not found\", \"data\": {}}",
1583+
"type": "object"
1584+
}]
1585+
},
1586+
"filename": "routes/api/hacker.js",
1587+
"groupTitle": "Hacker",
1588+
"sampleRequest": [{
1589+
"url": "https://api.mchacks.ca/api/hacker/self"
1590+
}]
1591+
},
15881592
{
15891593
"type": "get",
15901594
"url": "/",

docs/api/api_project.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ define({
99
"apidoc": "0.3.0",
1010
"generator": {
1111
"name": "apidoc",
12-
"time": "2018-11-30T07:04:37.968Z",
12+
"time": "2018-12-01T22:43:17.010Z",
1313
"url": "http://apidocjs.com",
1414
"version": "0.17.6"
1515
}

docs/api/api_project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"apidoc": "0.3.0",
1010
"generator": {
1111
"name": "apidoc",
12-
"time": "2018-11-30T20:01:44.909Z",
12+
"time": "2018-12-01T22:43:17.010Z",
1313
"url": "http://apidocjs.com",
1414
"version": "0.17.6"
1515
}

0 commit comments

Comments
 (0)