stub-api-server
    TypeScript icon, indicating that this package has built-in type declarations

    0.6.12 • Public • Published

    ci codecov release

    stub-api-server

    This lib allows you to configure an HTTP server responding dynamic fake JSON.

    The common usecase is stubbing a REST API for Integration Tests.

    Introduction

    stub-api-server allow you to define an endpoint based on a simple object

    // routes/route.ts
    import { RouteConfig } from 'stub-api-server';
    
    const route: RouteConfig = {
      method: 'GET',
      path: '/hello',
      template: { message: 'Hello World' },
    };
    
    export default route;
    // index.ts
    import path from 'path';
    import { StubApiServer } from 'stub-api-server';
    
    const server = new StubApiServer();
    server.useRoutesFromDir(path.resolve('./routes'));
    server.start();
    ➜ ts-node index.ts
    Starting server on http://localhost:8000

    Keywords

    none

    Install

    npm i stub-api-server

    DownloadsWeekly Downloads

    1,148

    Version

    0.6.12

    License

    MIT

    Unpacked Size

    3.95 MB

    Total Files

    102

    Last publish

    Collaborators

    • jgiovaresco