-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
48 lines (40 loc) · 1.3 KB
/
main.js
File metadata and controls
48 lines (40 loc) · 1.3 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
const express = require('express');
const cors = require('cors');
const path = require("path");
const swaggerUi = require('swagger-ui-express');
const swaggerJSDoc = require('swagger-jsdoc');
const reveal = require('./reveal');
const revealDom = require('./revealdom');
const app = express();
const port = 5111;
// Middleware
app.use(cors());
app.use("/images/png", express.static("images/png"));
app.use("/images/svg", express.static("images/svg"));
app.use(express.static(path.join(__dirname)));
// Swagger setup
const swaggerOptions = {
definition: {
openapi: '3.0.0',
info: {
title: 'Reveal BI API',
version: '1.0.0',
description: 'API for interacting with Reveal BI dashboards',
},
},
apis: ['./revealdom.js'],
};
const swaggerDocs = swaggerJSDoc(swaggerOptions);
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocs));
app.get('/swagger.json', (req, res) => {
res.setHeader('Content-Type', 'application/json');
res.send(swaggerDocs);
});
// Use the routes from revealDom.js
revealDom(app);
// Use the Reveal SDK middleware
app.use("/", reveal);
// Start the server
app.listen(port, () => {
console.log(`Reveal server accepting http requests on port ${port}`);
});