Developed with Express, malbums-api it's a music albums management system. Malbums means 'music albums', it's simple but sufficient for this project.
Expressto deal with routesTypeORMas ORMMySQLas databaseDockerto work with containersDocker-composeto manage containers
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)
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:
- Eslint (more details in https://eslint.org/)
- Prettier (more details in https://prettier.io/)
Clone this repository by running:
git clone https://github.com/IanMiranda43/malbums-api.gitAccess 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.
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=passwordremember 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 buildTo create and start your containers, run the following command:
docker-compose upIf 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
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 installThe 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:devThis can be found by accessing http://localhost:3000
MIT License © Ian Miranda