npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

baselinejs

v10.0.0

Published

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

Downloads

131

Readme

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.