-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
27 lines (20 loc) · 698 Bytes
/
Copy pathapp.js
File metadata and controls
27 lines (20 loc) · 698 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
const express = require('express');
const bodyParse = require('body-parser');
const mongoose = require('mongoose');
const apiRouter = require('./routers/apiRouter');
let app = express();
app.use(bodyParse.urlencoded({ extended: false }));
app.use(bodyParse.json());
app.use("/api", apiRouter);
app.get("/", function (req, res) {
res.send("");
});
const port = 6969;
mongoose.connect("mongodb://localhost:27017/xxx", {useNewUrlParser: true}, function (err) {
if (err) console.log(err)
else console.log("DB connect success!");
});
app.listen(port, function (err) {
if (err) console.log(err)
else console.log(`Server is listening at ${port}`);
});