-
Notifications
You must be signed in to change notification settings - Fork 27
/
Web.js
48 lines (34 loc) · 1.18 KB
/
Web.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
var express = require('express'),
http = require('http'),
request = require('request'),
bodyParser = require('body-parser'),
app = express();
var logFmt = require("logfmt");
app.use(express.static(__dirname + '/client'));
app.set('view engine', 'ejs');
app.use(bodyParser.json());
app.set('port', process.env.PORT || 3002);
app.all('/proxy', function(req, res) {
var url = req.header('SFDCActualURL');
request({ url: url, method: req.method, json: req.body,
headers: {'Authorization': req.header('X-Authorization'), 'Content-Type' : 'application/json'}, body:req.body }).pipe(res);
});
var sfConfigs = {
clientId: process.env.clientId,
callbackUrl: process.env.redirectURL
};
app.get('/' , function(req,res) {
res.render('index.ejs', sfConfigs);
} );
app.get('/index*' , function(req,res) {
res.render('index.ejs', sfConfigs);
} );
app.get('/oauthcallback*' , function(req,res) {
res.sendfile('views/oauthcallback.html');
} );
app.get('/soql*' , function(req,res) {
res.sendfile('views/SOQLBuilder.html');
} );
app.listen(app.get('port'), function () {
console.log('Express server listening on port ' + app.get('port'));
});