In which I explore, again, writing a RESTful API using Node.js and express but this time using MySql and sequelize for data persistence.
- First of all, make sure you have npm node installed
- Clone the repository
$ npm install
- Make sure you have mysql running (
$ mysql.server start
). Create a database called bank_development (or any other name you want, but make sure you specify the right database name inconfig/models.json
). Add the proper configuration data in the config/models.json file. $ node_modules/sequelize/bin/sequelize -m
- this will run the migrations and create the tables
You might have to editnode_modules/sequelize/bin/sequelize
so it will look at the right config file (line 11 should be, configFile = configPath + '/models.json'
)$ node seed.js
- this will populate the tables with some test values- Finally, you can run the application:
$ node server.js
- Navigate to
http://127.0.0.1:3000
/http://127.0.0.1:3000/offices
, etc.