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

horpax

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

horpax

Framework on top of express node.js. Designed for rapid application development

  • 0.8.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

HORPAX

Build Status Downloads Downloads NPM version

Core concepts

Framework on top of express node.js. Designed for rapid application development. It allows easy create CRUDs (create, read, update and delete) for any custom resource. They can be created even in runtime. It is very flexible in changing default behavior of any operations, allowing customization or giving access to raw express.js requests and responses. It has lot of pre made useful features like authorization.

Horpax

Instance of this class starts new node server. This is root object of application composition. It manages Stores and Resources


deprecated

Attribute

It is single attribute of model. Each of those: name, surname, age, bornData are attributes.

Attribute options
  • modelName - map model db key to attribute
  • allowFilter - property can be a filter in request query
  • filterName - map query param to attribute
  • allowBody - property can be in request body
  • bodyName - name property in body

AttributeType

Each attribute has some type like string, number, object. In our example name and surname are string attributeType. But age is number attributeType and bornDate is date.

Schema

Collection of attributes is Schema.

Model

It is object allowing communication with database. It need schema.

Action

It is single endpoint. For example when we want save user we use action post endpoint.

Controller

It is consist with related actions. Like we have user controller.

Adapter

In model we have different values. We may want to save them to different databases or do something different. Each target for source should have onw adapter. Adapter is responsible for converting value to aimed target. For example we have age which has AttributeType number. But it is possible that target database doesn't have number type and we need DatabaseNumberAdapter which will convert number to string and string to number.

Get started

  1. Create instance then start it
    const horpax = new Horpax();
    await horpax.start();
  1. Implement functionality
  • You can add inline controllers, actions ...
    const idAttribute = new Attribute("_id", { });
    const nameAttribute = new Attribute("name", { });

    const schema = new Schema();
    schema.addAttribute(idAttribute);
    schema.addAttribute(nameAttribute);

    const model = new Model("resources", Model.getStoreManager().getDefaultStore());
    model.setSchema(schema);

    const createAction = new CreateAction("resourceCreateAction");
    createAction.setModel(model);

    const controller = new Controller("manageResources", "/resources");
    controller.addAction(createAction);
    horpax.getControllerManager().addController(controller);
  • Create different components and pass Horpax instance
   export default class Resources {
     constructor(horpax) {
       const idAttribute = new Attribute("_id", { });
       const nameAttribute = new Attribute("name", { });
   
       const schema = new Schema();
       schema.addAttribute(idAttribute);
       schema.addAttribute(nameAttribute);
   
       const model = new Model("resources", Model.getStoreManager().getDefaultStore());
       model.setSchema(schema);
   
       const createAction = new CreateAction("resourceCreateAction");
       createAction.setModel(model);
   
       const controller = new Controller("manageResources", "/resources");
       controller.addAction(createAction);
       horpax.getControllerManager().addController(controller);
     }
   }

Debugger

Each element has debug module. For getting all debug info

DEBUG=horpax:* <command to run>

For specific debug, for example controller:

DEBUG=horpax:controller:* <command to run>

For specific controller

DEBUG=horpax:controller:<controller name> <command to run>

Keywords

FAQs

Package last updated on 16 Jul 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