The server-side application for the GoBarber App.
Interactive API
·
Report Bug
·
Request Feature
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.
The project was built using the following languages stacks:
Back-End(server)
- Node
- Typescript
- Docker
- Express
- TypeORM
- PostgreSQL
- Redis
- Nodemailer
- Bcryptjs
- Jsonwebtoken
- Multer
- Handlebars.js
- Celebrate
- TSyringe
- class-transformer
- date-fns
- Mime
- ioredis
- node-rate-limiter-flexible
- uuid
- aws-sdk
- Swagger UI Express
Testing Frameworks
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.
- Node
- NPM
- Yarn
- Docker
- Clone the repo
git clone https://github.com/Torres-ssf/gobarber-backend
- CD into the project root directory
cd gobarber-backend/
- Install npm packages
yarn
- Make a copy of the
ormconfig.example.json
file and rename it toormconfig.json
.
5. Make a copy of the `.env.example` file and rename it to `.env`.
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:
- 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.
- 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.
Setting up the application without Docker requires more steps.
- We need to edit the properties
user
,password
,port
, anddatabase
at theormconfig.json
. The values that you are going to use depend on how postgreSQL is setup on your system. After setting upuser
,password
, andport
we need to give the name of an existent database to thedatabase
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 ```
- 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!
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:
- At the documentation page, we will use the session endpoint to generate an jwt token. Click at
Try it out
- Give the admin credentials and click on the execute button:
- Copy the generated token from the response object:
- Click on the
Authorize
button at the top of the page:
- Insert the token in the value input and then click on
Authorize
:
- Now all endpoints can be used within the documentation.
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.
This application has tests. To run the tests we can simply run the following script.
yarn test
👤 Torres-ssf
- Github: @Torres-ssf
- Twitter: @torres_ssf
- Linkedin: torres-ssf
Contributions, issues and feature requests are welcome!
Feel free to check the issues page.
Give a ⭐️ if you like this project!
This project is MIT licensed.