My first challenge as intern at Compass UOL.
- Install Git and Node.js (which includes Node Package Manager)
Clone the repository on your machine in a new folder:
git clone https://github.com/pedrobraghin/first-challenge.git
Install dependencies:
cd [FOLDER NAME]
npm install
npm run start:dev
npm run test
npm run build
All API endpoints can be found in the documentation below or in the Swagger documentation.
In addition to the documentation, the documentation with Swagger is also available at the endpoint:
/api/v1/api-docs
-
POST /api/v1/users/signup{ "firstName": "John", "lastName": "Doe", "birthDate": "1995-01-31", "email": "john@example.com", "city": "London", "country": "England", "password": "12345678", "confirmPassword": "12345678" }201 Created// no response body -
POST /api/v1/users/signin{ "email": "john@example.com", "password": "12345678" }200 OK{ "status": "success", "message": "Authentication successful" }401 Unauthorized{ "status": "fail", "message": "Invalid email or password" }
-
POST /api/v1/events{ "description": "Hackathon event", "dateTime": "2023-02-11T13:38:11.295Z" }201 Created{ "description": "Hackathon event", "dateTime": "2023-02-11T13:38:11.295Z", "createdAt": "2023-02-11T13:38:11.295Z", "_id": "a04bd7c2-2cf8-4dee-8784-26e71e5d12ca" } -
GET /api/v1/events/200 OK{ "status": "success", "data:": { "events": [ { "description": "Hackathon event", "dateTime": "2023-02-11T13:38:11.295Z", "createdAt": "2023-02-11T13:38:11.295Z", "_id": "a04bd7c2-2cf8-4dee-8784-26e71e5d12ca" } ] } }404 Not Found{ "status": "fail", "message": "No events found" } -
GET /api/v1/eventsParameter Type Accepted values dayOfTheWeek query monday, tuesday, wednesday, thursday, friday, saturday, sunday Request to: /api/v1/events?dayOfTheWeek=saturday200 OK{ "status": "success", "data": { "events": [ { "description": "Hackathon event", "dateTime": "2023-02-11T13:38:11.295Z", "createdAt": "2023-02-11T13:38:11.295Z", "_id": "a04bd7c2-2cf8-4dee-8784-26e71e5d12ca" } ] } }Request to: /api/v1/events?dayOfTheWeek=sumday400 Bad Request{ "status": "fail", "message": "Day of the week invalid" }Request to: /api/v1/events?dayOfTheWeek=sunday404 Not Found{ "status": "fail", "message": "No events found" } -
GET /api/v1/events/{id}Parameter Type Accepted Values id path event hash string Request to: /api/v1/events/a04bd7c2-2cf8-4dee-8784-26e71e5d12ca200 OK{ "status": "success", "data": { "event": { "description": "Hackathon event", "dateTime": "2023-02-11T13:38:11.295Z", "createdAt": "2023-02-11T13:38:11.295Z", "_id": "a04bd7c2-2cf8-4dee-8784-26e71e5d12ca" } } }Request to: /api/v1/events/123404 Not Found{ "status": "fail", "message": "Event not found" } -
DELETE /api/v1/eventsParameter Type Accepted values dayOfTheWeek query monday, tuesday, wednesday, thursday, friday, saturday, sunday Request to: /api/v1/events?dayOfTheWeek=saturday200 OK{ "status": "success", "data": { "deletedEvents": [ { "description": "Hackathon event", "dateTime": "2023-02-11T13:38:11.295Z", "createdAt": "2023-02-11T13:38:11.295Z", "_id": "a04bd7c2-2cf8-4dee-8784-26e71e5d12ca" } ] } }Request to: /api/v1/events?dayOfTheWeek=monday200 OK{ "status": "success", "data": { "deletedEvents": [] } }Request to: /api/v1/events?dayOfTheWeek=sumday400 Bad Request{ "status": "fail", "message": "Day of the week invalid" }Request to: /api/v1/events?dayOfTheWeek=monday404 Not Found{ "status": "fail", "message": "No events found" } -
DELETE /api/v1/events/{id}Parameter Type Accepted Values id path event hash string Request to: /api/v1/events/a04bd7c2-2cf8-4dee-8784-26e71e5d12ca200 OK{ "status": "success", "data": { "event": { "description": "Hackathon event", "dateTime": "2023-02-11T13:38:11.295Z", "createdAt": "2023-02-11T13:38:11.295Z", "_id": "a04bd7c2-2cf8-4dee-8784-26e71e5d12ca" } } }Request to: /api/v1/events/123404 Not Found{ "status": "fail", "message": "Event not found" }
If a route that not exists is requested, the server return a 404 response:
{
"status": "fail",
"message": "Route not found. You can see the API documentation at https://github.com/pedrobraghin/first-challenge"
}If a server side error occurs, the server return a 500 response:
{
"status": "error",
"message": "Internal server error. Please try again later"
}The API are deployed on Railway, so you can testing without necessarily intall the application on your machine. Just make the requests to link bellow:
https://first-challenge-pb.up.railway.app