-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
23 lines (18 loc) · 748 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const logger = require('morgan');
const cors = require('cors');
const app = express();
const {userController,dataController} = require('./controllers');
mongoose.connect('mongodb://localhost:27017/weather',{ useNewUrlParser: true,useUnifiedTopology: true,});
app.use(bodyParser.urlencoded({extended:true}));
app.use(bodyParser.json());
app.use(logger('dev'));
app.use(cors());
app.use(express.static('./static/'));
app.use('/api/weather/',userController);
app.use('/api/weather/',dataController);
app.listen(process.env.PORT||8000,process.env.IP,()=>{
console.log(`Server listening on host localhost and on port 8000`);
});