Skip to content

Commit c1b7b2b

Browse files
committed
update sequelize module
1 parent f834311 commit c1b7b2b

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
# Node.js Rest APIs with Express, Sequelize & MySQL example
22

33
For more detail, please visit:
4-
> [Build Node.js Rest APIs with Express, Sequelize & MySQL](https://bezkoder.com/node-js-express-sequelize-mysql/)
4+
> [Build Node.js Rest APIs with Express, Sequelize & MySQL](https://www.bezkoder.com/node-js-express-sequelize-mysql/)
55
6-
> [Server side Pagination in Node.js with Sequelize and MySQL](https://bezkoder.com/node-js-sequelize-pagination-mysql/)
6+
> [Server side Pagination in Node.js with Sequelize and MySQL](https://www.bezkoder.com/node-js-sequelize-pagination-mysql/)
77
8-
> [Deploying/Hosting Node.js app on Heroku with MySQL database](https://bezkoder.com/deploy-node-js-app-heroku-cleardb-mysql/)
8+
> [Deploying/Hosting Node.js app on Heroku with MySQL database](https://www.bezkoder.com/deploy-node-js-app-heroku-cleardb-mysql/)
99
1010
Security:
11-
> [Node.js Express: JWT example | Token Based Authentication & Authorization](https://bezkoder.com/node-js-jwt-authentication-mysql/)
11+
> [Node.js Express: JWT example | Token Based Authentication & Authorization](https://www.bezkoder.com/node-js-jwt-authentication-mysql/)
1212
1313
Associations:
14-
> [Sequelize Associations: One-to-Many Relationship example](https://bezkoder.com/sequelize-associate-one-to-many/)
14+
> [Sequelize Associations: One-to-Many Relationship example](https://www.bezkoder.com/sequelize-associate-one-to-many/)
1515
16-
> [Sequelize Associations: Many-to-Many Relationship example](https://bezkoder.com/sequelize-associate-many-to-many/)
16+
> [Sequelize Associations: Many-to-Many Relationship example](https://www.bezkoder.com/sequelize-associate-many-to-many/)
1717
1818
Fullstack:
19-
> [Vue.js + Node.js + Express + MySQL example](https://bezkoder.com/vue-js-node-js-express-mysql-crud-example/)
19+
> [Vue.js + Node.js + Express + MySQL example](https://www.bezkoder.com/vue-js-node-js-express-mysql-crud-example/)
2020
21-
> [Vue.js + Node.js + Express + MongoDB example](https://bezkoder.com/vue-node-express-mongodb-mevn-crud/)
21+
> [Vue.js + Node.js + Express + MongoDB example](https://www.bezkoder.com/vue-node-express-mongodb-mevn-crud/)
2222
23-
> [Angular 8 + Node.js + Express + MySQL example](https://bezkoder.com/angular-node-express-mysql/)
23+
> [Angular 8 + Node.js + Express + MySQL example](https://www.bezkoder.com/angular-node-express-mysql/)
2424
25-
> [Angular 10 + Node.js + Express + MySQL example](https://bezkoder.com/angular-10-node-js-express-mysql/)
25+
> [Angular 10 + Node.js + Express + MySQL example](https://www.bezkoder.com/angular-10-node-js-express-mysql/)
2626
27-
> [Angular 11 + Node.js Express + MySQL example](https://bezkoder.com/angular-11-node-js-express-mysql/)
27+
> [Angular 11 + Node.js + Express + MySQL example](https://www.bezkoder.com/angular-11-node-js-express-mysql/)
2828
29-
> [Angular 12 + Node.js Express + MySQL example](https://bezkoder.com/angular-12-node-js-express-mysql/)
29+
> [Angular 12 + Node.js + Express + MySQL example](https://www.bezkoder.com/angular-12-node-js-express-mysql/)
3030
31-
> [React + Node.js + Express + MySQL example](https://bezkoder.com/react-node-express-mysql/)
31+
> [Angular 13 + Node.js + Express + MySQL example](https://www.bezkoder.com/angular-13-node-js-express-mysql/)
32+
33+
> [React + Node.js + Express + MySQL example](https://www.bezkoder.com/react-node-express-mysql/)
3234
3335
Integration (run back-end & front-end on same server/port)
34-
> [Integrate React with Node.js Restful Services](https://bezkoder.com/integrate-react-express-same-server-port/)
36+
> [Integrate React with Node.js Restful Services](https://www.bezkoder.com/integrate-react-express-same-server-port/)
3537
36-
> [Integrate Angular with Node.js Restful Services](https://bezkoder.com/integrate-angular-10-node-js/)
38+
> [Integrate Angular with Node.js Restful Services](https://www.bezkoder.com/integrate-angular-10-node-js/)
3739
38-
> [Integrate Vue with Node.js Restful Services](https://bezkoder.com/serve-vue-app-express/)
40+
> [Integrate Vue with Node.js Restful Services](https://www.bezkoder.com/serve-vue-app-express/)
3941
4042
## Project setup
4143
```

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
"author": "bezkoder",
1818
"license": "ISC",
1919
"dependencies": {
20-
"body-parser": "^1.19.0",
2120
"cors": "^2.8.5",
2221
"express": "^4.17.1",
2322
"mysql2": "^2.0.2",
24-
"sequelize": "^5.21.2"
23+
"sequelize": "^6.21.0"
2524
}
2625
}

server.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const express = require("express");
2-
// const bodyParser = require("body-parser"); /* deprecated */
32
const cors = require("cors");
43

54
const app = express();
@@ -11,14 +10,21 @@ var corsOptions = {
1110
app.use(cors(corsOptions));
1211

1312
// parse requests of content-type - application/json
14-
app.use(express.json()); /* bodyParser.json() is deprecated */
13+
app.use(express.json());
1514

1615
// parse requests of content-type - application/x-www-form-urlencoded
17-
app.use(express.urlencoded({ extended: true })); /* bodyParser.urlencoded() is deprecated */
16+
app.use(express.urlencoded({ extended: true }));
1817

1918
const db = require("./app/models");
2019

21-
db.sequelize.sync();
20+
db.sequelize.sync()
21+
.then(() => {
22+
console.log("Synced db.");
23+
})
24+
.catch((err) => {
25+
console.log("Failed to sync db: " + err.message);
26+
});
27+
2228
// // drop the table if it already exists
2329
// db.sequelize.sync({ force: true }).then(() => {
2430
// console.log("Drop and re-sync db.");

0 commit comments

Comments
 (0)