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

division.js

v1.2.2

Published

Central JS logic management module

Downloads

6

Readme

division.js

division.js is just a small boilerplate to have a prototype project demonstrating a centrally managed data model and business logic between a nodejs server and Knockoutjs-based client(s).

Unfortunately there is no official way allowing you to define and manage and maintain data model, business logic functions and validation rules for both sides only at one place.

But this minimalist project gives you a way to achieve this easily with nodejs on the server-side and Knockoutjs on client-side.

No need for "double-entry bookkeeping" as for code/model management or use different syntax or format or tools to describe how you want to manage your data just because you are working on client or on server side.

Is this solution complex?

Quite the opposite. You will see how easy-to-use this project really is. :)

Scenario

A model is defined/managed by the server-side:

Model definition - server/model.js

This would be the "common understanding" of both sides as for the business processes. You can structure it as you want to to any depth/level.

It contains business logic functions, computed values, static attributes and validation rules. Everything you need.

The model is used to automatically generate mongoose schema and model objects via the mongoose-schemagen.

That library extends the model object with validation services as well, so server can store received objects directly to the DB with automated validation!

The defined model is available to the client(s) via simple REST call using connect-rest and funcsync.

REST services - server/restMaker.js

By retrieving this model (including functions, rules, etc.) via simple GET request,

Client mapping - www/js/shared.js

, the client is able to build up the complete structure using the same funcsync library as the server did and map it nicely and completely to Knockoutjs using the plugins Knockout-Parsley and knockout.mapper.js.

Just a few lines of code!

This way, the client can map it to the UI allowing the user to interact.

After a few seconds, if no validation issue or whatsoever comes up - the data is sent back to the server, where the server builds up a mongoose recodrd by the model generated at start-time. The record will be stored to the DB which functionality includes the validation as weel provided by the lib Vindication.js.