Skip to content

Commit 1235352

Browse files
committed
update new sequelize and pg version
1 parent 3162f04 commit 1235352

File tree

3 files changed

+37
-19
lines changed

3 files changed

+37
-19
lines changed

README.md

+24-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Node.js PostgreSQL CRUD example with Express Rest APIs
22

33
Full Article with implementation:
4-
> [Node.js PostgreSQL CRUD example with Express Rest APIs](https://bezkoder.com/node-express-sequelize-postgresql/)
4+
> [Node.js PostgreSQL CRUD example with Express Rest APIs](https://www.bezkoder.com/node-express-sequelize-postgresql/)
55
66
We will build Rest Apis that can create, retrieve, update, delete and find Tutorials by title.
77

@@ -97,28 +97,41 @@ Now there are no rows in `tutorials` table:
9797
```
9898

9999
For more detail, please visit:
100-
> [Node.js PostgreSQL CRUD example with Express Rest APIs](https://bezkoder.com/node-express-sequelize-postgresql/)
100+
> [Node.js PostgreSQL CRUD example with Express Rest APIs](https://www.bezkoder.com/node-express-sequelize-postgresql/)
101101
102-
> [Node.js Express Pagination with PostgreSQL example](https://bezkoder.com/node-js-pagination-postgresql/)
102+
> [Node.js Express Pagination with PostgreSQL example](https://www.bezkoder.com/node-js-pagination-postgresql/)
103103
104104
Security:
105-
> [Node.js JWT Authentication & Authorization with PostgreSQL example](https://bezkoder.com/node-js-jwt-authentication-postgresql/)
105+
> [Node.js JWT Authentication & Authorization with PostgreSQL example](https://www.bezkoder.com/node-js-jwt-authentication-postgresql/)
106106
107107
Associations:
108-
> [Sequelize Associations: One-to-Many Relationship example](https://bezkoder.com/sequelize-associate-one-to-many/)
108+
> [Sequelize Associations: One-to-Many Relationship example](https://www.bezkoder.com/sequelize-associate-one-to-many/)
109109
110-
> [Sequelize Associations: Many-to-Many Relationship example](https://bezkoder.com/sequelize-associate-many-to-many/)
110+
> [Sequelize Associations: Many-to-Many Relationship example](https://www.bezkoder.com/sequelize-associate-many-to-many/)
111111
112112
Fullstack:
113-
> [Vue + Node.js + Express + PostgreSQL example](https://bezkoder.com/vue-node-express-postgresql/)
113+
> [Vue + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/vue-node-express-postgresql/)
114114
115-
> [React + Node.js + Express + PostgreSQL example](https://bezkoder.com/react-node-express-postgresql/)
115+
> [React + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/react-node-express-postgresql/)
116116
117-
> [ANgular 8 + Node.js + Express + PostgreSQL example](https://bezkoder.com/angular-node-express-postgresql/)
117+
> [Angular 8 + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/angular-node-express-postgresql/)
118118
119-
> [ANgular 10 + Node.js + Express + PostgreSQL example](https://bezkoder.com/angular-10-node-express-postgresql/)
119+
> [Angular 10 + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/angular-10-node-express-postgresql/)
120120
121-
> [ANgular 11 + Node.js + Express + PostgreSQL example](https://bezkoder.com/angular-11-node-js-express-postgresql/)
121+
> [Angular 11 + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/angular-11-node-js-express-postgresql/)
122+
123+
> [Angular 12 + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/angular-12-node-js-express-postgresql/)
124+
125+
> [Angular 13 + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/angular-13-node-js-express-postgresql/)
126+
127+
> [Angular 14 + Node.js + Express + PostgreSQL example](https://www.bezkoder.com/angular-14-node-js-express-postgresql/)
128+
129+
Integration (run back-end & front-end on same server/port):
130+
> [Integrate React with Node.js Restful Services](https://www.bezkoder.com/integrate-react-express-same-server-port/)
131+
132+
> [Integrate Angular with Node.js Restful Services](https://www.bezkoder.com/integrate-angular-12-node-js/)
133+
134+
> [Integrate Vue with Node.js Restful Services](https://www.bezkoder.com/serve-vue-app-express/)
122135
123136
## Project setup
124137
```

package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
"author": "bezkoder",
1818
"license": "ISC",
1919
"dependencies": {
20-
"body-parser": "^1.19.0",
2120
"cors": "^2.8.5",
2221
"express": "^4.17.1",
23-
"pg": "^7.17.1",
24-
"pg-hstore": "^2.3.3",
25-
"sequelize": "^5.21.3"
22+
"pg": "^8.7.3",
23+
"pg-hstore": "^2.3.4",
24+
"sequelize": "^6.21.1"
2625
}
2726
}

server.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const express = require("express");
2-
const bodyParser = require("body-parser");
32
const cors = require("cors");
43

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

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

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

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

0 commit comments

Comments
 (0)