Skip to content

Social networking rideshare solution for your daily commute.

License

Notifications You must be signed in to change notification settings

dkulp23/ways2go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status

Ways2Go

Social networking rideshare solution for your daily commute.

Models | Routes | Testing | About Us

Ways2GO


MODELS

User | Profile | Reviews | Way | Message |


User

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 }
}

Profile

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 with user._id when Profile is created
    • avgRating is generated from aggregate of review ratings
    • timeStamp is automatically generated when Profile is created
    • reviews is an array of review._id objects for reviews of Profile owner

Review

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 }
}

Message

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 with user._id when Profile is created
    • fromProfileID is generated from aggregate of review ratings
    • timeStamp is automatically generated when Message is created
    • text the body of the message being sent by the user

ROUTES


User | top

POST: /api/user

This is the endpoint to hit to sign up a new user.

Request

There are three required components to the request that every user must provide in order to create an account:

  • username
  • password
  • email

The request should be made in JSON format:

{ "username": "helloworld", "password": "notpassword", "email": "valid@email.com" }
Response

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

GET: /api/user

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.

Request

Authorization Header: req.headers.authorization Format: username:password

Response

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

PUT: /api/user

This endpoint will allow users to update their username or password.

Request

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" }

Response

The res.text property of the response object will contain a status code and message. If successful:

201
password updated successfully

DELETE: /api/user

This endpoint will allow a user to remove their account.

Request

User must be signed in and provide token in Authorization Header to access this route. 'Bearer <token>' (single space between fields required

Response

Upon success: res.status => 200 res.text => account removed

Profile | top

POST: /api/profile

This endpoint will allow a signed in user with a valid token to create a Profile.

Request

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?" }
Response

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

GET: /api/profile/:id

This enpoint will allow a registered user, with a token, read access to a single, specific profile.

Request

http://ways2go.herokuapp.com/api/profile/<valid 24 character id>

Response

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}]" }

GET: /api/profile

Without specifying an ID, this endpoint returns an array of all profiles which can then be sorted or filtered by client side methods.

Request

GET Authorization Header: 'Bearer <token>'

Response

The res.body will contain an array of all user profile objects:

[{profile}, {profile1}, {profile2}]

PUT /api/profile

Hitting this endpoint will allow a logged in user, with a token, to update their profile information:

Request

http://ways2go.herokuapp.com/api/profile

  • req.body { "displayName": "speed_racer" }
Response

The response body will contain the profile object and properties can be accessed individually: res.body.<key>

DELETE: /api/profile

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.

Request

http://ways2go.herokuapp.com/api/profile

Response

If profile is successfully removed, res.status will equal 204. There will be no res.body.

Review | top

POST: /api/wayerz/:wayerzID/review

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.

Request

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.

Response

Will send a new Review to the database and update a reviews property on the reviewed user's profile.

GET: /api/wayerz/:wayerzID/review

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.

Request

Will look for the data for a particular way and must contain an _id for the user being reviewed.

Response

Will return all reviews left for a particular user.

PUT: /api/review/:id

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.

Request

A rating and a comment will be sent in the req.body, where req.body.rating is required and req.body.comment is optional.

Response

An updated Review with an updated res.body will then be sent to the database.

DELETE: /api/review/:id

This endpoint will allow an authorized user to delete a Review they've previously written.

Request

The request needs to contain an _id for that Review.

Response

Will return a 204 status to confirm a successful deletion.


WAY | top


POST: /api/way

This is the endpoint for an authorized user to create a new Way.

Request

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" }
Response

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" ] }

GET: /api/way/:id

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.

Request

No additional parameters required for this endpoint

Response

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"
        }
    ]
}

PUT: /api/way/:id

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.

Request

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] }
Response

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"] }

DELETE: /api/way/:id

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.

Request

User must be signed in and provide token in Authorization Header to access this route. 'Bearer <token>' (single space between fields required)

Response

Upon success: res.status => 204

POST: /api/way/:wayID/wayerz/:wayerID

This is the endpoint for an authorized user to add another user(wayerID) to members of the rideshare(wayerz).

Request

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)

Response

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"] }

DELETE: /api/way/:wayID/wayerz/:wayerID

This is the endpoint for an authorized user to remove another user(wayerID) from the members of the rideshare(wayerz).

Request

User must be signed in and provide token in Authorization Header to access this route. 'Bearer <token>' (single space between fields required)

Response

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

POST: /api/profile/:profileID/message

This is the endpoint for a user to create a new message.

Request

The request should be made in JSON format:

{ "profileID": 6789, "password": "notpassword", "email": "valid@email.com" }
Response

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

GET: /api/message/:id

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.

Request

Authorization Header: req.headers.authorization Format: username:password

Response

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

PUT: /api/message/:id

This endpoint will allow users to update thetext in a message.

Request

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" }

Response

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

DELETE /api/message/:id

This endpoint will allow a user to remove a message they have sent.

Request

User must be signed in and provide token in Authorization Header to access this route. 'Bearer <token>' (single space between fields required)

Response

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.



TESTING | top



INTEGRATION | top


Travis CI


DEPLOYMENT | top


Heroku


ABOUT US | top


Anna Ulanova - Full Stack Developer - @annaul

Darcy McCabe - Full Stack Developer - @darms

Remil Marzan - Full Stack Developer - @remilonwheels

Dana Kulp - Full Stack Developer - @dkulp23

About

Social networking rideshare solution for your daily commute.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •