mirror of
https://github.com/yusufipk/RememberMe.git
synced 2026-09-11 10:56:07 +00:00
created(tests) created tests for person route
This commit is contained in:
@@ -2,14 +2,24 @@ const express = require("express");
|
||||
const mongoose = require("mongoose");
|
||||
const app = express();
|
||||
|
||||
mongoose
|
||||
.connect(`mongodb://localhost:27017/rememberme`, {
|
||||
useUnifiedTopology: true,
|
||||
useNewUrlParser: true,
|
||||
useCreateIndex: true,
|
||||
})
|
||||
.then(() => console.log("Connected to MongoDB..."))
|
||||
.catch((err) => console.log("Could not connect to MongoDB", err));
|
||||
if (process.env.NODE_ENV === "test") {
|
||||
mongoose
|
||||
.connect("mongodb://localhost:27017/remembermetest", {
|
||||
useUnifiedTopology: true,
|
||||
useNewUrlParser: true,
|
||||
useCreateIndex: true,
|
||||
})
|
||||
.then(() => console.log("Connected to MongoDB test..."));
|
||||
} else {
|
||||
mongoose
|
||||
.connect(`mongodb://localhost:27017/rememberme`, {
|
||||
useUnifiedTopology: true,
|
||||
useNewUrlParser: true,
|
||||
useCreateIndex: true,
|
||||
})
|
||||
.then(() => console.log("Connected to MongoDB..."))
|
||||
.catch((err) => console.log("Could not connect to MongoDB", err));
|
||||
}
|
||||
|
||||
const people = require("./routes/person");
|
||||
|
||||
@@ -17,4 +27,8 @@ app.use(express.json());
|
||||
app.use("/api/person", people);
|
||||
|
||||
const port = process.env.port || 3002;
|
||||
app.listen(port, () => console.log(`Listening on port ${port}...`));
|
||||
const server = app.listen(port, () =>
|
||||
console.log(`Listening on port ${port}...`)
|
||||
);
|
||||
|
||||
module.exports = server;
|
||||
|
||||
Reference in New Issue
Block a user