An open API service indexing awesome lists of open source software.

https://github.com/yarapolana/nodejs-auth-api-v2

🗓 NodeJS Schedule Auth API
https://github.com/yarapolana/nodejs-auth-api-v2

bee-queue express jwt-authentication mail mongodb multer nodejs postgresql rocketseat-desafio-03 sentry sequelize

Last synced: about 1 month ago
JSON representation

🗓 NodeJS Schedule Auth API

Awesome Lists containing this project

README

          



🗓NodeJS REST API Challenge V2


This is my third NodeJS server, part two of this repo and a code challenge from a class in Rocketseat's Bootcamp. The challenge involves creating a booking system REST API server from scratch using nodejs. Read Description









🚀Description



Build an authentication service from scratch using Express, Nodemon, Sequelize, Jsonwebtoken, Yup and Postgres. In this application I used linting standards with ESLint + Prettier + EditorConfig.

### Routes
Bookings
- `GET /bookings`: This route displays an array of all bookings created by the authenticated user.

- `GET /bookings/:id`: This route uses `id` as a parameter and displays a single booking.

- `POST /bookings`: This route creates a new booking and receives `file_id`, `title`, `description`, `location` and `date` in the body. All fields are required. This request should return the user's id as the organizer's id.

- `PUT /bookings/:id`: This route uses `id` as a parameter and this is where booking gets updated. Request receives any of these fields `file_id`, `title`, `description`, `location` and `date`, only the user who created the booking can edit it.

- `DELETE /bookings/:id`: This route uses `id` as a parameter and deletes the booking, only the user who created the booking can delete it.

Subscriptions
- `GET /subscriptions`: This route displays an array of all bookings that the authenticated user is subscribed to.

- `POST /subscriptions`: This route creates a subscription to a meetup and must receive `name`, `email` and `password` in the body. You must validate the user where you state that all fields are required, `email` must be an email and password has a minimum of 8 characters.

Organizer
- `GET /organizer`: This is a test route you can send as response an `OK` message.

Files
- `POST /files`: This route creates a new file to be used in creating bookings and it must receive `file` in `multipart formdata`. The response should provide the name, url and the path to the file.

### Rules


- On get bookings route, filter with a date query (not hour), it should display an array paginated by 10 items per page.
This query should come with the organizer's data.

In the below query example, it shows that on page 2 it should display meetups that happened on the 1st of July 2019.

```http://localhost:3333/meetups?date=2019-07-01&page=2```

Make sure:
- User can not create meetups with past dates.

- User can only book meetups he does not organize.

- User can not book past meetups.

- User can not book the same meetup twice.

- User can not book different meetups on the same time period.

- User can only edit and cancel meetups that have not passed and that he organizes.

- Send an email for every meetup booked, only applicable for users with organizer role.

- Only display meetups that have not passed and order by closest as first on the list.

### MVC

Dive deeper and explore the Model View Controler model.

Usage


To run the application first install dependencies

```
yarn or npm install
```

This application uses Postgres so make sure to have that running too (with Docker recommended) then run the application

```
yarn dev
```

Your code should be up and running here

```http://localhost:3333```

---

Check out the fullstack version of this challenge here.

---
### License:

This project is made available under the [MIT LICENSE](LICENSE.md).

### Authors: