-
Notifications
You must be signed in to change notification settings - Fork 8
Create travel api #639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create travel api #639
Changes from all commits
4c6b19d
00fe61b
3ac0b29
2848f42
e9b5f22
0c3d7eb
99450d7
4e48321
6b13751
c203958
15ee2b3
04a5cef
2b3d2ac
77c1918
627cd0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| "use strict"; | ||
| const Constants = { | ||
| Success: require("../constants/success.constant"), | ||
| Error: require("../constants/error.constant") | ||
| }; | ||
|
|
||
| function okay(req, res) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: okay sounds a bit odd as a function name
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whoops, this function was just for debugging - I'll remove it |
||
| return res.status(200).json({ | ||
| message: "good" | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * @function showTravel | ||
| * @param {{body: {travel: Object}}} req | ||
| * @param {*} res | ||
| * @return {JSON} Success status and travel object | ||
| * @description Returns the JSON of travel object located in req.body.travel | ||
| */ | ||
| function showTravel(req, res) { | ||
| return res.status(200).json({ | ||
| message: Constants.Success.TRAVEL_READ, | ||
| data: req.body.travel.toJSON() | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * @function createTravel | ||
| * @param {{body: {travel: {_id: ObjectId, accountId: ObjectId, hackerId: objectId, status: string, request: number, offer: number}}}} req | ||
| * @param {*} res | ||
| * @return {JSON} Success status | ||
| * @description | ||
| * Create a travel's record based off information stored in req.body.travel | ||
| * Returns a 200 status for the created travel. | ||
| */ | ||
| function createdTravel(req, res) { | ||
| return res.status(200).json({ | ||
| message: Constants.Success.TRAVEL_CREATE, | ||
| data: req.body.travel.toJSON() | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * @function updatedTravel | ||
| * @param {{params: {id: ObjectId}, body: {Object}}} req | ||
| * @param {*} res | ||
| * @return {JSON} Success or error status | ||
| * @description | ||
| * Change a travel's information based on the trave;'s mongoID specified in req.params.id. | ||
| * The id is moved to req.body.id from req.params.id by validation. | ||
| * Returns a 200 status for an updated travel. | ||
| * The new information is located in req.body. | ||
| */ | ||
| function updatedTravel(req, res) { | ||
| return res.status(200).json({ | ||
| message: Constants.Success.TRAVEL_UPDATE, | ||
| data: req.body | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be json like the other portions or no? |
||
| }); | ||
| } | ||
|
|
||
| module.exports = { | ||
| okay: okay, | ||
| showTravel: showTravel, | ||
| updatedTravel: updatedTravel, | ||
| createdTravel: createdTravel | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this post? Did you mean create travel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's for create - thought I was following the naming convention from account and hacker, would it be better to rename this from
posttocreateTravel?