Skip to content

valdidev/rental-movies

Repository files navigation

RENTAL MOVIES

Nodejs REST API + MySQL database


node_mysql


Backend for application of rental movies and series

Technologies

  • Nodejs with express
  • MySQL database
  • Sequelize ORM
  • Json Web Token

Features

  • CRUD of users, movies and series
  • Log in as administrator to delete users or see all the content of the database
  • See the logs of error, warning and info loggeds in the logs folder

Installation

Requires Node.js v16+ to run.

Install the dependencies and devDependencies and start the server.

npm install

Start up

1. Create the SQL database

Go to the .env.example file and rename it to .env and modify it with your settings

JWT_SECRET="add jtw secret"
SERVICE_PORT="add service port"

DB_USER="add database user"
DB_PSWD="add database password"
DB_HOSTNAME="add database hostname"
DB_PORT="add database port"
DB_NAME="add database name"
DB_DIALECT="add database dialect"

Create database and call it

rentalmovies

or throw

npx sequelize-cli db:create

2. Populate the database

Two ways:


2.1 Migrations

Rename config/example.config.json to config.json and and modify it with your settings

{
  "development": {
    "username": "db username",
    "password": "db password",
    "database": "db database",
    "host": "db host",
    "dialect": "db dialect",
    "port": "db port"
  }
}

Launch the migrations

npx sequelize-cli db:migrate

or


2.2 Sequelize models

Go to index.js and change sequelize.authenticate() to

sequelize.sync()

Remember to change it back if you want to keep the changes


2.3 Seeders

If you want to have mocked data you can use

npx sequelize-cli db:seed:all

Test the app

In the test folder you will find test files as a client

  • auth.test.http
  • movies.test.http
  • series.test.http
  • rentals.test.http

EER Diagram

er-rental-movies

License

MIT

Author

Fernando Valdivielso - @valdidev

Releases

No releases published

Packages

No packages published