Skip to content

Commit

Permalink
replaced joi with @hapi/joi. Added mongo connect options
Browse files Browse the repository at this point in the history
  • Loading branch information
berensjd committed Jun 13, 2019
1 parent 70d769b commit 6468b35
Show file tree
Hide file tree
Showing 5 changed files with 3,426 additions and 44 deletions.
5 changes: 4 additions & 1 deletion modals/game.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Joi = require("joi");
const Joi = require("@hapi/joi");
const mongoose = require("mongoose");
const gameSchema = new mongoose.Schema({
players: {
Expand Down Expand Up @@ -27,6 +27,9 @@ const gameSchema = new mongoose.Schema({
type: Array
}
});

//mongoose.set("useFindAndModify", false);

const Game = mongoose.model("game", gameSchema);
function validatePlayers(players) {
const schema = {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@
"author": "Jonathan Berens",
"license": "MIT",
"dependencies": {
"@hapi/joi": "^15.0.3",
"compression": "^1.7.4",
"config": "^3.1.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"express-async-errors": "^3.1.1",
"helmet": "^3.18.0",
"joi": "^14.3.1",
"joi-objectid": "^2.0.0",
"lodash": "^4.17.11",
"mongoose": "^5.5.11",
"winston": "^3.2.1"
},
"devDependencies": {
"@types/jest": "^24.0.13",
"jest": "^24.8.0",
"supertest": "^4.0.2"
},
"scripts": {
Expand Down
8 changes: 7 additions & 1 deletion startup/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ const mongoose = require("mongoose");
const config = require("config");
module.exports = function() {
const db = config.get("db");
mongoose.connect(db).then(() => winston.info(`Connected to ${db}...`));
mongoose
.connect(db, {
useNewUrlParser: true,
useFindAndModify: false,
useCreateIndex: true
})
.then(() => winston.info(`Connected to ${db}...`));
};
2 changes: 1 addition & 1 deletion startup/validation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Joi = require("joi");
const Joi = require("@hapi/joi");
module.exports = function() {
Joi.objectId = require("joi-objectid")(Joi);
};
Loading

0 comments on commit 6468b35

Please sign in to comment.