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

fauxify

v1.0.2

Published

A lightweight library for mocking API endpoints and schemas

Readme

Fauxify

Fauxify is a lightweight JavaScript library for creating and testing mock API endpoints with schema-based input and output validation. It simplifies the process of creating and testing APIs by allowing developers to define endpoint behavior in a few lines of code.


Features

  • Schema-based Validation: Define and validate input/output schemas effortlessly.
  • Type Handling: Predefined and extensible types for fields, including custom validators and generators.
  • Mock API Endpoints: Simulate endpoints with configurable behavior.
  • Asynchronous Responses: Simulate network delays for realistic API behavior.
  • Nested Objects Support: Easily define and validate nested object structures.

Installation

Install the library via npm:

npm install fauxify

Getting Started

Importing Fauxify

import fauxify from 'fauxify';
import { types } from 'fauxify/types.js';

Usage

1. Define a Mock API Endpoint

Define a mock endpoint using fauxify.create. Specify the input schema, output schema, and the endpoint path.

fauxify.create('/signup', {
    email: types.email,
    password: types.string,
    profile: types.object({
        name: types.string,
        age: types.number,
        email: types.email
    })
}, {
    userId: types.uuid,
    message: types.success
});

2. Call the Mock API

Call the endpoint using fauxify.call. Provide payload data and handle success or error responses in a callback.

fauxify.call('/signup', {
    email: '[email protected]',
    password: 'password123',
    profile: {
        name: 'John Doe',
        age: 30,
        email: '[email protected]'
    }
}, (success, error) => {
    if (success) {
        console.log('Signup Success:', success);
    } else {
        console.error('Signup Error:', error.message);
    }
});

How It Works

Step 1: Define Input and Output Schemas

Fauxify uses predefined types to validate inputs and generate outputs. Each type has:

  • Type Validation: Ensures the payload adheres to the schema.
  • Value Generation: Generates default values for mocked responses.
const userProfileSchema = types.object({
    name: types.string,
    age: types.number,
    email: types.email
});

Step 2: Create Endpoints

Use fauxify.create(endpoint, inputSchema, outputSchema) to define a mock endpoint.

  • endpoint: Path of the mock API.
  • inputSchema: Expected structure for the request payload.
  • outputSchema: Defines the mock response structure.

Predefined Types

Fauxify provides built-in types for common use cases.

| Type | Validation | Auto-Generated Value | |----------|--------------------------------------------|----------------------------------| | string | Ensures value is a string | 'mock_string' | | number | Ensures value is a number | Random integer | | email | Validates email format | '[email protected]' | | uuid | Validates string (UUID) | Random UUID | | array | Ensures value is an array | [] | | object | Ensures value is a non-array object | {} | | success| Always valid (success message placeholder) | 'Operation successful' |


Example: Nested API Endpoints

Mock an endpoint to fetch a user profile:

const userProfileSchema = types.object({
    name: types.string,
    age: types.number,
    email: types.email
});

fauxify.create('/getProfile', {
    userId: types.uuid
}, {
    profile: userProfileSchema,
    message: types.success
});

fauxify.call('/getProfile', {
    userId: '550e8400-e29b-41d4-a716-446655440000'
}, (success, error) => {
    if (success) {
        console.log('Get Profile Success:', success);
    } else {
        console.error('Get Profile Error:', error.message);
    }
});

A complete example

import fauxify from 'fauxify';
import { types } from 'fauxify/types.js';

const userProfileSchema = types.object({
    name: types.string,
    age: types.number,
    email: types.email
});

fauxify.create('/signup', {
    email: types.email,
    password: types.string,
    profile: userProfileSchema
}, {
    userId: types.uuid,
    message: types.success
});

fauxify.create('/getProfile', {
    userId: types.uuid
}, {
    profile: userProfileSchema,
    message: types.success
});

fauxify.call('/signup', {
    email: '[email protected]',
    password: 'password123',
    profile: {
        name: 'John Doe',
        age: 30,
        email: '[email protected]'
    }
}, (success, error) => {
    if (success) {
        console.log('Signup Success:', success);
    } else {
        console.error('Signup Error:', error.message);
    }
});

fauxify.call('/getProfile', {
    userId: '550e8400-e29b-41d4-a716-446655440000'
}, (success, error) => {
    if (success) {
        console.log('Get Profile Success:', success);
    } else {
        console.error('Get Profile Error:', error.message);
    }
});

License

Fauxify is licensed under the MIT License.

Contact

For questions, feedback, or issues, contact [[email protected]].


Happy mocking! 🚀