At the conception of this sample project, the REST API app was kept alive using PM2 on an AWS EC2. The MySQL was an instance created in AWS RDS.
1. MySQL Driver: The node module mysql
2. REST Framework: Restify
3. Authentication: JsonWebToken
- I integrated JWT for API Authentication.
- Re-scaffold the routes and data files.
- I did not use async/await syntax, and instead, I kept Callbacks and Promise functions because I was being nostalgic of the old days. If you'd like to see me apply async/await used in REST API, take a look at the API_MongoDB_Atlas folder. MongooseJS added the async/await features so it was a given.
- Added proper error handlings using
restify-errors
Sequelize is an ORM and a good alternative to mysql
driver. In this project, I use only mysql
which expects SQL Statements. However, with Sequelize, you don't make SQL Statements. It's beneficial to use Sequelize because it handles many SQL-DB like MSSQL Server, MariaDB and especially MySQL. I like making SQL Statements and being nostalgic, I decided to use mysql
only without any ORM and other frameworks to interface with MySQL for this Web API app.
Three instances (or ways) to have a MySQL Database:
1. Remote MySQL DB on Amazon RDS: https://aws.amazon.com/getting-started/hands-on/create-mysql-db/
2. Local using MAMP on MacOS
3. Local using XAMPP on Windows
Once you have your MySQL Database running, simply change the .env
values for DB_HOST
, DB_USER
, DB_PASSWORD
, DB_PORT
, and DB_NAME
.