-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (36 loc) · 1.39 KB
/
index.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
const express = require('express');
const httpProxy = require('http-proxy');
var apiProxy = httpProxy.createProxyServer();
var reservationsServer = 'http://18.188.235.153',
detailsServer = 'http://18.221.218.103',
photosServer = 'http://3.14.5.145';
const morgan = require('morgan');
const bodyParser = require('body-parser');
const path = require('path');
const app = express();
const port = 3003;
app.use(morgan('tiny'));
app.use(bodyParser());
app.use('/:listingID', express.static(path.resolve(__dirname, './public/dist/')));
app.all("/api/listings/photos/:listingID", function(req, res) {
apiProxy.web(req, res, {target: photosServer});
});
app.all("/api/listings/photos/initial/:listingID", function(req, res) {
apiProxy.web(req, res, {target: photosServer});
});
app.all("/listing/:listingID", function(req, res) {
apiProxy.web(req, res, {target: reservationsServer});
});
app.all("/custom/month", function(req, res) {
apiProxy.web(req, res, {target: reservationsServer});
});
app.all("/reserved/month", function(req, res) {
apiProxy.web(req, res, {target: reservationsServer});
});
app.all("/listing/desc/:listingID", function(req, res) {
apiProxy.web(req, res, {target: detailsServer});
});
app.all("/listing/amenity/:listingID", function(req, res) {
apiProxy.web(req, res, {target: detailsServer});
});
app.listen(port, () => console.log(`Listening on port ${port}!`));