Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

sails-cubejs-glue

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sails-cubejs-glue

a glue for cubejs to be used in sails's action

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Sails CubeJS Glue

npm version Coverage Status node npm bundle size

this package is intended to make a glue for cubejs and sails framework.

With this method, you can still use sails's functionalities like policy as it is.

Installation

to install is just straight forward:

  • with npm: npm i sails-cubejs-glue
  • with yarn: yarn add sails-cubejs-glue

Example Action

this is lazy method, that do everything one the action. (bootstrap and proxying).

Althought its better idea to use sails's hook for bootstrapping and action only proxying, this example is enough:

ON api/controllers/cube.js:

/* api/controllers/cube.js */

var glue = require('./sails-cubejs-glue');

var cubeApp = null;
const schemas = [
  {
    fileName: 'Orders.js',
    content: `
      cube('Orders', {
        sql: 'SELECT * FROM orders',
        measures: {
          countAll: {
            type: 'count'
          },
        }
      });
    `
  }
]


module.exports = async (req, res) => {
  if (cubeApp === null) cubeApp = await glue.bootstrap(schemas, {basePath: '/cube'});

  glue.createProxy(cubeApp)(req, res);
}

ON config/routes.js add the graphql route:

module.exports.routes = {
  ...
  '/cube/*': { action: 'cube' },
};

Connecting to Database

As cubejs's documentation: https://cube.dev/docs/connecting-to-the-database.

Example in environment variables:

CUBEJS_DB_TYPE=mongobi
CUBEJS_API_SECRET=123123
CUBEJS_DB_HOST=localhost
CUBEJS_DB_PORT=3307
CUBEJS_DB_USER=
CUBEJS_DB_PASS=
CUBEJS_DB_NAME=app

Drivers Dependencies

quoted from @cubejs-backend/server-core/core/index.js

const DriverDependencies = {
  postgres: '@cubejs-backend/postgres-driver',
  mysql: '@cubejs-backend/mysql-driver',
  mssql: '@cubejs-backend/mssql-driver',
  athena: '@cubejs-backend/athena-driver',
  jdbc: '@cubejs-backend/jdbc-driver',
  mongobi: '@cubejs-backend/mongobi-driver',
  bigquery: '@cubejs-backend/bigquery-driver',
  redshift: '@cubejs-backend/postgres-driver',
  clickhouse: '@cubejs-backend/clickhouse-driver',
  hive: '@cubejs-backend/hive-driver',
  snowflake: '@cubejs-backend/snowflake-driver',
  prestodb: '@cubejs-backend/prestodb-driver',
  oracle: '@cubejs-backend/oracle-driver',
};

License

MIT

Keywords

sails

FAQs

Package last updated on 30 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts