-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
62 lines (54 loc) · 1.29 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
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
const axios = require('axios');
const dotenv = require('dotenv');
const express = require('express');
const cors = require('cors');
dotenv.config()
const data = JSON.stringify({
"action": "create",
"version": "0.1.0",
"key": process.env.CUMUL_KEY,
"token": process.env.CUMUL_TOKEN,
"properties": {
"integration_id": process.env.INTEGRATION_ID,
"type": "sso",
"expiry": "24 hours",
"inactivity_interval": "10 minutes",
"username": process.env.USER_USERNAME,
"name": process.env.USER_NAME,
"email": process.env.USER_EMAIL,
"suborganization": process.env.USER_SUBORGANIZATION,
"role": "viewer"
}
});
var config = {
method: 'post',
url: `${process.env.API_URL || 'https://api.cumul.io'}/0.1.0/authorization`,
headers: {
'Content-Type': 'application/json'
},
data : data
};
const app = express();
app.use(cors());
const port = 4001;
app.get('/', (req, res) => {
axios(config)
.then(function (response) {
const resp = {
status: 'success',
key: response.data.id,
token: response.data.token
};
res.json(resp);
})
.catch(function (error) {
const resp = {
status: 'failed',
error
};
res.json(resp);
});
});
app.listen(port, () => {
console.log(`CUMUL Server app listening on port ${port}`)
});