Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@101-ways/core

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

@101-ways/core

Accelerator core package.

latest
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

@101-ways/core

Base package for building accelerator packages. It uses the Service Registry pattern to create a single object with APIs.

Usage

import { load } from '@101-ways/core';

load([`${__dirname}/modules`]).then((sr) => {
  console.log('SERVICE REGISTRY', sr);
});

Basic example for creating a child package:

import { load as loadCore, type Registry } from '@101-ways/core';

export type { Registry };

export async function load<T extends Registry>(paths: string[] = [], sr?: T) {
  return loadCore([`${__dirname}/modules`, ...paths], sr);
}

Service Registry API

  • sr.config - configuration (see ./src/modules/config.ts)
  • sr.core - inherited from @borisovg/service-core package (see https://github.com/borisovg/node-service-core/blob/main/src/types.ts#L6)
  • sr.ctx - asynchronous context methods
    • sr.ctx.get() - get current context
    • sr.ctx.getTraceMeta() - get trace metadata from context in ECS format
    • sr.ctx.toTraceMeta(ctx) - as above but using provided context
    • sr.ctx.run(fn) - run a function with async context
  • sr.ecs - ECS schema methods
    • sr.ecs.makeEventFn() - returns a function that will in turn generate and ECS event object
  • sr.log - logger methods
    • sr.log.debug(params)
    • sr.log.error(params)
    • sr.log.info(params)
    • sr.log.trace(params)
    • sr.log.warn(params)
  • sr.uuid - UUID generation methods
    • sr.uuid.v4() - generate a UUIDv4 string

Environment Variables

FAQs

Package last updated on 30 Apr 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