This repository was archived by the owner on Jul 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·65 lines (60 loc) · 2.27 KB
/
Copy pathapp.js
File metadata and controls
executable file
·65 lines (60 loc) · 2.27 KB
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
61
62
63
64
65
/**
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
*/
var express = require('express');
var cors = require('cors');
var app = express();
app.use(cors());
app.options('*', cors());
var bodyParser = require('body-parser');
var jsonParser = bodyParser.json();
var config = require('./api/config/config');
var request = require('request');
if(process.env.DEBUG && process.env.DEBUG=='http'){
require('request-debug')(request);
}
var https = require('http');
var querystring = require('querystring');
var CreateAccountClient = require('./api/CreateAccountClient');
var CDTermsClient = require('./api/CDTermsClient');
var oauth = require('./api/oauth');
var oauthOptions = {
tokenURL: config.BASE_URI + '/oauth2/token',
// The clientId and clientSecret you received when registering your app.
clientID: config.CLIENT_ID,
clientSecret: config.CLIENT_SECRET
};
var ClientOptions = {
// The URL of the Credit Offers environment you are connecting to.
url: config.BASE_URI,
apiVersion: 2
};
var PORT = process.env.PORT || 8001;
app.use(express.static(__dirname + '/public'));
app.use(bodyParser.json());
app.post("/deposits/account-applications", function(req, res, next) {
var customerInfo = req.body;
var client = new CreateAccountClient(ClientOptions, oauth(oauthOptions));
client.createAccount(customerInfo, function (err, response) {
if (err) { return next(err) }
res.json(response);
})
});
app.get("/deposits/account-products/3500", function(req, res, next) {
var client = new CDTermsClient(ClientOptions, oauth(oauthOptions));
client.getCDTerms(function (err, response) {
if (err) { return next(err) }
res.json(response);
})
});
app.listen(PORT, 'localhost', function() {
console.log('express server listening on port', PORT);
});