Repalced body-parser for native express.json().
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
"dependencies": {
|
||||
"@babel/polyfill": "~7.2",
|
||||
"@zxing/library": "^0.15.2",
|
||||
"body-parser": "^1.19.0",
|
||||
"canvas-confetti": "^1.2.0",
|
||||
"chart.js": "^2.9.3",
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
|
||||
30
server.js
30
server.js
@@ -15,28 +15,32 @@ const subscriptionApi = require(path.join(__dirname + "/api/subscriptions"));
|
||||
const chat = require(path.join(__dirname + "/api/chat"))(io);
|
||||
const chatHistory = require(path.join(__dirname + "/api/chatHistory"));
|
||||
|
||||
const bodyParser = require("body-parser");
|
||||
|
||||
const mongoose = require("mongoose");
|
||||
const MongoStore = require("connect-mongo")(session);
|
||||
|
||||
// mongoose / database
|
||||
mongoose.promise = global.Promise;
|
||||
mongoose.connect("mongodb://localhost/vinlottis", {
|
||||
useCreateIndex: true,
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
serverSelectionTimeoutMS: 10000 // initial connection timeout
|
||||
}).then(_ => console.log("Mongodb connection established!"))
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
console.error("ERROR! Mongodb required to run.");
|
||||
process.exit(1);
|
||||
})
|
||||
mongoose.set("debug", process.env.NODE_ENV === "development");
|
||||
|
||||
// middleware
|
||||
const setupCORS = require(path.join(__dirname, "/middleware/setupCORS"));
|
||||
const setupHeaders = require(path.join(__dirname, "/middleware/setupHeaders"));
|
||||
app.use(setupCORS)
|
||||
app.use(setupHeaders)
|
||||
|
||||
app.use(cors());
|
||||
mongoose.promise = global.Promise;
|
||||
mongoose.connect("mongodb://localhost/vinlottis");
|
||||
mongoose.set("debug", true);
|
||||
|
||||
app.use(
|
||||
bodyParser.urlencoded({
|
||||
extended: true
|
||||
})
|
||||
);
|
||||
app.use(bodyParser.json());
|
||||
// parse application/json
|
||||
app.use(express.json());
|
||||
|
||||
app.use(
|
||||
session({
|
||||
|
||||
Reference in New Issue
Block a user