-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
54 lines (47 loc) · 1.74 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
/**
* Created by Zem on 2014-10-10.
*/
// set up ========================
var express = require('express');
var app = express();
var mongoose = require('mongoose');
var morgan = require('morgan');
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
var eworksService = require('./scrape/eworksservice');
var rapidkonsultService = require('./scrape/rapidkonsultservice');
var goditService = require('./scrape/goditservice');
var gabertpartnersService = require('./scrape/gabertpartnersservice');
var keymanService = require('./scrape/keymanservice');
// configuration =================
mongoose.connect('mongodb://fmf:fmfadmin@linus.mongohq.com:10000/findmyfriend');
app.use(express.static(__dirname + '/public'));
app.use(morgan('dev'));
app.use(bodyParser.urlencoded({'extended':'true'}));
app.use(bodyParser.json());
app.use(bodyParser.json({ type: 'application/vnd.api+json' }));
app.use(methodOverride());
app.set('port', (process.env.PORT || 5000));
// Start server ======================================
app.listen(app.get('port'), function() {
console.log("Node app is running at localhost:" + app.get('port'))
});
app.get('/scrape', function(req, res){
var type = req.param('type');
if(type == 'ework') {
eworksService.scrapeEworks(req, res);
}
else if(type == 'rapidkonsult'){
rapidkonsultService.scrapeRapidkonsult(req, res);
}else if(type == 'godit'){
goditService.scrapegodit(req, res);
}
else if(type == 'gabertpartners'){
gabertpartnersService.scrapegabertpartners(req,res);
}else if(type == 'keyman'){
keymanService.scrapekeyman(req, res);
}
});
app.get('*', function(req, res) {
res.sendfile(__dirname +'/public/index.html');
});