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

division.js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

division.js

Central JS logic management module

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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.

FAQs

Package last updated on 27 Aug 2013

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