Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

baselinejs

Package Overview
Dependencies
Maintainers
4
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baselinejs

Share code and data between the client and the server in full stack JavaScript applications.

  • 7.0.2
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-37.5%
Maintainers
4
Weekly downloads
 
Created
Source

baseline.js

basline.js is a small library that organizes application logic and data in node.js web applications into interdependent services that can be used both on the client and the server. It provides a small, simple, in-memory data store to organize and access data on the client. The same in-memory database and logic can also be used on the server side.

A baseline object may be initialized both on the server and on the client. On the server, a baseline object is initialized on a per request basis. For example, in an express.js app,

var baseline = require( 'baseline' );

app.use( function( req, res, cb ) {
	req.baseline = new Baseline( {
		rt : new ContactsService( { collectionName : 'contacts' } )
	} );
} );

On the client, a single baseline object is initialized and attached to the window object.

window.Wikkem.baseline = new Baseline( {
	rt : new ContactsService(),
} );

Anatomy

A baseline instance is made up of services. A service is a module that contains application logic and potentially accessors for in-memory data that is operated on by that logic. Services may depend on each other.

Collection services

collectionServices contain the application logic and the means to access in-memory data that is a subset of the data in a database collection or table.

When used on the client side, collectionServices are very similar to backbone.js collections, with a few key differences:

  • collectionServices are the preferred place to put application logic that operates on the data in the collection, whereas backbone collection classes generally do not serve that purpose.
  • While there may exist multiple backbone collections of the same type of object, there is always only one service (just like there is aways only one database table).
  • While backbone collections contain models that wrap the underlying data, collectionServices provide access to the underlying data only through per-field getters and setters. Objects are referenced by their id, instead of with pointers to models. This approach allows baseline to reliably keep track of changes.

Bootstrapping data from the server to the client

The process of bootstrapping data from the client to the server is streamlined using steamer.

To

app.use( function( req, res, cb ) {
	req.baseline = new Baseline( {
		rt : new ContactsService( { collectionName : 'contacts' } )
	} );

	req.bootstrapBoat = req.baseline.createBoat();
	steamer.stuffMiddleware( 'bootstrapBoat' )( req, res, cb );
} );

THIS DOCUMENTATION IS A WORK IN PROGRESS. If you want to see more, please star the repo.

FAQs

Package last updated on 24 Jan 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc