Skip to content

API Documentation

HeribertoGalvezGarcia edited this page May 28, 2020 · 1 revision

GET Requests

/api/users/all: Gets all users in the database. Requires user to be admin.

/api/users/:userId: Get the user of the specified ID. 404s if user not found.

/api/users/:userId/reviews: Gets all reviews of the specified user. 404s if user not found.

/api/users/:userId/reviews/:revId: Gets the specified review from the specified user. 404s if user or review not found.

/api/reviews: Gets all reviews in the database.

/api/reviews/:revId: Gets the specified review by the specified ID. 404s if review not found.

/api/companies: Gets all companies in the database.

/api/companies/:companyId: Gets the specified company by the specified ID. 404s if company not found.

/api/companies/:companyId/reviews: Gets all reviews made about the specified company. 404s if company not found.

POST Requests

/api/auth/register: Creates a user with the given data. 409s if a user with the provided email already exists. Returns a token to be used with protected routes.

/api/auth/login: Logs in as the user with the given data. 401s if the provided credentials are incorrect. Returns a token to be used with protected routes.

/api/users/:userId/add-review: Creates a review under the user id given. 404s if user provided and user's token don't match.

/api/companies: Creates a company with the given data.

PUT Requests

/api/users/:userId: Updates a user with the given data. 404s if user not found. 409s if new update is used by an existing user.

/api/users/:userId/bind: Updates a user's bind status. 404s if user not found. 403s if user's token isn't an admin.

/api/users/:userId/reviews/:reviId: Updates a user's review with the given data. 404s if user not found.

/api/companies/:companyId: Updates a company with the given data. 404s if company not found.

DELETE Requests

/api/users/:userId: Deletes the user of the provided ID. 404s if user not found.

/api/users/:userId/reviews/:revId: Deletes the review of the user. 404s if user or review not found.

/api/companies/:companyId: Deletes the company of the provided ID. 404s if company not found. 403s if user's token isn't an admin.

Clone this wiki locally