Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');
app.locals.cubejsApiToken = process.env.CUBEJS_API_TOKEN;
app.locals.cubejsApiUrl = process.env.CUBEJS_API_URL;
app.use(cors());
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', indexRouter);
CubejsServerCore.create().initApp(app);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
next(createError(404));
});
// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500);
res.render('error');
});
const CubejsServerCore = require('@cubejs-backend/server-core');
const express = require('express');
const bodyParser = require("body-parser");
const path = require("path");
const http = require("http");
const serveStatic = require('serve-static');
require('dotenv').config();
var app = express();
app.use(bodyParser.json({ limit: "50mb" }));
const cubejsServer = CubejsServerCore.create();
if (process.env.NODE_ENV === 'production') {
app.use(serveStatic(path.join(__dirname, 'dashboard-app/build')));
}
app.get('/healthy', (req, res) => {
res.json({ status: 'ok' });
});
cubejsServer.initApp(app);
const port = process.env.PORT || 4000;
const server = http.createServer({}, app);
server.listen(port, () => {
console.log(`🚀 Cube.js server is listening on ${port}`);
constructor(config) {
config = config || {};
config.webSockets = config.webSockets || (process.env.CUBEJS_WEB_SOCKETS === 'true');
this.core = CubejsServerCore.create(config);
this.webSockets = config.webSockets;
this.redirector = null;
this.server = null;
}
const WebSocketServer = require('@cubejs-backend/server/WebSocketServer');
const express = require('express');
const bodyParser = require("body-parser");
const http = require("http");
const path = require("path");
const MongoClient = require('mongodb').MongoClient;
const serveStatic = require('serve-static');
const moment = require('moment');
require('dotenv').config();
var app = express();
app.use(require("cors")());
app.use(bodyParser.json({ limit: "50mb" }));
const cubejsServer = CubejsServerCore.create({
orchestratorOptions: {
queryCacheOptions: {
refreshKeyRenewalThreshold: 1,
}
}
});
if (process.env.NODE_ENV === 'production') {
app.use(serveStatic(path.join(__dirname, 'dashboard-app/build')));
}
cubejsServer.initApp(app);
const server = http.createServer({}, app);
const socketServer = new WebSocketServer(cubejsServer, { processSubscriptionsInterval: 1 });
socketServer.initServer(server);