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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@igniter-js/core

v0.3.40

Published

A modern, type-safe, and flexible HTTP framework for building scalable APIs with TypeScript

Readme

@igniter-js/core

NPM Version License: MIT Build Status

The core package for the Igniter.js framework. It contains the essential building blocks for creating type-safe, modern TypeScript applications.

Role in the Ecosystem

This package is the heart of the Igniter.js framework. It provides all the fundamental tools you need to build a robust and scalable API, including:

  • The Igniter Builder: A fluent API for composing your application's features.
  • Action Factories: igniter.query() and igniter.mutation() to define your API endpoints.
  • Controller Factory: igniter.controller() to group related actions.
  • Procedure Factory: igniter.procedure() for creating reusable, type-safe middleware.
  • The Router: igniter.router() to assemble all your controllers into a single, executable API handler.
  • Core Interfaces: All the essential TypeScript types and interfaces that power the framework's end-to-end type safety.

Installation

You can install the core package using your favorite package manager:

# npm
npm install @igniter-js/core

# yarn
yarn add @igniter-js/core

# pnpm
pnpm add @igniter-js/core

# bun
bun add @igniter-js/core

While @igniter-js/core has no required production dependencies, you will likely install zod for schema validation, as it is tightly integrated with the framework's type system.

npm install zod

Basic Usage

Here is a minimal example of how to create a complete Igniter.js application using only the core package.

1. Define the Context (src/igniter.context.ts)

Define the shape of your application's global context. This is where you'll provide dependencies like a database connection.

// src/igniter.context.ts
export interface AppContext {
  // In a real app, this would be a database client instance.
  db: {
    findUsers: () => Promise<{ id: number; name: string }[]>;
  };
}

2. Initialize the Igniter Builder (src/igniter.ts)

Create the main igniter instance, telling it about your AppContext.

// src/igniter.ts
import { Igniter } from '@igniter-js/core';
import type { AppContext } from './igniter.context';

export const igniter = Igniter.context<AppContext>().create();

3. Create a Controller (src/features/user/user.controller.ts)

Define your API endpoints using igniter.controller() and igniter.query().

// src/features/user/user.controller.ts
import { igniter } from '@/igniter';

export const userController = igniter.controller({
  path: '/users',
  actions: {
    list: igniter.query({
      path: '/',
      handler: async ({ context, response }) => {
        const users = await context.db.findUsers();
        return response.success({ users });
      },
    }),
  },
});

4. Assemble the Router (src/igniter.router.ts)

Register your controller with the main application router.

// src/igniter.router.ts
import { igniter } from '@/igniter';
import { userController } from '@/features/user/user.controller';

export const AppRouter = igniter.router({
  controllers: {
    users: userController,
  },
});

5. Create an HTTP Server

Finally, use the AppRouter.handler to serve HTTP requests. The handler is framework-agnostic and works with any server that supports the standard Request and Response objects.

// src/server.ts
import { AppRouter } from './igniter.router';
import { createServer } from 'http';

// A simple example with Node.js http server
// In a real app, you would use a framework adapter (e.g., Next.js, Hono)
createServer(async (req, res) => {
  const request = new Request(`http://${req.headers.host}${req.url}`, {
    method: req.method,
    headers: req.headers,
    // body handling would be more complex
  });

  const response = await AppRouter.handler(request);

  res.statusCode = response.status;
  for (const [key, value] of response.headers.entries()) {
    res.setHeader(key, value);
  }
  res.end(await response.text());
}).listen(3000, () => {
  console.log('Server running on http://localhost:3000');
});

For more detailed guides and advanced concepts, please refer to the Official Igniter.js Wiki.

Contributing

Contributions are welcome! Please see the main CONTRIBUTING.md file for details on how to get started.

License

This package is licensed under the MIT License.