|
|
|
@ -11,21 +11,21 @@ const PORT = 4000 |
|
|
|
app.use(cors()) |
|
|
|
app.use(cors()) |
|
|
|
app.use(bodyParser.json()) |
|
|
|
app.use(bodyParser.json()) |
|
|
|
|
|
|
|
|
|
|
|
app.listen(PORT, function () { |
|
|
|
app.listen(PORT, () => { |
|
|
|
console.log(`Server is running on Port: ${PORT}`) |
|
|
|
console.log(`Server is running on Port: ${PORT}`) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
mongoose.connect('mongodb://localhost:27017/todos?authSource=admin', { |
|
|
|
mongoose.connect('mongodb://localhost:27017/todos?authSource=admin', { |
|
|
|
useNewUrlParser: true, |
|
|
|
useNewUrlParser: true, |
|
|
|
useUnifiedTopology: true, |
|
|
|
useUnifiedTopology: true, |
|
|
|
user: "admin", |
|
|
|
user: "mongodbUser", |
|
|
|
pass: "admin" |
|
|
|
pass: "mongodbPass" |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const connection = mongoose.connection |
|
|
|
const connection = mongoose.connection |
|
|
|
|
|
|
|
|
|
|
|
connection.on('error', console.error.bind(console, 'connection error:')) |
|
|
|
connection.on('error', console.error.bind(console, 'connection error:')) |
|
|
|
connection.once('open', function () { |
|
|
|
connection.once('open', () => { |
|
|
|
console.log('Connected successfully to mongodb server') |
|
|
|
console.log('Connected successfully to mongodb server') |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|