Artenes / rocketseat-bootcamp-gobarber-backend

Node js app to connect persons and beauty professionals

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issues MIT License LinkedIn


Logo

Gobarber (backend)

Get in touch with beauty professionals and schedule services!

Table of Contents

About The Project

REST API to manage the schedule of beauty professionals so customer can schedule appointments with them. This is not a flesh out product to be used in production, it is just a demo application created during Rocketseat's GoStack bootamp.

Built With

Getting Started

To get a local copy up and running follow these steps.

Prerequisites

  • Node js
  • yarn
  • Postgres database (you can use docker for that)
  • Reddis server (you can use docker for that)
  • Mongo Database (you can use docker for that)
  • Mailing service (for tests check mailtrap.io)
  • Sentry credentials. We use sentry to track erros and bugs. But this is not mandatory.

Installation

  1. Clone the repo
git clone git@github.com:Artenes/rocketseat-bootcamp-gobarber-backend.git
  1. Access the directory
cd rocketseat-bootcamp-gobarber-backend
  1. Install dependencies
yarn
  1. Create a copy of the .env.example file
cp .env.example .env
  1. Configure the .env file (just follow the comments on it)

  2. Run the migrations to create the tables. Make sure the database you set in .env exists

yarn sequelize db:migrate
  1. Run the queue server, this will handle mails delivery
yarn queue
  1. Run the server
yarn dev

Usage

There are protected and unprotected routes. To access a protected route, you need a JWT token in the header of the requeast as such:

Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NSwiaWF0IjoxNTY3OTUwMTM2LCJleHAiOjE1Njg1NTQ5MzZ9.JPHK7jwgSgvdVABon2HxtJT6ddofu6EWW53az6qF-0M

For that you have to create a user in the POST /users endpoint, then create a session in POST /sessions endpoint. See endpoints descriptions below for more details.

Users

A user that can schedule for services or provide services.

POST /users

Creates a new user.

Body

{
  "name": "Jhon",
  "email": "jhon@doe.com",
  "password": "123456"
}

PUT /users [protected]

Edits the current logged in user.

Body

{
  "name": "New Jhon",
  "email": "newjhon@doe.com",
  "oldPassword": "123456",
  "password": "1234567",
  "confirmPassword": "1234567"
}

Sessions

A session to access protected routes in the API.

POST /sessions

Creates a new JWT token for a user.

Body

{
  "email": "jhon@doe.com",
  "password": "123456"
}

Files

An image used by another resource. Files must be uploaded separately from the requests that need them.

POST /files

Uploads a new file.

Body - Multipart Form

file: file/path

Providers

A user that provide services.

GET /providers [protected]

Lists all providers in the application.

GET /providers/:id/available?date=1571957701 [protected]

Lists all hours available for a provider in the given date (unix timestamp).

Appointments

Appointments created by customers.

GET /appointments [protected]

Gets all appointments of the logged user.

POST /appointments [protected]

Creates a new appointment.

Body

{
  "provider_id": 12,
  "date": "2019-10-24T09:00:00-04:00",
}

Notifications

Manage a provider's notifications list.

GET /notifications [protected]

Gets all notifications for the logged user.

PUT /notifications/:id [protected]

Mark as notification as read.

Contributing

Contributions are welcome, even though this was made only for learning purposes.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Artenes Nogueira - artenes.nogueira@gmail.com

My blog: http://artenesbok.com/

My Linkedin: https://www.linkedin.com/in/artenes/

README template from: https://github.com/othneildrew/Best-README-Template

About

Node js app to connect persons and beauty professionals


Languages

Language:JavaScript 98.1%Language:HTML 1.9%