Coder Social home page Coder Social logo

kassette's Introduction

kassette

kassette-logo
kassette is a development server, used mainly for testing, which proxies requests and
is able to easily manage local mocks.

To use it:

  • install with npm install kassette
  • add this command to your package.json scripts: kassette -c kassette.config.js
  • and create the configuration file kassette.config.js:
exports.getConfiguration = () => {
  return {
    port: 4200,
    mocksFolder: './mocks-folder',
    remoteURL: 'http://127.0.0.1:3000',
    mode: 'local_or_download',

    hook: async ({mock}) => {
      if (!mock.request.pathname.startsWith('/api/')) {
        mock.setMode('remote');
        return;
      }

      mock.setLocalPath([
        mock.request.pathname.split('/').slice(1),
        mock.request.method,
      ]);
    }
  };
}

Now run your script to launch the proxy!

With this configuration, input requests targeting URLs starting with /api/ will get processed, and local mocks will be used if present, otherwise data will be downloaded from http://127.0.0.1:3000 with a forwarded request, persisted and used for future input requests.

Check Getting started to learn more.

Main features

  • optionally forward requests to a remote backend
  • record backend responses for later use
  • easily computed and set local mock path
  • fill response to client from backend response, downloaded or persisted
  • modify response to client manually
  • integrates nicely into your editor and source control: a simple hierarchy of files is generated in a clean way for inspection, edition, diffing, etc.

Installation

This is a Node.js project using npm for dependency management, so ensure you have those two properly installed. Node.js LTS onwards is supported.

With npm, you can install it in two locations:

  • locally inside your project and run it the usual way (using a npm script or accessing the path explicitly node_modules/.bin/kassette)
  • or install it globally and run it using the command kassette (not advised for self-contained projects)

Besides where it is installed, you have at least two ways to install it:

  • from the npm registry: package's name is kassette
  • from a git clone (see below)

Installing from a git clone

Clone this repository, and run npm link to install it globally on your computer.

If you want to use it globally only, then there is nothing more to do.

If you want to install it locally though, you need to add one more step. You won't be able to use a package.json dependency, but you can install it manually using npm link kassette from inside your project.

User documentation

It is advised to start with the Getting started article which describes a few practical usage examples, then check the reference for the configuration and the API.

Developing / Contributing

See developer guide for details.

kassette's People

Contributors

exflo avatar schuhmi2 avatar ymeine avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.