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

@micaiah_effiong/api-builder

v0.0.4-beta.0

Published

This package provides the core application setup for building scalable, robust Node.js APIs with Express. It encapsulates best practices for server initialization, middleware configuration, clustering, error handling, documentation, and static file servin

Readme

API Builder

This package provides the core application setup for building scalable, robust Node.js APIs with Express. It encapsulates best practices for server initialization, middleware configuration, clustering, error handling, documentation, and static file serving.

Features

  • Express Application Bootstrapping
    Easily set up an Express app with configurable middleware, static directories, error handlers, and API routers.

  • Clustering
    Scale your server across multiple CPU cores using Node.js clustering for improved performance and reliability.

  • OpenAPI Documentation
    Integrate Swagger UI for interactive API documentation and testing.

  • Customizable Middleware
    Add custom middleware, environment validators, and lifecycle hooks (initialization and shutdown).

  • Static File Serving
    Serve static assets from configurable directories.

  • Security and Logging
    Integrates helmet for HTTP header security and morgan for access logging.

Getting Started

Installation

Install via npm:

npm install @micaiah_effiong/api-builder

Usage

import { CreateApplicationService } from "@micaiah_effiong/api-builder";
import express from "express";

// Create your API router
const apiRouter = express.Router();
// ... define your routes

// Initialize the application service
const appService = new CreateApplicationService({
  docsPath: "/docs",
  clusterSize: "MAX", // Use all cores
  config: {
    cors: { origin: "*" },
    helmet: {},
  },
  docConfig: {
    /* Swagger UI options */
  },
})
  .addApi(apiRouter)
  .addStaticDir("public")
  .addEnvValidator((env) => {
    if (!env.PORT) throw new Error("PORT not defined");
  })
  .setInitializer(() => {
    // Custom startup logic
  })
  .setShutdown(() => {
    // Custom cleanup logic
  });

// Build and start the server
const appInstance = appService.build();
appInstance.start();

Options

  • docsPath: Path to serve API documentation.
  • docConfig: Swagger UI configuration options.
  • clusterSize: Number of worker processes (number or "MAX" for all cores).
  • config.cors: CORS options for Express.
  • config.helmet: Helmet configuration for security headers.

API Reference

CreateApplicationService<T>

Methods

  • .addApi(router: Router)
  • .addStaticDir(folderPath: string, options?: ServeStaticOptions)
  • .addMiddleware(middleware: NextFunction)
  • .addErrorRequestHandler(errorHandler: ErrorRequestHandler)
  • .addNotFoundHandler(notFoundHandler: RequestHandler)
  • .addEnvValidator(validator: (env: Required<NodeJS.ProcessEnv>) => void)
  • .setInitializer(fn: () => void)
  • .setShutdown(fn: () => void)
  • .build() → Returns an instance of CreateApplication

CreateApplication

Methods

  • .start() → Starts the server (clustered if configured)
  • .getContext() → Returns { app, server } for advanced usage

Environment Variables

  • PORT: Port number to run the server on (default: 3000)

Documentation

API documentation is auto-generated via OpenAPI and served at the path specified by docsPath (default: /docs).

Contributing

Contributions are welcome! Please open issues or submit pull requests to improve functionality, fix bugs, or update documentation.

License

MIT