added DB connection verification
This commit is contained in:
parent
4fc1e81ba3
commit
5f7a0f0a99
1 changed files with 7 additions and 5 deletions
12
app.js
12
app.js
|
|
@ -2,11 +2,6 @@ const createError = require("http-errors");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const mongoose = require("mongoose");
|
const mongoose = require("mongoose");
|
||||||
require("dotenv").config();
|
|
||||||
|
|
||||||
mongoose.connect(
|
|
||||||
`mongodb+srv://${process.env.USER}:${process.env.PASS}@odin.eftl02o.mongodb.net/?retryWrites=true&w=majority`
|
|
||||||
);
|
|
||||||
|
|
||||||
const INDEX = require("./routes/index");
|
const INDEX = require("./routes/index");
|
||||||
const NEWMESSAGE = require("./routes/newMessage");
|
const NEWMESSAGE = require("./routes/newMessage");
|
||||||
|
|
@ -40,4 +35,11 @@ app.use(function (err, req, res, next) {
|
||||||
res.render("error");
|
res.render("error");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
await mongoose.connect(
|
||||||
|
`mongodb+srv://${process.env.USER}:${process.env.PASS}@odin.eftl02o.mongodb.net/?retryWrites=true&w=majority`
|
||||||
|
);
|
||||||
|
console.log("Connected to database!");
|
||||||
|
})();
|
||||||
|
|
||||||
module.exports = app;
|
module.exports = app;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue