-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (21 loc) 路 792 Bytes
/
Copy pathserver.js
File metadata and controls
28 lines (21 loc) 路 792 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
const express = require("express");
const logger = require("morgan");
const bodyParser = require("body-parser");
const mongoose = require("mongoose");
const cors = require("cors");
const routes = require("./routes");
const app = express();
const PORT = process.env.PORT || 3001;
const MONGOD_URI = 'mongodb://apprx:apprxdrugs1@ds153775.mlab.com:53775/heroku_w2cm2s4j';
app.use(logger("dev"));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(cors());
if (process.env.NODE_ENV === "production") {
app.use(express.static("client/build"));
}
app.use(routes);
mongoose.connect(MONGOD_URI, { useUnifiedTopology: true, useNewUrlParser: true });
app.listen(PORT, function() {
console.log(`馃寧 ==> API Server now listening on PORT ${PORT}!`);
});