Skip to content

NUber, is a RESTful API consisting of microservices to handle incoming requests from a Lyft/Uber style mobile or web application. — Node.js/Express.js, MongoDB/Mongoose.js, Google Maps API, and deployment via Heroku CLI.

Notifications You must be signed in to change notification settings

abmaxwell/NUber

 
 

Repository files navigation

/////////////////////////////////////////////////////////////
// NPM MODULES NEEDED
/////////////////////////////////////////////////////////////

npm install node --save
npm install express --save --save-exact
npm install mongoose --save --save-exact
npm install jsonwebtoken --save --save-exact
npm install enum --save --save-exact
npm install google-distance --save --save-exact

/////////////////////////////////////////////////////////////
// URLS & Functionality
////////////////////////////////////////////////////////////

URL TO KEROKU APP: https://nuber-network.herokuapp.com

DRIVER TYPES:

chauffeur
amateur
baby_driver
betty_white

SERVICE TYPES:

nuber_x
nuber_xl
number_select
nuber_black
nuber_suv
nuber_lux

CONCIERGE TYPES:

none
hunk
hottie
average_joe
average_jane
below_average_jones

NOTE! All types above MUST be entered as they appear.


////////////////////////////////////////////////
//  https://nuber-network.herokuapp.com/users
///////////////////////////////////////////////

[POST] /users/
- Expects: Nothing.
- Creates: New user.
- Returns: Nothing.

[GET] /users/
- Expects: Nothing.
- Creates: Nothing.
- Returns: All users.

[GET] /users/:id
- Expects: The mongoDB if of the user.
- Creates: Nothing.
- Returns: User by id.

[DELETE] /users/:id
- Expects: The mongoDB if of the user.
- Creates: Nothing.
- Returns: Nothing.

[PUT] /users/:id
- Expects: The mongoDB if of the user.
- Creates: Updates the properties of the specified user.
- Returns: Nothing.


////////////////////////////////////////////////////
//  https://nuber-network.herokuapp.com/drivers
////////////////////////////////////////////////////
[POST] /drivers/
- Expects: Nothing.
- Creates: New driver.
- Returns: Nothing.

[GET] /drivers/
- Expects: Nothing.
- Creates: Nothing.
- Returns: All drivers.

[GET] /drivers/:id
- Expects: The mongoDB id of driver.
- Creates: Nothing.
- Returns: Driver by id.

[GET} /drivers/service/:type
- Expects: The desired service type.
- Creates: Nothing.
- Returns: All drivers of specified service type.

[GET} /drivers/type/:type
- Expects: The desired driver type.
- Creates: Nothing.
- Returns: All drivers of specified driver type.

[GET] /drivers/:id/range?distance=<distance>
- Expects: The mongoDB id of user and a specified range (Double or Int).
- Creates: Nothing.
- Returns: All drivers within the specified distance.

[DELETE] /drivers/:id
- Expects: The mongoDB id of the driver.
- Creates: Nothing.
- Returns: Nothing.

[PUT] /drivers/:id
- Expects: The mongoDB of the driver.
- Creates: Updates the properties of the specified driver.
- Returns: Nothing.

[PUT] /drivers/:id/status?available=<Bool>
- Expects: The mongoDB of the driver and a status for available of either true or false.
- Creates: Updates the "available" property of specified driver.
- Returns: Nothing.

////////////////////////////////////////////////////
//  https://nuber-network.herokuapp.com/trips
////////////////////////////////////////////////////

[POST] /trips/new?userid=<id>&driverid=<id>&concierge=<type>

- Expects: The mongoDB id of the user and driver. As well as a specific concierge type.
- Creates:
--- A new trip with the specified user and driver.
--- Concierge type is optional and if none is specified then none will be attached to the trip.
--- Distance is calculated using Google Maps API.
--- Duration is calculated using Google Maps API.
--- Directions URL is calculated using Google Maps API.
- Returns: Nothing.

[GET] /trips/

- Expects: Nothing.
- Creates: Nothing.
- Returns: All trips.


