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

lupine.api

v1.1.79

Published

lupine.api is a fast, lightweight, and flexible node.js based server, working with lupine.web to provide SSR and modern JavaScript features for web applications and APIs.

Downloads

2,542

Readme

lupine.api

lupine.api is a fast, lightweight, and flexible node.js based server framework. It is designed to work seamlessly with lupine.web to provide Server-Side Rendering (SSR) and modern API capabilities.

The project consists of two main parts:

  1. Server (src/app): A robust HTTP/HTTPS server that manages multiple applications, domains, and processes.
  2. API Module (src/api): A framework for building the backend logic for individual applications.

Server (src/app)

The server component is responsible for handling incoming network requests, managing SSL certificates, and dispatching requests to the appropriate application based on domain configuration. It supports clustering logic to utilize multi-core CPUs efficiently.

Key Features

  • Multi-App & Multi-Domain: Host multiple independent applications on a single server instance, routing traffic based on domain names.
  • Cluster Support: Automatically forks worker processes to match CPU cores for high performance.
  • SSL/TLS: Built-in support for HTTPS with custom certificate paths.
  • Environment Management: Loads configuration from .env files.

Usage Example

See apps/server/src/index.ts for a complete example.

import { appStart, loadEnv, ServerEnvKeys } from 'lupine.api';
import * as path from 'path';

const initAndStartServer = async () => {
  // 1. Load Environment Variables
  await loadEnv('.env');

  // 2. Configure Applications
  const serverRootPath = path.resolve(process.env[ServerEnvKeys.SERVER_ROOT_PATH]!);
  const webRootMap = [
    {
      appName: 'demo.app',
      hosts: ['localhost', 'example.com'],
      // Standard directory structure expected by lupine.api
      webPath: path.join(serverRootPath, 'demo.app_web'),
      dataPath: path.join(serverRootPath, 'demo.app_data'),
      apiPath: path.join(serverRootPath, 'demo.app_api'),
      dbType: 'sqlite',
      dbConfig: { filename: 'sqlite3.db' },
    },
  ];

  // 3. Start Server
  await appStart.start({
    debug: process.env.NODE_ENV === 'development',
    apiConfig: {
      serverRoot: serverRootPath,
      webHostMap: webRootMap,
    },
    serverConfig: {
      httpPort: 8080,
      httpsPort: 8443,
      // sslKeyPath: '...',
      // sslCrtPath: '...',
    },
  });
};

initAndStartServer();

API Module (src/api)

The API Module provides the framework for writing the business logic of your application. It acts similarly to Express.js but is optimized for the lupine ecosystem.

Key Features

  • ApiRouter: A flexible router supporting GET, POST, and middleware-like filters.
  • Context Isolation: Uses AsyncStorage to safely manage request-scoped data (like sessions or database transactions) across async operations.
  • Database Integration: Built-in helpers for database connections (e.g., SQLite via better-sqlite3).

Usage Example

An application's API entry point (e.g., apps/demo.app/api/src/index.ts) typically exports an instance of ApiModule.

1. Entry Point (index.ts):

import { ApiModule } from 'lupine.api';
import { RootApi } from './service/root-api';

// Export apiModule so the server can load it dynamically
export const apiModule = new ApiModule(new RootApi());

2. Root API Service (service/root-api.ts):

import { ApiRouter, IApiBase, IApiRouter } from 'lupine.api';

export class RootApi implements IApiBase {
  getRouter(): IApiRouter {
    const router = new ApiRouter();

    // Define routes
    router.get('/hello', async (req, res) => {
      res.write(JSON.stringify({ message: 'Hello World' }));
      res.end();
      return true; // Return true to indicate request was handled
    });

    // Sub-routers can be mounted
    // router.use('/users', new UserApi().getRouter());

    return router;
  }
}

Dashboard

lupine.api includes a built-in extensible dashboard for managing your services. Detailed documentation can be found in README-dashboard.md.