-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (25 loc) · 713 Bytes
/
index.js
File metadata and controls
30 lines (25 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const express = require("express");
const mongoose = require("mongoose"); // new
const cors = require("cors");
const ImageUploadRouter = require("./route/uploadImageRoute");
//defining mongoose options
const options = {
useNewUrlParser: true,
useFindAndModify: false,
useCreateIndex: true,
useUnifiedTopology: true,
};
const app = express();
//adding the middlewares
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors());
app.use("/api", ImageUploadRouter);
// Connect to MongoDB database
mongoose
.connect("mongodb://localhost:07017(express.server)", options)
.then(() => {
app.listen(5000, () => {
console.log("Server has started!");
});
});