forked from WDSIGreenTaxi/GreenTaxi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
30 lines (23 loc) · 769 Bytes
/
server.js
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
'use strict';
require('dotenv').config({ silent: true });
const express = require('express');
const logger = require('morgan');
const path = require('path');
const bodyParser = require('body-parser');
const app = express();
const PORT = process.argv[2] || process.env.PORT || 3000;
const loc = require('./models/location.js');
app.use(logger('dev'));
app.use(bodyParser.json());
app.get('/find_hist', (req, res) => {
res.json(require('./data.js'));
})
app.post('/location',
loc.getDistance,
loc.getWeatherData,
loc.prepareResponse,
(req, res) => {
res.json(res.data);
});
app.use(express.static(path.join(__dirname, 'dist')));
app.listen(PORT, () => console.warn(`Server here! Listening on port ${PORT}!`));