This repository is part of my WYT.com project, is just an application to give recommendations of movies, books, tv-shows and music.
- nodeJS
- Express
- Docker
- Sequelize
- Postrgres
- JWT
You need Docker and Docker Compose on your computer, because there is a docker-compose.yml
file that creates a container to the Postgres database.
Also you need nodeJS, this project was made in the 16 version of node.
- Clone the repository
git clone https://github.com/germanruzca/wyt-backend.git cd wyt-backend
- Install dependencies
npm install
- Introduce the environment variables
You can create a .env
file or in ZSH
WYT="~/wyt"
WYT_PSQL_HOST="0.0.0.0"
WYT_PSQL_CONTAINER_NAME="wyt_postgres"
WYT_PSQL_LISTEN_PORT="5001"
WYT_PSQL_VOLUME_PATH="${WYT}/postgres/data"
WYT_PSQL_DB="wyt_databse"
WYT_PSQL_USER="wyt_user"
WYT_PSQL_PASSWORD="passwordDB"
WYT_ACTION_SECRET="passwordAccess"
WYT_REFRESH_SECRET="passwordRefresh"
-
Go the docker folder
cd containers
-
Install docker images and create container.
docker-compose up
-
Start the project
npm run start
There is nodemon package.
The backend starts in the 3001 port, sync with frontend.
This is the backend part of an application, the fronted (reactJS
) could be find in this link.
There are four web services that provide the full CRUD.
Here the four end-points to each web service:
people registered on the application
-
localhost/3001/users
routes / controller / model
the post with the recommendations.
-
localhost/3001/posts
routes / controller / model
storage the differents types of recommendations.
-
localhost/3001/types
routes / controller / model
to login and sign up.
-
localhost/3001/auth
First, you need create a user, localhost/3001/auth/signup
{
"firstName": "John",
"lastName": "Lennon",
"username": "john123",
"password": "john123",
}
When you are in, you receive a response with an accesToken to use in others requests. You need to login (localhost/3001/auth/login
) every time the token has expired.
(For now, there is no data when the models are created, so you must to know: to create a post is need create at least a type and a user.)
You can see example: