How to use the @cubejs-backend/server-core.create function in @cubejs-backend/server-core

To help you get started, we’ve selected a few @cubejs-backend/server-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cube-js / cube.js / examples / express-analytics-dashboard / app.js View on Github external
// 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');
});
github cube-js / cube.js / examples / d3-dashboard / index.js View on Github external
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}`);
github cube-js / cube.js / packages / cubejs-server / index.js View on Github external
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;
  }
github cube-js / cube.js / examples / real-time-dashboard / index.js View on Github external
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);

@cubejs-backend/server-core

Cube.js base component to wire all backend components together

Apache-2.0
Latest version published 2 days ago

Package Health Score

89 / 100
Full package analysis