0.4.4 • Published 5 years ago

datasole v0.4.4

Weekly downloads
24
License
Apache-2.0
Repository
github
Last release
5 years ago

datasole

CircleCI Build Status DeepScan grade

Datasole, or data console, is a fast prototyping tool for realtime, full-stack Javascript web applications using Node and any reactive frontend Javascript framework. It works by maintaining a single shared data model (object) between a server process and multiple connected Websocket clients, as well as providing a thin RPC framework from client to server.

Datasole is based on (and abstracts; opinionates): Webpack, Express, and Websockets connections. It works well with frontend frameworks that support reacting to mutations on a shared data model, such as Vue, Angular, and React.

In development mode, Datasole allows full-stack applications to be interactively developed with the following features:

  • Hot Module Reloading (HMR) of the client SPA, via Webpack.
  • Application server (backend) restart on source file changes.
  • Asset bundling using an opinionated Webpack configuration.
  • Templating languages: Pug, HTML
  • Stylesheet languages: CSS, Sass (SCSS), LessCSS
  • Image formats (with optimizer): SVG, GIF, PNG, JPG, ICO
  • .vue single-file Vue.js components

The datasole build command runs the Webpack build in production mode to produce a static web distribution in the dist directory by default.

Install

npm install -g datasole

Datasole can also be used as a locally installed library by omitting the -g flag.

Workflow

Each command attempts sensible defaults. Help for each option: -h or --help

init

Start a new project by running datasole init in an empty directory.

dev

Start a development webserver: datasole dev

build

Build a production version of the frontend: datasole build

run

Serve a production version of the frontend: datasole run (requires datasole build first)

Settings

The following environment variables affect Datasole's behavior. No environment variables are required by default.

See lib/config/defaults.js for the full list of environment variables.

Required variables, with defaults:

Environment variableDefaultDescription
DISABLE_COLORSfalseStrip ANSI color codes from log messages.
DATASOLE_API_URL/api/v1URL path to forward to application as REST requests.
DATASOLE_API_TIMEOUT_SEC30Maximum number of seconds before timing out an HTTP request.
DATASOLE_LISTEN_ADDRESS0.0.0.0Local address to listen on (0.0.0.0 = all interfaces)
DATASOLE_LOG_FORMATtexttext or json
DATASOLE_LOG_LEVEL_APPinfoDatasole user application logging level.
DATASOLE_LOG_LEVEL_SYSinfoDatasole system runtime logging level.
DATASOLE_MODEproductionDatasole run mode: development or production
DATASOLE_PORT8000Port to listen on.
DATASOLE_STATIC_URL/Path to serve a fallback static distribution at.
DATASOLE_URL_ROOT_PATH/URL prefix for all paths, useful for path-based proxies.
DATASOLE_WEBSOCKET_URL__ws__Relative path to listen for Websocket connections.

Optional variables, enables specific features if set (default: not set):

Environment variableDescription
DATASOLE_LOG_OUTPUT_PATHDisk path to write logs to, or write to console if blank.
DATASOLE_STATIC_PATHFallback static distribution disk path to attempt before error page.
DATASOLE_BUILTIN_TEMPLATE_PATHOverride path containing Pug templates for built-in error pages.

URL Prefixes

All server URLs will be prefixed by DATASOLE_URL_ROOT_PATH. This is useful, e.g., behind a reverse proxy like nginx where different path prefixes map to different upstream backend servers, or behind cloud load balancers.

All other paths (e.g., DATASOLE_API_URL, DATASOLE_STATIC_URL)

Logging Level

The following logging levels are supported for DATASOLE_LOG_LEVEL_APP and DATASOLE_LOG_LEVEL_SYS:

  • trace (most verbose)
  • debug
  • info
  • warn
  • error
  • fatal (silent)

Static Fallback Distribution

If the SPA does not contain a particular URL, Datasole optionally falls back to a static web distribution on disk.

If the DATASOLE_STATIC_PATH variable is set, any files at that path will be served as static content.

Example projects

See the datasole-examples repository.

Package maintainer notes

  • Webpack is not in devDependencies because recursive devDependencies are not currently installed by npm, and Webpack is required for developing the client and server components of any project. In the future, Webpack and other large dev dependencies can be moved to devDependencies by requiring a global npm install of datasole for development.

Source Statistics

StatisticValue
Total lines of code4234
Source lines3153 (74%)
Comment lines600
Installed node_modules size202M