-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
35 lines (30 loc) · 976 Bytes
/
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
require('dotenv').config();
const express = require('express');
const { join } = require('path');
const app = express();
const Cumulio = require('cumulio');
// Listen on port 3000
const dashboardId = 'e830af8d-bf1d-4918-963e-884b6c0fc569';
const client = new Cumulio({
api_key: process.env.CUMULIO_API_KEY,
api_token: process.env.CUMULIO_API_TOKEN
});
app.use(express.static(join(__dirname, 'public')));
app.get('/authorization', (req, res) => {
const options = {
type: 'temporary',
expiry: '1 day',
inactivity_interval: '30 minutes',
securables: [dashboardId]
};
if(req.query.city){
options.metadata = {city : [req.query.city]};
}
client.create('authorization', options).then((result) => {
return res.status(200).json(result);
});
});
app.get('/*', (req, res) => {
res.sendFile(join(__dirname, 'index.html'));
});
app.listen(3000, () => console.log('Application running on port 3000'));