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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wymp/weenie-base

v1.3.0

Published

This is the base package for Weenie, an unopinionated, fluent, traditional Typescript dependency injector.

Downloads

5

Readme

Weenie Base

Overview

This is the base package for the Weenie framework. See https://wymp.github.io/weenie for a more full-bodied explanation of the weenie framework itself.

Weenie is a Typescript microservices framework. (Sort of.)

It attempts to provide a much simpler and easier solution to building microservices than other frameworks such as NestJS. In reality, while Weenie is called a microservices framework, it is nothing more than an easy and elegant way to create a strongly-typed dependency injection container.

This package provides a very minimal set of tools geared toward building that container. It is centered around a small function, Weenie, that allows you to build the DI container from the ground up, declaratively including and exposing only the dependencies you want, rather than relying on a big and/or opinionated framework for everything.

(For the full Weenie Framework, see https://github.com/wymp/weenie-framework, which provides several pre-built dependencies such as mysql, rabbitMQ, and a configurator to get you up and running quickly.)

The function definition of Weenie is as follows:

declare function Weenie<Deps = Obj>(deps: Deps): Extensible<Deps>;
declare type Obj = Record<string | number | symbol, unknown>;

declare type Extensible<Deps = Obj> = Deps & {
  and: <NextDeps extends Obj>(next: (deps: Deps) => NextDeps) => Extensible<Deps & NextDeps>;
  done: <FinalDeps extends Obj | Promise<Obj>>(fin: (deps: Deps) => FinalDeps) => FinalDeps;
};

In human language, all this says is:

For any given object, the Weenie function returns a dependency injection container with two additional methods, and and done.

The and method takes a function, next, whose argument is the current DI container (or a subset of it, or nothing) and which returns an arbitrary new object. The and method returns a new DI container which is the combination of the current DI container, the new dependencies returned by the next function, and an updated set of and and done methods.

The done method takes a function, final, whose argument is the current DI container (or a subset of it, or nothing) and which returns an arbitrary final DI container (optionally through a promise). The done method returns the value returned by final. Note that this object does not have the and and done methods, since it is considered the final DI container.

See the main Weenie Webpage for more detailed examples and documentation.

Additional Exports

In addition to the core Weenie function, this library also exports a deepmerge function that it uses to perform object merging. This is simply for convenience for downstream libraries, since it seems deepmerge is an oft-wanted function. (It only implements a native deepmerge function to avoid a dependency, since Weenie is proudly dependency-free.)