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

@modhub/kin-mock-server

v1.2.3

Published

A lightweight, flexible mock server for frontend development with easy API mocking capabilities

Readme

KIN Mock Server

A lightweight, flexible mock server for frontend development with easy API mocking capabilities.

Overview

KIN Mock Server is a development tool that allows you to create and manage mock APIs for frontend development. It provides a simple way to define API endpoints and their responses, making it ideal for developing frontend applications without depending on a real backend.

Features

  • 🚀 Easy Setup: Quick initialization with a CLI tool
  • 🔄 Live Reloading: Changes to mock files are reflected immediately
  • 🎮 API Documentation: Auto-generated documentation for all endpoints
  • ⏱️ Configurable Delays: Simulate network latency for realistic testing
  • 🧩 TypeScript Support: Full TypeScript support for type safety
  • 🔌 Flexible Integration: Works with any frontend framework (React, Angular, etc.)

Installation

Global Installation

npm install -g @modhub/kin-mock-server

Project Installation

npm install --save-dev @modhub/kin-mock-server

Quick Start

Initialize a New Project

npx kin-mock-server-cli init my-mock-api
cd my-mock-api
npm install
npm start

Project Structure

After initialization, your project will have the following structure:

my-mock-api/
├── mock-fn/
│   └── example.mock.ts
├── routes.ts
├── package.json
└── tsconfig.json

Usage

Define Routes

Edit the routes.ts file to define your API endpoints:

import { createMockServer, type ApiDef } from '@modhub/kin-mock-server';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const routes: ApiDef = {
  users: {
    urlPattern: '/api/users',
    mockFnPath: './mock-fn/users.mock.ts',
    delay: 200,
    disabled: false
  },
  // Add more routes as needed
};

export const mockServer = createMockServer(routes, __dirname).start({ port: 3000 });

Create Mock Responses

Create a mock file in the mock-fn directory:

// mock-fn/users.mock.ts
import { MockFn } from '@modhub/kin-mock-server';

export const mockFn: MockFn<any, { data: any[] }> = (req) => ({
  data: [
    { id: 1, name: 'John Doe', email: '[email protected]' },
    { id: 2, name: 'Jane Smith', email: '[email protected]' }
  ]
});

Access Your Mock API

Once started, your mock server will be available at http://localhost:3000.

  • View API documentation: http://localhost:3000/
  • Access endpoints: http://localhost:3000/api/users

Advanced Usage

Request Parameters

Access request parameters in your mock functions:

export const mockFn: MockFn<any, { data: any }> = (req) => {
  const userId = req.params.id;
  
  return {
    data: { id: userId, name: 'John Doe' }
  };
};

Conditional Responses

Create dynamic responses based on request data:

export const mockFn: MockFn<any, { data: any }> = (req) => {
  if (req.query.error === 'true') {
    return new Error('Custom error message');
  }
  
  return {
    data: { success: true }
  };
};

Using with Frontend Frameworks

Examples for integrating with various frontend frameworks are available in the examples directory.

Configuration

Server Options

createMockServer(routes, __dirname).start({ 
  port: 4000,  // Custom port (default: 3000)
  host: '0.0.0.0'  // Custom host (default: localhost)
});

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

ISC