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

@sukhdevth./ts-mockit

v1.0.1

Published

Generates a realistic mock API straight from your TypeScript types

Readme

ts-mockit

The types you already wrote, turned into a working mock API.

npm version zero config license


Introduction

You already write TypeScript interfaces. ts-mockit reads them and spins up a real local API returning realistic fake date that matches your types exactly - no manual JSON, no hand-roplled mock server, no waiting on the backend.

npx @sukhdevth./ts-mockit ./types/User.ts
export interface User {
    id: string;
    name: string;
    email: string;
    age: number;
}
mockit server running at http://localhost:4000
 
GET  /user        → 20 fake users
GET  /user/0      → one fake user

That's it!! Your frontend now has a real endpoint to build against, today.

How it works

ts-mockit uses the TypeScript compiler itself to stastically read your file - the same way tsc does - and walks the actual type graph, not a regex or a guess. Every interface, nested object, array, enum and unions gets reduced to a shape then handed to a data generator that produces realistic values based on both the type and the field name.

interface User {
    id: string;
    email: string;
    age: number;
    role: "admin" | "editor" | "viewer";
}
// ****
{
    "id" : "b21e11d7-ddb0-44ec-ac93-c5e1a4d5ce4a",
    "email": "[email protected]",
    "age": 34,
    "role": "editor" 
}

Features

Field-aware generation - a string field named email gets a real-looking email not random words. age gets a sane range. price gets a realistic decimal. The generator reads intent from your field names not just their types.

Full-recursive support - nested objects, array of objects, enums, unions, and dates are all walked correctly, however deep they go.

interface Post {
    role: "admin" | "editor" | "viewer";
    address: { street: string; city: string };
    comments: Comment[];

    // all resolved correctly - nested objects stay objs
    // arrays stay arrays, enum pick a real member
}

Resolves import across files - if yur type import another type from a different file, ts-mockit follows it automatically, because it uses the real TypeScript type checker, not a single file parser.

import { Address } from "./address";

export interface User {
    homeAddress: Address; // resolved correctly, from anywhere in your project
}

Stable data per session - data is generated one when the server starts and cached, so your frontend isnt fighting new random values every refres.

Zero config, zero setup - one command, one file, no config file to write :3

Usage

npx @sukhdevth./ts-mockit <file> [options]

| Option | Description | Default | |---|---|---| | -p, --port <number> | Port to run the server on | 4000 | | -c, --count <number> | Fake records generated per type | 20

every exported interface or type in the file become its own route, named after the type(lowercased):

GET /<type>          → all fake records
GET /<type>/:index   → one record by index

Why not just write JSON by yourself?

You already do the type design work once, In typescript, ts-mockit reads that instead of asking you to describe your data twice once in code, once in a mock file that drifts out of sync with the real types.

License

MIT