-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
36 lines (27 loc) · 1.1 KB
/
index.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
'use strict';
const bodyParser = require('body-parser');
const express = require('express');
const poalim = require('./poalimapi');
const subscriptionKey = process.env.SUBSCRIPTION_KEY;
const clientId = process.env.CLIENT_ID;
const client_secret = process.env.CLIENT_SECRET;
const google_map_key = process.env.GOOGLE_KEY;
var app = express();
app.set('port', process.env.PORT || 5000);
app.set('view engine', 'ejs');
app.use(express.static('public'));
app.get('/getBranchInfo', async function(req, res) {
console.log('got request for: ' + JSON.stringify(req.query));
console.log('bank: ' + req.query.bank_id + ', branch: ' + req.query.branch_id);
var access_token = await poalim.auth();
var branch_info = await poalim.getBranchInfo(access_token, req.query.bank_id, req.query.branch_id)
res.render('branchinfo', {
branchName: branch_info.branchName,
googleMapKey: google_map_key,
latitude: branch_info.latitude,
longitude: branch_info.longitude
});
});
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});