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

@ez4/gateway

v0.42.0

Published

EZ4: Components to build gateway services

Readme

EZ4: Gateway

It uses the power of reflection to provide a contract that determines how to build and connect gateway components.

Getting started

Install

npm install @ez4/gateway @ez4/local-gateway @ez4/aws-gateway -D

Create gateway

// file: server.ts
import type { Environment, Service } from '@ez4/common';
import type { Http } from '@ez4/gateway';

// MyServer declaration
export declare class MyServer extends Http.Service {
  routes: [
    Http.UseRoute<{
      path: 'POST /post-route';
      handler: typeof routeHandler;
    }>
  ];
}

// MyServer route request
declare class MyRouteRequest implements Http.Request {
  body: {
    foo: string;
    bar: number;
  };
}

// MyServer route response
declare class MyRouteResponse implements Http.Response {
  status: 201;
  body: {
    baz: string;
  };
}

// MyServer route provider
interface MyRouteProvider extends Http.Provider {
  variables: {
    myVariable: Environment.Variable<'MY_VARIABLE'>;
  };

  services: {
    otherService: Environment.Service<OtherService>;
    variables: Environment.ServiceVariables;
  };
}

// MyServer route handler
export function routeHandler(request: Http.Incoming<MyRouteRequest>, context: Service.Context<MyRouteProvider>): MyRouteResponse {
  const { otherService, variables } = context;
  const { body } = request;

  // Access body contents
  body.foo;

  // Access injected services
  otherService.call();

  // Access injected variables
  variables.myVariable;

  return {
    status: 201,
    body: {
      baz: 'baz'
    }
  };
}

Gateway properties

Service

| Name | Type | Description | | --------- | ------------------ | ----------------------------------------------- | | routes | Http.UseRoute<> | All routes associated to the gateway. | | defaults | Http.UseDefaults<> | Default gateway parameters. | | cors | Http.UseCors<> | CORS configuration for all routes. | | cache | Http.UseCache<> | Cache configuration for authorizers. | | access | Http.UseAccess<> | Access configuration for logs. | | name | string | Display name for the service. | | variables | object | Environment variables associated to all routes. | | services | object | Injected services associated to all routes. |

Use type helpers for routes, defaults, cors, cache and access properties.

Routes

| Name | Type | Description | | ------------ | -------- | -------------------------------------------------------- | | name | string | Route operation name. | | path | string | Route path including the HTTP verb. | | listener | function | Life-cycle listener function for the route. | | handler | function | Entry-point handler function for the route. | | authorizer | function | Authorizer function for the route. | | httpErrors | object | Map status codes and errors for all known exceptions. | | variables | object | Environment variables associated to the route. | | logRetention | integer | Log retention (in days) for the handler. | | memory | integer | Memory available (in megabytes) for the handler. | | timeout | integer | Max execution time (in seconds) for the route. | | disabled | boolean | Determines whether or not the route is disabled. | | cors | boolean | Determines whether or not CORS is enabled for the route. |

Examples

Providers

License

MIT License