[GET] /trips/:id

- Expects: The mongoDB id of the trip.
- Creates: Nothing.
- Returns: Trip by id.

[GET] /trips/:id/directions

- Expects: The mongoDB id of the trip.
- Creates: Nothing.
- Returns: The direction URL as generated by the Google Maps API.

[GET] /trips/:id/duration

- Expects: The mongoDB id of the trip.
- Creates: Nothing.
- Returns: The duration in mm:ss of the trip (driver to user) as calculated by Google Maps API

[GET] /trips/user/:id

- Expects: The mongoDB id of the user.
- Creates: Nothing.
- Returns: All trips taken by the specified user id.

[GET] /trips/driver/:id

- Expects: The mongoDB id of the driver.
- Creates: Nothing.
- Returns: All trips taken by the specified driver id.

[DELETE] /trips/:id
- Expects: The mongoDB id of the trip.
- Expects: The authorization from admin token.
- Creates: Nothing.
- Returns: Nothing.


////////////////////////////////////////////////////
//  https://nuber-network.herokuapp.com/admins
////////////////////////////////////////////////////

[POST] /admins/
- Expects: The authorization from super admin token.
- Creates: A new admin in the database.
- Returns: Nothing.

[GET] /admins/
- Expects: Nothing.
- Creates: Nothing.
- Returns: All admins.

[GET] /admins/:id
- Expects: The mongoDB id of the admin.
- Creates: Nothing.
- Returns: Admin by id.

[DELETE] /admins/:id
- Expects: The mongoDB id of the admin.
- Creates: Nothing.
- Returns: Nothing.

[PUT] /admins/:id
- Expects: The mongoDB id of the admin.
- Creates: Updates the properties of the specified admin.
- Returns: Nothing.

////////////////////////////////////////////////////
//  https://nuber-network.herokuapp.com/superadmins
////////////////////////////////////////////////////

[GET] /superadmins/:id
- Expects: The mongoDB id of the super admin.
- Creates: Nothing.
- Returns: Super admin by id.

[POST] /superadmins/
- Expects: Nothing.
- Creates: Super admin with specified username "Jason Diaz"
- Returns: Nothing.

[DELETE] /superadmins/:id
- Expects: The mongoDB if of the super admin.
- Creates: Nothing.
- Returns: Nothing.

////////////////////////////////////////////////////////////////////
// Authorization Instructions
///////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////
// SUPERADMIN
////////////////////////////////////////////////////

1. In order to receive your SUPERADMIN authorization token perform a GET request on /superadmins/username.
 	  A. YOUR ASSIGNED SUPERADMIN USERNAME IS: 'jasondiaz'.
	  B. Be sure to type your username (jasondiaz) in all lower case. (/superadmins/jasondiaz)
2. The server will respond with a JsonWebToken that will be required when POSTing or DELETE-ing NUber admins from the network.
3. In order to do a POST request to add a NUber admin to the network via Postman:
  	A. Under the headers tab include the key: 'authorization'.
	  B. The value of the key will be: 'Bearer <token>'. Do not include the <> when inserting the token into the value parameter.

Example:  KEY				VALUE
	  authorization 		Bearer xxxxxx.yyyyyy._zzzzzz

4. Repeat the same process in order to DELETE a driver from the NUber network.

////////////////////////////////////////////////////
// ADMIN
////////////////////////////////////////////////////

1. After an admin has been POSTed to NUber by a superadmin, the server will respond with another Bearer token. This token will be required
   in order for a driver to be POSTed or DELETEd from the NUber network.
2. The same token will be required for the POST or DELETE of a NUber trip. The trip will hold sensitive details, such as user and driver
   locations. So the data composing a trip can only be POSTed or DELETEd by a NUber admin.

About

NUber, is a RESTful API consisting of microservices to handle incoming requests from a Lyft/Uber style mobile or web application. — Node.js/Express.js, MongoDB/Mongoose.js, Google Maps API, and deployment via Heroku CLI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%