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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sdflc/backend-helpers

v1.0.112

Published

Set of helper functions and classes to simplify building backend apps within @sdflc ecosystem

Readme

Backend Helpers

This library has a variety of classes and functions to simplify building backend applications with the specific architecture within @sdflc ecosystem.

Classes

BaseCore

This is the class that should be extended when you create a new core class. This is where all the business logic should be happeninng when processing request.

Constructor

Here are the props to be passed to the BaseCore constructor:

  • db: Database - an object of Database class
  • context?: any - the request context where you can add all you need, optional
  • gateway?: any - main gateway class object that will be working with DB or 3rd part API
  • gateways?: any - an object
  • isProduction: boolean - true when the app is in production
  • logLevel: LoggerLevels - log leves: 0 - none, 1 - errors, 2 - warnings, 3 - messages, 4 - all
  • logger?: Logger - object of Logger class to be used as logger
  • name?: string - name of the core
  • requestId: string - Unique ID of a request processed, can be used for troubleshooting
  • doAuth: boolean - call authorize method or not an incoming request
  • doingWhat?: BaseCoreDoingWhatInterface - an object with text descriptions of each action, used to generate generic error message sent to user on an exception
  • validators?: BaseCoreValidatorsInterface - an object with validator functions to be used to validate incoming data
  • spaceGw?: BaseGateway - gateway to find a space, i.e. configration of the app. Each app can have several configurations to be used as one instance for different applications
  • interserviceApiKey?: string - API key to be used to authenticate incoming request from another microservice, optional
  • jwtSecret?: string - secret to be used to validate Authorize Bearer token on incoming request, optional
  • verifytokenArgs?: VerifyUserTokenArgs - optional parameters for JWT token validation, like algorithm, etc

getDb()

getRequestId()

getContext(key?: string)

getGateways()

success(data: any, code?: number): any

failure(code: number, errorMsg: string, data?: any)

validationFailure(ex: any): any

exceptionFailure(ex: any, doingWhat: string | any, data?: any)

checkResult(args: any)

runAction(opt: CoreActionInterface)

Default Actions

list(args: any)
get(args: any)
getMany(args: any)
create(args: any)
createMany(args: any)
update(args: any)
updateMany(args: any)
set(args: any)
remove(args: any)
removeMany(args: any)

Default Action related events

beforeList(params: any, opt?: BaseCoreActionsInterface): Promise
afterList(params: any, opt?: BaseCoreActionsInterface): Promise
beforeCreate(params: any, opt?: BaseCoreActionsInterface): Promise
afterCreate(params: any, opt?: BaseCoreActionsInterface): Promise
beforeCreateMany(params: any, opt?: BaseCoreActionsInterface): Promise
afterCreateMany(params: any, opt?: BaseCoreActionsInterface): Promise
beforeUpdate(params: any, opt?: BaseCoreActionsInterface): Promise
afterUpdate(params: any, opt?: BaseCoreActionsInterface): Promise
beforeUpdateMany(params: any, opt?: BaseCoreActionsInterface): Promise

afterUpdateMany(params: any, opt?: BaseCoreActionsInterface): Promise

beforeSet(params: any, opt?: BaseCoreActionsInterface): Promise
afterSet(params: any, opt?: BaseCoreActionsInterface): Promise
beforeRemove(params: any, opt?: BaseCoreActionsInterface): Promise
afterRemove(params: any, opt?: BaseCoreActionsInterface): Promise
beforeRemoveMany(params: any, opt?: BaseCoreActionsInterface): Promise
afterRemoveMany(params: any, opt?: BaseCoreActionsInterface): Promise
onException(params: any, opt?: BaseCoreActionsInterface): Promise

Authorization

authenticate(params: any, opt?: BaseCoreActionsInterface)

BaseGateway

This is the class that should be extended when you create a new gateway class. This is where your code works with database or 3rd party API or do some works of the lowest level. Gateways are used by the core classes to actually do the job to implement one or another business logic.

constructor(props: BaseGatewayInterface)

generateId(args?: any)

onListFilter(query: any, filterParams: any)

onUpdateFilter(query: any, filterParams: any)

onRemoveFilter(query: any, filterParams: any)

transformOnCreate(args: any)

transformOnUpdate(params: any, where?: any)

transformOnRemove(args?: any)

getDb()

getBuilder()

getIdField()

getCore()

setCore(core: BaseCore)

get(id: any)

getMany(ids: any[])

list(args?: ListArgsInterface)

create(args: any)

update(where: any, params: any)

updateMany(params: any): Promise<any[]>

increment(where: any, params: any)

decrement(where: any, params: any)

set(params: any): Promise<any[]>

remove(where: any, hardRemove = false)

buildDefaultGatewayProps = (args: any)

This function builds configuration object for a gateways inherited from the BaseGateway classs

BaseController

Base constroller class is used to create request handlers for RESTful API and provides some methods to simplify the task of working with requests and responses

json(method: any)

Application Context

createApiContext = async (args: ApiContextInterface)

createContextDefault = async (args: any)