-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathserver.js
More file actions
29 lines (23 loc) · 956 Bytes
/
server.js
File metadata and controls
29 lines (23 loc) · 956 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
29
var express = require('express'),
bodyParser = require('body-parser'),
compression = require('compression'),
cors = require('cors'),
properties = require('./server/property-service'),
brokers = require('./server/broker-service'),
app = express();
app.set('port', process.env.PORT || 5000);
app.use(cors());
app.use(bodyParser.json());
app.use(compression());
app.use('/', express.static(__dirname + '/www'));
app.get('/properties', properties.findAll);
app.get('/properties/favorites', properties.getFavorites);
app.get('/properties/:id', properties.findById);
app.post('/properties/likes', properties.like);
app.post('/properties/favorites', properties.favorite);
app.delete('/properties/favorites/:id', properties.unfavorite);
app.get('/brokers', brokers.findAll);
app.get('/brokers/:id', brokers.findById);
app.listen(app.get('port'), function () {
console.log('Realty server listening on port ' + app.get('port'));
});