-
Notifications
You must be signed in to change notification settings - Fork 8
/
server.js
60 lines (47 loc) · 1.84 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
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var request = require('request');
var path = require('path');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
global.keys = require('./config/keys.js');
//Convert the Content
//For Production SDK
app.get('/js-sdk/:id', function(req, res) {
request('https://raw.githubusercontent.com/CloudBoost/JavaScriptSDK/master/dist/'+req.params.id, function (error, response, body) {
if (!error && response.statusCode == 200) {
res.header("content-type","text/javascript");
res.send(body);
}else{
res.status(404).send('Sorry, we cannot find the SDK. For more info, Please visit https://docs.cloudboost.io');
}
});
});
//For Developement SDK
app.get('/js-sdk-development/:id', function(req, res) {
request('https://raw.githubusercontent.com/CloudBoost/JavaScriptSDK/development/dist/'+req.params.id, function (error, response, body) {
if (!error && response.statusCode == 200) {
res.header("content-type","text/javascript");
res.send(body);
}else{
res.status(404).send('Sorry, we cannot find the SDK. For more info, Please visit https://docs.cloudboost.io');
}
});
});
//Convert the Content
/****************************************************************************************************/
//Routers
var routes = require('./routes/routes');
var twitterRoutes=require('./routes/twitterRoutes')();
//View engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes);
app.use('/', twitterRoutes);
//Ending
app.set('port', process.env.PORT || 1444);
var server = app.listen(app.get('port'), function() {
console.log("CBLanding started on PORT:"+app.get('port'));
});