Skip to content

Sever-side application for GoBarber, an application for service providers, such as barbers, to control customer appointments. It was built with NodeJs, Typescript, TypeORM, Postgres, MongoDB, Redis, AWS SES and S3.

License

Notifications You must be signed in to change notification settings

Torres-ssf/gobarber-backend

Repository files navigation

Contributors Forks Stargazers Issues


Logo

Gobarber Backend

The server-side application for the GoBarber App.
Interactive API · Report Bug · Request Feature

About The Project

Sever-side application for GoBarber, an application for service providers, such as barbers, to control customer schedules. Postgres was used for the database along with Redis for caching data.

The implemented features are:

  • Users can create new account either as a provider (barber) or as simple user.
  • Users can create a new session using their credentials.
  • Users can create/update their avatar image.
  • Users can create appointments with their desired provider.
  • Users can request for a password reset email.
  • Users can update their info.
  • Providers can see their daily schedule and monthly schedule.
  • The monthly availability of a provider can be fetched.
  • The daily availability of a provider can be fetched.
  • A list of all providers can be fetched.

Built With

The project was built using the following languages stacks:

Back-End(server)
Testing Frameworks

Getting Started

This application is dockerized, if have docker and docker-compose on you system it's pretty straightforward to start using it.

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

Prerequisites

  • Node
  • NPM
  • Yarn
  • Docker

Installation

  1. Clone the repo
git clone https://github.com/Torres-ssf/gobarber-backend
  1. CD into the project root directory
cd gobarber-backend/
  1. Install npm packages
yarn
  1. Make a copy of the ormconfig.example.json file and rename it to ormconfig.json.

5. Make a copy of the `.env.example` file and rename it to `.env`.

Using Docker

This application uses Docker and Docker Compose and can be quickly initiate by simply running docker-compose up. To make this work you will need to have Docker and Docker Compose installed on your system. Docker will setup the database container, create the app database, setup the app container, and will start the app. The steps are:

  1. Run docker compose.
docker-compose up

After docker compose finishing initiate the application, you will see the log App launched at 3333 🚀. Before using the application, it's necessary to run the migrations first.

  1. To run the migrations inside the docker container, we can simply use the following script:
yarn typeorm:docker migration:run

Now the application is ready to be used.

Without Docker

Setting up the application without Docker requires more steps.

  1. We need to edit the properties user, password, port, and database at the ormconfig.json. The values that you are going to use depend on how postgreSQL is setup on your system. After setting up user, password, and port we need to give the name of an existent database to the database property.

2. To setup Redis you will need to edit 3 environment variable at the `.env` file: `REDIS_PORT`, `REDIS_HOST`, and `REDIS_PASSWORD`. Assign these values according on how redis is configured on your system.
3. Now with the database properly setup, we can run the migrations: ``` yarn typeorm migration:run ```
  1. And finally, we can start the app:
yarn dev:server

If everything was done properly, a log message will appear at the terminal: Server started on port 3333!

Usage

It is possible to explore all API endpoints using an interactive documentation created with Swagger UI. After the application is running you can open the browser at http://localhost:3333/documentation and start using it.

To be able to tests login required endpoint at the Swagger Documentation, you will need first to use a jwt token to gain authorization. The steps are the following:

  1. At the documentation page, we will use the session endpoint to generate an jwt token. Click at Try it out

  1. Give the admin credentials and click on the execute button:

  1. Copy the generated token from the response object:

  1. Click on the Authorize button at the top of the page:

  1. Insert the token in the value input and then click on Authorize:

  1. Now all endpoints can be used within the documentation.
App Scripts:
yarn dev:server

Script for development stage. An output message should appear on the terminal: Server started on port 3333!

yarn typeorm

Used for operations related to Typeorm, like creating migrations.

yarn typeorm:docker

Run typeorm cli inside Docker container.

yarn build

Transpile Typescript code into Javascript inside the dist directory.

Run tests

This application has tests. To run the tests we can simply run the following script.

yarn test

Authors

👤 Torres-ssf

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check the issues page.

Show your support

Give a ⭐️ if you like this project!

📝 License

This project is MIT licensed.

About

Sever-side application for GoBarber, an application for service providers, such as barbers, to control customer appointments. It was built with NodeJs, Typescript, TypeORM, Postgres, MongoDB, Redis, AWS SES and S3.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published