Giter VIP home page Giter VIP logo

peasy-js's Introduction

peasy-js

A business logic micro-framework for javascript

Write your business logic once and consume from everywhere!

What's a business logic micro-framework?

A business logic framework is code that facilitates creating business logic in a consistent, predictable, reusable, extensible, maintainable, scalable, and testable manner. It promotes creating business logic that is completely decoupled from its consuming technologies and helps to ensure that separation of concerns (SoC) are adhered to.

Why peasy-js?

Because the javascript ecosystem changes at a pace much more rapid than your business logic. UI frameworks change: Backbone one day, Angular the next day, React the following... Backend frameworks change: Express one day, Koa the next day, Hapi the next... Data frameworks and ORMS change...

Why couple your code with technologies that are hot today and gone tomorrow? Why not focus on your business logic and abstract out everything else into truly reusable code that can be consumed by javascript in the browser, backend, or both, and by any UI or backend framework?

peasy-js makes it trivial to whimsically swap out UI, backend, and data frameworks in your applications by creating your business logic in a composable, reusable, scalable, and testable manner.

peasy-js offers/addresses the following:

Where can I get it?

  • Download the latest release
  • Clone the repo: git clone https://github.com/peasy/peasy-js.git
  • Install with npm: npm install peasy-js
  • Install with yarn: yarn add peasy-js

You can also download and add the peasy.js file to your project and reference it accordingly.

Getting started

You can get started by reviewing the walk throughs below.

  • Run it in a client (browser)

  • Run it on a server (Node.js)

  • Run it with TypeScript (Node.js)

  • Sample application: This sample application is an order entry / inventory management system written with peasy-js, react, angular (with TypeScript), mongoDB, nodejs, and express.

  • An additional sample can be viewed using promises or using callbacks that showcases creating a business service, custom command, business rules, and wiring them up. The sample also showcases how to consume the service. To see it in action, run one or both from a command line:

    • node src/sampleWithPromises.js
    • node src/sampleWithCallbacks.js

The main actors

Business Service

A business service implementation represents an entity (e.g. users, or projects) and is responsible for exposing business functionality via commands. These commands encapsulate CRUD and other business related logic.

Command

The command is responsible for orchestrating the execution of initialization logic, business and validation rule execution, and other logic (data proxy invocations, workflow logic, etc.), respectively, via the command execution pipeline.

Rule

A rule can be created to represent a business rule (authorization, price validity, etc.) or a validation rule (field length, required, etc.). Rules are consumed by commands and can be chained, configured to execute based on a previous rule’s execution, etc. Rules can also be configured to invoke code based on the result of their execution.

Data Proxy

The data proxy is responsible for data storage and retrieval, and serves as an abstraction layer for data stores (database, web services, cache, etc.).

peasy-js actors at work

What's new in version 2.0?

You can see all changes introduced with peasy-js 2.0 here.

Contributing

All contributions are welcome, from general framework improvements to sample client consumers, proxy implementations, and documentation updates. Want to get involved? Please hit us up with your ideas. Alternatively, you can make a pull request and we'll get to it ASAP.

Like what you see?

Please consider showing your support by starring the project.

peasy-js's People

Contributors

ahanusa avatar gitter-badger avatar jandritsch avatar jpiontek avatar svzieg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

peasy-js's Issues

Build process

Create a build process to take all modules and inject them into peasyjs.js

Add license

To make others more comfortable with using and extending this library, I would recommend adding a license so that people can know how exactly the code can be used.

Add IfInvalidThenValidate Functionallity

Hey,

Currently I have the case, I need to build some "OR" Functionality.
So I have two conditions, lets say:

PersonIsYoungEnoughRule => person.age < 27 and the rule
PersonIsStudent => person.job === student.

Now I want to build a rule by concatenating the conditions by an OR. So the command would check a rule like:

PersonIsYoungEnoughOrStudentRule = PersonIsYoungEnoughRule.ifInvalidthenValidate(PersonIsStudent)

Of course I could create that rule manuell or performing two Checks, but I also need that functionality in deeply interleaved rules. Such as:

If ((A and (B or C)) or (D and A) or (B and C)) ... then ...

which makes the conversions process a bit more tricky.
Therefore it would be nice if Peasy-JS, which already handles the AND-Connectors by the 'ifValidThenValidate' functionality, could also handle that case.

Best Regards
Sven

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.