Social networking rideshare solution for your daily commute.
Models | Routes | Testing | About Us
User | Profile | Reviews | Way | Message |
This is the entry point for the Ways2Go interface. In order to interact with most of the features, each individual will be asked to provide a unique username
, password
and email
address. This information will be stored securely and used to verify individuals each time they visit the site. Ways2Go leverages the bcrypt module to safely encrypt and match user passwords.
{
username: "cool_commuter",
password: "<super salty bcrypt password string>",
email: "ray_tomlinson@arpa.net",
timeStamp: <Date supplied by default when document is created>,
_id: { Object supplied by MongoDB when document is created }
}
This will be the customizable home base for each individual user. The Profile ._id
provided by Mongodb will serve as the tether that loosely binds the individual to their Ways, Messages and Reviews.
{
profileID: {Object},
displayName: "Rollin with my Homies",
fullName: "Joe Driver",
address: "2909 3rd Ave, Seattle, WA 98103",
bio: "Who says that the ride to work can't be fun?!",
avgRating: Number,
timeStamp: Date,
reviews: [{Object}]
}
- Notes
profileID
automatically created withuser._id
when Profile is createdavgRating
is generated from aggregate of review ratingstimeStamp
is automatically generated when Profile is createdreviews
is an array of review._id objects for reviews of Profile owner
This feature will give users the ability to leave feedback for each other. When they are considering a ride with a particular person (or people) they can simply go to particular user's profile and see all Reviews that were left for that user. The fields each Review will contain are: _id
- provided by Mongodb, rating
, comment
, timestamp
- set automatically, user id
, way id
, and reviewed user id
.
{
rating: { type: Number, required: true },
comment: { type: String, required: false },
timestamp: { type: Date, required: true, default: Date.now },
profileID: { type: Schema.Types.ObjectId, required: true },
wayID: { type: Schema.Types.ObjectId, required: true},
reviewedprofileID: { type: Schema.Types.ObjectId, required: true }
}
This feature is only available to authorized members of the Ways2Go community. Unregistered members see routes, but can only contact them about sharing rides once they've been accepted into the community. By requiring membership we are able to better foster a community of trust for our users.This information is linked back to users through the profile model, via the toProfileID and fromProfileID properties.
{
toProfileID:{ type: Schema.Types.ObjectId, required: true },
fromProfileID: { type: Schema.Types.ObjectId, required: true },
timestamp: { type: Date, default: Date.now },
text : { type: String, required: true }
}
- Notes
toProfileID
automatically created withuser._id
when Profile is createdfromProfileID
is generated from aggregate of review ratingstimeStamp
is automatically generated when Message is createdtext
the body of the message being sent by the user
User | top
This is the endpoint to hit to sign up a new user.
There are three required components to the request that every user must provide in order to create an account:
- username
- password
The request should be made in JSON format:
{ "username": "helloworld", "password": "notpassword", "email": "valid@email.com" }
The response object (res.text) will contain a randomly generated 32 byte string that will serve as the new user's token for signing in to create a profile. Example
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbiI6IjVhNTFiZmI1YTlkYzJjYzY0MGRkODljODIwZjZkZWZjY2RiMGNmOTc2NGI4YjZkYTUwNDk4NzljOGNjOWZmNDIiLCJpYXQiOjE0ODk1OTIzMjB9.vfM9xh4iFZFOU_aFpWz_z4SbTAwjbAkuRCgnyyhgnEk
This is the endpoint to hit for a user to sign in.
User will be asked to enter username
and password
.
Ways2Go uses the bcrypt npm module to create and verify encypted passwords.
Authorization Header: req.headers.authorization
Format: username:password
IMPORTANT
res.text
will contain the authentication token that will allow the user to create or access their profile and all other routes.
Token:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbiI6IjVhNTFiZmI1YTlkYzJjYzY0MGRkODljODIwZjZkZWZjY2RiMGNmOTc2NGI4YjZkYTUwNDk4NzljOGNjOWZmNDIiLCJpYXQiOjE0ODk1OTIzMjB9.vfM9xh4iFZFOU_aFpWz_z4SbTAwjbAkuRCgnyyhgnEk
This endpoint will allow users to update their username
or password
.
User must be signed in and provide token in Authorization Header
'Bearer <token>'
(single space between fields required
The property to be updated should be sent in JSON format within the req.body
.
{ "password": "newpassword" }
The res.text
property of the response object will contain a status code and message. If successful:
201
password updated successfully
This endpoint will allow a user to remove their account.
User must be signed in and provide token in Authorization Header
to access this route.
'Bearer <token>'
(single space between fields required
Upon success:
res.status
=> 200
res.text
=> account removed
Profile | top
This endpoint will allow a signed in user with a valid token to create a Profile.
There are four components on the req.body
that can be provided by the user to create a profile:
- displayName - unique handle displayed when interacting with features of the app
- fullName - user's name
- address - user's home address
- bio - allows user to provide bio info (will be expanded in future iteration) Should be sent in JSON format:
{ "displayName": "Rollin with my Homies", "fullName": "Joe Driver",
"address": "2909 3rd Ave, Seattle, WA 98103",
"bio": "Who says that the ride to work can't be fun?" }
If successful, res.status
will be 200
and res.body
will be:
{ "profileID": "<user._id>", "displayName": "Rollin with my Homies", "fullName": "Joe Driver",
"address": "2909 3rd Ave, Seattle, WA 98103",
"bio": "Who says that the ride to work can't be fun?", "avgRating": "<avg score>", "timeStamp": "<time profile created>", "reviews": "[]" }
reviews
will be an empty array when profile is created
This enpoint will allow a registered user, with a token, read access to a single, specific profile.
http://ways2go.herokuapp.com/api/profile/<valid 24 character id>
The requested profile on res.body
in JSON format.
{ "profileID": "<user._id>", "displayName": "Rollin with my Homies", "fullName": "Joe Driver",
"address": "2909 3rd Ave, Seattle, WA 98103",
"bio": "Who says that the ride to work can't be fun?", "avgRating": "<avg score>", "timeStamp": "<time profile created>", "reviews": "[{array of Review objects}]" }
Without specifying an ID, this endpoint returns an array of all profiles which can then be sorted or filtered by client side methods.
GET
Authorization Header
: 'Bearer <token>'
The res.body
will contain an array of all user profile objects:
[{profile}, {profile1}, {profile2}]
Hitting this endpoint will allow a logged in user, with a token, to update their profile information:
http://ways2go.herokuapp.com/api/profile
req.body
{ "displayName": "speed_racer" }
The response body will contain the profile object and properties can be accessed individually:
res.body.<key>
This endpoint will allow a user to remove their profile from the database. In order to keep the database clean, the 'pre' hook middleware of Mongoose is leveraged to also remove any resources related to the profile.
http://ways2go.herokuapp.com/api/profile
If profile is successfully removed, res.status
will equal 204
.
There will be no res.body
.
Review | top
This endpoint will allow user to leave reviews for people with whom he/she just shared a ride, one at a time. Only signed in and authorized users can perform this operation.
There are two properties a user will be able to add to a review body:
- rating
- comment
They may choose to provide both or only submit a rating, which is allowed by our model.
Will send a new Review to the database and update a reviews
property on the reviewed user's profile.
To have access to this endpoint a user will need to be signed in and choose a user they wish to see reviews for, the Reviews will then be pulled from that user's profile.
Will look for the data for a particular way and must contain an _id
for the user being reviewed.
Will return all reviews left for a particular user.
This endpoint will allow a user to edit a Review they previously left for a user. Only signed in and authorized users will be able to perform this operation.
A rating and a comment will be sent in the req.body
, where req.body.rating
is required and req.body.comment
is optional.
An updated Review with an updated res.body
will then be sent to the database.
This endpoint will allow an authorized user to delete a Review they've previously written.
The request needs to contain an _id
for that Review.
Will return a 204 status
to confirm a successful deletion.
WAY | top
This is the endpoint for an authorized user to create a new Way.
There are five components on the req.body
that can be provided by the user to create a way, two of which are required:
- startLocation
- endLocation
- recurringDayOfWeek
- startTime
- oneTimeDate
The request body should be made in JSON format:
{ "startLocation": "123 N Jump St Seattle WA 9812",
"endLocation": "99 Problems Ave Seattle WA 98108" }
If successful, res.status
will be 200
and res.body
will be the Way that was saved to the database:
Example
{ "profileID": "58cb5469422bbb001115c74f",
"startLocation": "58cb6af2422bbb001115c758",
"endLocation": "58cb6af2422bbb001115c759",
"_id": "58cb6af2422bbb001115c75a",
"recurringDayOfWeek": [],
"timestamp": "2017-03-17T04:49:54.925Z",
"wayerz": [ "58cb5469422bbb001115c74f" ] }
This is the endpoint to return a Way of a specified _id
property. If the ID is not specified, an array of all Way objects. NOTE: This endpoint does not require authorization and is publically available.
No additional parameters required for this endpoint
If successful, res.status
will be 200
and res.body
will be Way returned from the database:
Example
{
"__v": 1,
"_id": "58cb6af2422bbb001115c75a",
"endLocation": {
"__v": 0,
"_id": "58cb6af2422bbb001115c759",
"city": "Seattle",
"number": "99",
"state": "WA",
"street": "Problems",
"timestamp": "2017-03-17T04:49:54.909Z",
"type": "Ave",
"zip": "98108"
},
"profileID": "58cb5469422bbb001115c74f",
"recurringDayOfWeek": [],
"startLocation": {
"__v": 0,
"_id": "58cb6af2422bbb001115c758",
"city": "Seattle",
"number": "123",
"prefix": "N",
"state": "WA",
"street": "Jump",
"timestamp": "2017-03-17T04:49:54.906Z",
"type": "St",
"zip": "98121"
},
"timestamp": "2017-03-17T04:49:54.925Z",
"wayerz": [
{
"__v": 0,
"_id": "58cb5469422bbb001115c74f",
"displayName": "ayowayer",
"reviews": [],
"timeStamp": "2017-03-17T03:13:45.018Z",
"profileID": "58cb4aaddb9f2e0011bc74b3"
}
]
}
This is the endpoint for an authorized user to update Way of a specified _id
property. The authorized user is required to have the associated profileID
to the Way to successfully update.
There are five components on the req.body
that can be provided by the user to update a way:
- startLocation
- endLocation
- recurringDayOfWeek
- startTime
- oneTimeDate
The request body should be made in JSON format:
{ "startTime":630,
"recurringDayOfWeek":[1,2,3] }
If successful, res.status
will be 200
and res.body
will be the updated Way that was saved to the database:
Example
{ "_id":"58cb6af2422bbb001115c75a",
"profileID":"58cb5469422bbb001115c74f",
"startLocation":"58cb6af2422bbb001115c758",
"endLocation":"58cb6af2422bbb001115c759",
"__v":1,
"startTime":630,
"recurringDayOfWeek":[1,2,3]
,"timestamp":"2017-03-17T04:49:54.925Z",
"wayerz":["58cb5469422bbb001115c74f"] }
This is the endpoint for an authorized user to remove a Way of a specified _id
property. The authorized user is required to have the associated profileID
to the Way to successfully delete.
User must be signed in and provide token in Authorization Header
to access this route.
'Bearer <token>'
(single space between fields required)
Upon success:
res.status
=> 204
This is the endpoint for an authorized user to add another user(wayerID
) to members of the rideshare(wayerz).
Although that this request is a POST, a body is not to be provided in this request. The wayerID
provided as a request url parameter will be the associated profileID
for the user that is to be added to the wayerz
of a specified wayID
.
User must be signed in and provide token in Authorization Header
to access this route.
'Bearer <token>'
(single space between fields required)
If successful, res.status
will be 200
and res.body
will be the Way with an updated wayers property that was saved to the database:
Example
{ "_id":"58cb6af2422bbb001115c75a",
"profileID":"58cb5469422bbb001115c74f",
"startLocation":"58cb6af2422bbb001115c758",
"endLocation":"58cb6af2422bbb001115c759",
"__v":2,
"startTime":630,
"recurringDayOfWeek":[1,2,3],
"timestamp":"2017-03-17T04:49:54.925Z",
"wayerz":["58cb5469422bbb001115c74f","58cb81c0a766d40011ec1c34"] }
This is the endpoint for an authorized user to remove another user(wayerID
) from the members of the rideshare(wayerz).
User must be signed in and provide token in Authorization Header
to access this route.
'Bearer <token>'
(single space between fields required)
If successful, res.status
will be 200
and res.body
will be the Way with an updated wayers property that was saved to the database:
Example
{ "_id":"58cb6af2422bbb001115c75a",
"profileID":"58cb5469422bbb001115c74f",
"startLocation":"58cb6af2422bbb001115c758",
"endLocation":"58cb6af2422bbb001115c759",
"__v":2,
"startTime":630,
"recurringDayOfWeek":[1,2,3],
"timestamp":"2017-03-17T04:49:54.925Z",
"wayerz":["58cb5469422bbb001115c74f"] }
MESSAGE | top
This is the endpoint for a user to create a new message.
The request should be made in JSON format:
{ "profileID": 6789, "password": "notpassword", "email": "valid@email.com" }
Will either indicate success or failure in creating a new message
200
Allows user to post a message
400
Invalid Body, unable to create a message
This is the endpoint for a user to retrieve their messages.
User will be asked to enter username
and password
.
Ways2Go uses the bcrypt npm module to create and verify encypted passwords.
Authorization Header: req.headers.authorization
Format: username:password
res.text
will contain the authentication token that will allow the user to access their messages.
200
Allows user to review previous messages
404
Not Found
This endpoint will allow users to update thetext
in a message.
User must be signed in and provide token in Authorization Header
'Bearer <token>'
(single space between fields required
The property to be updated should be sent in JSON format within the req.body
.
{ "password": "newpassword" }
The res.text
property of the response object will contain a status code and message. If successful:
200
Including any updated text from the user
400
Bad request
401
Unauthorized to make any updates
This endpoint will allow a user to remove a message they have sent.
User must be signed in and provide token in Authorization Header
to access this route.
'Bearer <token>'
(single space between fields required)
Upon success:
res.status
=> 200
Upon failure:
res.status
=> 401
res.text
: Sorry, you do not have access to these messages
DEPENDENCIES | top
Without this wizardry, there would be no ways2go.