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
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.
Bookings
-
GET /bookings
: This route displays an array of all bookings created by the authenticated user. -
GET /bookings/:id
: This route usesid
as a parameter and displays a single booking. -
POST /bookings
: This route creates a new booking and receivesfile_id
,title
,description
,location
anddate
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 usesid
as a parameter and this is where booking gets updated. Request receives any of these fieldsfile_id
,title
,description
,location
anddate
, only the user who created the booking can edit it. -
DELETE /bookings/:id
: This route usesid
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 receivename
,email
andpassword
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 anOK
message.
Files
POST /files
: This route creates a new file to be used in creating bookings and it must receivefile
inmultipart formdata
. The response should provide the name, url and the path to the file.
- 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.
Dive deeper and explore the Model View Controler model.
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.
This project is made available under the MIT LICENSE.