Skip to content

IanMirandaDev/malbums-api

Repository files navigation

malbums-api


Developed with Express, malbums-api it's a music albums management system. Malbums means 'music albums', it's simple but sufficient for this project.

The system use:

  • Express to deal with routes
  • TypeORM as ORM
  • MySQL as database
  • Docker to work with containers
  • Docker-compose to manage containers

Requirements

System requirements

Before start, check if you have installed and configured the following tools:

  • Git
  • Node.js
  • Docker (just if you want to run the system with the automatic docker default configuration)
  • MySQL (just if you will not run it with Docker)

Editor requirements

The system is configured to a better code style with development tools like Eslint and Prettier, but to this tools work it's necessary to have installed and configured the following extensions in your code editor:

Getting started

Cloning the repository

Clone this repository by running:

git clone https://github.com/IanMiranda43/malbums-api.git

Configuring the project

Access the project folder and then set your server port, DB credentials and an JWT secret string as token in the .env file.

PORT=3001

JWT_SECRET=secret_token

# DB credentials for DEV and PROD environments
DB_TYPE_DEV=mysql
DB_NAME_DEV=database
DB_USER_DEV=user
DB_PASS_DEV=password
DB_HOST_DEV=127.0.0.1
DB_PORT_DEV=3306

DB_TYPE_PROD=mysql
DB_NAME_PROD=database
DB_USER_PROD=user
DB_PASS_PROD=password
DB_HOST_PROD=db
DB_PORT_PROD=3306

The .env.example file have this layout, just set your data there and remove the .example extension from it.

Working with Docker

The project has all the Docker configurations that its needed. If do you want to run with containers, there are configured to run the node project in one and the database in another. With that your containers will be created and the project configured properly without to need any intervention before its running.

The database container need to be configured with the database, username and user password before its builded. To make that, we have an .env.example file in the path .docker/mysql/.env.example. Copy or rename that file to .env and set your database config in there like bellow.

MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=database
MYSQL_USER=username
MYSQL_PASSWORD=password

remember that this credentials will be used by your system and needs to be the same that you configured at the main .env file in the root folder

After that, run the following to build your docker images:

docker-compose build

To create and start your containers, run the following command:

docker-compose up

Configuring without Docker

If you did not want to use Docker you can configure the server by yourself:

Remember that in this case you need to have an configured and running MySQL database

Installing the dependencies:

In the project folder run de following code. This will create a node_modules folder and download and install all the project dependencies in there.

# with npm
npm install
# with yarn
yarn install

Start the server:

The script will run the migrations and then start the application at the port setted on the .env file.

# with npm
npm run start:dev
# with yarn
yarn start:dev

Access the page

This can be found by accessing http://localhost:3000



License

MIT License © Ian Miranda

About

Music albums management api

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published