Skip to content

Commit ae7a500

Browse files
committed
update sequelize module
1 parent f834311 commit ae7a500

File tree

3 files changed

+33
-22
lines changed

3 files changed

+33
-22
lines changed

README.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,47 @@
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+
> [Node.js Express File Upload Rest API example](https://www.bezkoder.com/node-js-express-file-upload/)
77
8-
> [Deploying/Hosting Node.js app on Heroku with MySQL database](https://bezkoder.com/deploy-node-js-app-heroku-cleardb-mysql/)
8+
> [Server side Pagination in Node.js with Sequelize and MySQL](https://www.bezkoder.com/node-js-sequelize-pagination-mysql/)
9+
10+
> [Deploying/Hosting Node.js app on Heroku with MySQL database](https://www.bezkoder.com/deploy-node-js-app-heroku-cleardb-mysql/)
911
1012
Security:
11-
> [Node.js Express: JWT example | Token Based Authentication & Authorization](https://bezkoder.com/node-js-jwt-authentication-mysql/)
13+
> [Node.js Express: JWT example | Token Based Authentication & Authorization](https://www.bezkoder.com/node-js-jwt-authentication-mysql/)
1214
1315
Associations:
14-
> [Sequelize Associations: One-to-Many Relationship example](https://bezkoder.com/sequelize-associate-one-to-many/)
16+
> [Sequelize Associations: One-to-Many Relationship example](https://www.bezkoder.com/sequelize-associate-one-to-many/)
1517
16-
> [Sequelize Associations: Many-to-Many Relationship example](https://bezkoder.com/sequelize-associate-many-to-many/)
18+
> [Sequelize Associations: Many-to-Many Relationship example](https://www.bezkoder.com/sequelize-associate-many-to-many/)
1719
1820
Fullstack:
19-
> [Vue.js + Node.js + Express + MySQL example](https://bezkoder.com/vue-js-node-js-express-mysql-crud-example/)
21+
> [Vue.js + Node.js + Express + MySQL example](https://www.bezkoder.com/vue-js-node-js-express-mysql-crud-example/)
22+
23+
> [Vue.js + Node.js + Express + MongoDB example](https://www.bezkoder.com/vue-node-express-mongodb-mevn-crud/)
24+
25+
> [Angular 8 + Node.js + Express + MySQL example](https://www.bezkoder.com/angular-node-express-mysql/)
2026
21-
> [Vue.js + Node.js + Express + MongoDB example](https://bezkoder.com/vue-node-express-mongodb-mevn-crud/)
27+
> [Angular 10 + Node.js + Express + MySQL example](https://www.bezkoder.com/angular-10-node-js-express-mysql/)
2228
23-
> [Angular 8 + Node.js + Express + MySQL example](https://bezkoder.com/angular-node-express-mysql/)
29+
> [Angular 11 + Node.js + Express + MySQL example](https://www.bezkoder.com/angular-11-node-js-express-mysql/)
2430
25-
> [Angular 10 + Node.js + Express + MySQL example](https://bezkoder.com/angular-10-node-js-express-mysql/)
31+
> [Angular 12 + Node.js + Express + MySQL example](https://www.bezkoder.com/angular-12-node-js-express-mysql/)
2632
27-
> [Angular 11 + Node.js Express + MySQL example](https://bezkoder.com/angular-11-node-js-express-mysql/)
33+
> [Angular 13 + Node.js + Express + MySQL example](https://www.bezkoder.com/angular-13-node-js-express-mysql/)
2834
29-
> [Angular 12 + Node.js Express + MySQL example](https://bezkoder.com/angular-12-node-js-express-mysql/)
35+
> [Angular 14 + Node.js + Express + MySQL example](https://www.bezkoder.com/angular-14-node-js-express-mysql/)
3036
31-
> [React + Node.js + Express + MySQL example](https://bezkoder.com/react-node-express-mysql/)
37+
> [React + Node.js + Express + MySQL example](https://www.bezkoder.com/react-node-express-mysql/)
3238
3339
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/)
40+
> [Integrate React with Node.js Restful Services](https://www.bezkoder.com/integrate-react-express-same-server-port/)
3541
36-
> [Integrate Angular with Node.js Restful Services](https://bezkoder.com/integrate-angular-10-node-js/)
42+
> [Integrate Angular with Node.js Restful Services](https://www.bezkoder.com/integrate-angular-10-node-js/)
3743
38-
> [Integrate Vue with Node.js Restful Services](https://bezkoder.com/serve-vue-app-express/)
44+
> [Integrate Vue with Node.js Restful Services](https://www.bezkoder.com/serve-vue-app-express/)
3945
4046
## Project setup
4147
```

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)