forked from R-N-D-M/CityDashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
66 lines (55 loc) · 1.73 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"use strict";
require('dotenv').config();
var path = require('path');
var express = require('express');
var webpack = require('webpack');
var webpackConfig = require('./webpack.config');
var webpackMiddleware = require('webpack-dev-middleware');
var webpackHot = require('webpack-hot-middleware');
var bodyParser = require('body-parser');
var compiler = webpack(webpackConfig);
// server files
var getBarsList = require('./server/bars.js');
var weather = require('./server/weather.js');
var nearby = require('./server/nearby.js');
var movies = require('./server/movies.js');
var bart = require('./server/bart.js');
var app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(webpackMiddleware(compiler, {
quiet: true,
noInfo: true,
stats: {
colors: true,
reasons: true
},
publicPath: webpackConfig.output.publicPath
}));
app.use(webpackHot(compiler));
app.use(express.static(path.join(__dirname, 'dist/')));
app.post('/bars', (request, response, next) => {
getBarsList(request.body.location, request.body.radius)
.then((barsList) => {
response.writehead(200);
response.write(barsList);
response.send();
});
});
app.post('/weather', (request, response)=> {
// console.log("POST request to /weather");
weather.getWeather(request, response);
});
app.post('/nearby', (request, response)=> {
console.log("POST request to /nearby");
nearby.getGoogleData(request, response);
});
app.post('/bart', (request, response)=> {
console.log("POST request to /bart");
bart.getListOfStations(request, response);
});
app.post('/movies', (request, response) => {
console.log('Post request to /movies')
movies.getMovies(request,response)
});
app.listen(process.env.PORT || 3000);