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

backend-plus

Package Overview
Dependencies
Maintainers
0
Versions
787
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backend-plus

Backend for the anti Pareto rule

  • 2.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
119
increased by27.96%
Maintainers
0
Weekly downloads
 
Created
Source

backend-plus

Backend for the anti Pareto rule.

stable npm-version downloads build coverage dependencies

language: English also available in: Spanish

It's a framework for developing web applications based on PostgreSQL database. It's main features are:

  1. It is based on centralized metadata that defines:
    1. The data structure (tables and views structure)
    2. The procedures structure (param definition, permissions, encoding)
    3. The menus structure
  2. It provides:
    1. Editable grids (orderable and filterable), with support for edit data using XLSX format files
    2. Login mechanism
    3. Menus
    4. Skins definition

API

table definitions

module definitions

client side definitions

Menus definition

menuTypeuse
menumenu or submenu
tablegrid or table
procprocedures
propertytypedefault valuemenuTypeuse
menuTypeTmenu Type
nameToption name (id)
menuContentAmenumenu content
tableTnametabletable name
labelTnameif you don't want to use default value to display in menu
selectedByDefaultBis the selected by default option
autoprocedBfalseprocif yo want to execute the procedure without clicking the proced button

Integrating example:

    getMenu(context){
        return {menu:[
            {menuType:'menu', name:'periodic table', menuContent:[
                {menuType:'table', name:'ptable'  , label:'elements'},
                {menuType:'table', name:'pgroups' , label:'groups'  },
                {menuType:'table', name:'isotopes', label:'isotopes'},
                {menuType:'proc' , name:'count_without_isotopes', label:'count'}
            ]},
            {menuType:'table', name:'images', table:'element_images'},
            {menuType:'menu', name:'test', menuContent:[
                {menuType:'table', name:'bigint'},
            ]},
            {menuType:'menu', name:'config', menuContent:[
                {name:'users', menuType:'table'},
            ]},
        ]}
    }

Procedures definition

procDef:
propertytypedefault valueuse
actionTName that will be invoked the procedure
bitacoraBO{ error:false, always:false }Bitacora Object for core functions register
parametersPOA[]Param Objects Array
cacheableBoolfalseThe result can be cached
coreFunctionFFunction that implements the procedure
bitacoraDef:
propiedadtipodefault valueuso
errorBfalseIf true, bitacora saves data of error ocurred during core function execution
alwaysBfalseIf true, bitacora saves all data ocurred during core function execution (overrides error)
targetTableTnullTablename for update result of execution data (must to exists a record for update) (see targetTableBitacoraFields). Use null for ignore option
targetTableBitacoraFieldsO{ init_date: 'init_date', end_date: 'end_date', has_error: 'has_error', end_status: 'end_status'}Objects who defines the fields where 'targetTable' will reply bitacora fields (If targetTable is null it's ommited)
targetTableUpdateFieldsConditionAnullFields array to define update condition (each value must to be passed as parameter with the same field name)
paramDef:
propertytypedefault valueuse
nameTname of the parameter that is sent to the procedure
defaultValuesegún typeNameparameter default value
typeNameTto define the data type
labelTnameif you don't want to use default value to display on screen
coreFunction(context, parameters)
contextuso
bebackendApp object
usernameusername

Process definition example:

    {
        action:'count_without_isotopes',
        bitacora:{
                   error:true,
                   always:true,
                   targetTable:'other_table',
                   targetTableBitacoraFields: {
                                                init_date: 'fecha_hora_inicio',
                                                end_date: 'fecha_hora_final',
                                                has_error: 'hubo_error',
                                                end_status: 'resultado'
                                              },
                   targetTableUpdateFieldsCondition: ['id']
                 },
        parameters:[
            {name:'first_atomic_number', defaultValue:10, typeName:'integer'},
            {name:'last_atomic_number' , defaultValue:99, typeName:'integer'},
        ],
        coreFunction:function(context, parameters){
            return context.client.query(
                `SELECT count(*) as number_of_elements
                   FROM ptable p left join isotopes i on p.atomic_number=i.atomic_number
                   WHERE i.atomic_number IS NULL
                     AND p.atomic_number between coalesce($1,0) and coalesce($2,999)`,
                [parameters.first_atomic_number, parameters.last_atomic_number]
            ).fetchUniqueRow().then(function(result){
                return result.row.number_of_elements;
            });
        }
    },

def-config

/// def-config.ts
export defConfig=`
server:
  port: 3000
  base-url: /my-app
db:
  motor: postgresql
  host: localhost
  database: my_app_db
  user: my_app_user
install:
  dump:
    db:
      owner: my_app_owner
client-setup:
  title: My app
  lang: es
`;

/// main.ts
import {defConfig} from "./def-config"

export function emergeMyApp<T extends Constructor<AppBackend>>(Base:T){
    /// ...
    configStaticConfig(){
        super.configStaticConfig();
        this.setStaticConfig(defConfig);
    }
    ///...
}

The general application config is setted with setStaticConfig. Any option can be overwrited in local-config.yaml file.

BACKEND_PLUS_LOCAL_CONFIG enviroment variable can be a filename.yaml with more config options.

config format:

entryusage
server
.portport where is listening
.base-urlbase url added to domain name
.module-store
install(see Spanish)
.dump(see Spanish)
..db.owner(see Spanish)
..scripts.post-adapt(see Spanish)
..scripts.parts-order(see Spanish)
devel(see Spanish)
.delay(see Spanish)
.cache-content(see Spanish)
.forceShowAsEditable(see Spanish)
login(see Spanish)
.plus(see Spanish)
..allowHttpLogin(see Spanish)
log(see Spanish)
.req(see Spanish)
.session(see Spanish)
client-setup(see Spanish)
.cursors(see Spanish)
.skin(see Spanish)
.menu(see Spanish)
.title(see Spanish)
.lang(see Spanish)
install:
  dump:
    db:
      owner: user_owner
    scripts:
      post-adapt: [special_triggers.sql, other_constraints.sql]
login:
  plus:
    allowHttpLogin: true
    store:
      module-name: file
log:
  req: true
  session: true
devel:
  cache-content: true

Install

$ npm install backend-plus

License

MIT


FAQs

Package last updated on 23 Nov 2024

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