Giter Site home page Giter Site logo

fidelman / mokker Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 5.0 511 KB

The mock does not mock you. The video: https://www.youtube.com/watch?v=gGLNJpC-Ov0

License: MIT License

JavaScript 100.00%
express node mock-server javascript mock server json json-api json-server json-server-mock

mokker's Introduction

Mokker

npm version

Mokker is a simple express RESTful API mock server, which also provides few methods to make your data emulating easier.

Installation

npm install --save-dev mokker
yarn add --dev mokker

Dependencies

  • body-parser
  • express
  • morgan
  • query-string
  • react-dev-utils

Usage

// server.js
const mokker = require('mokker');

const routes = [{
    method: 'get',
    url: '/api',
    json: { is: 'done' }
}];

mokker.start({ routes });
// done ๐Ÿ˜

$ node server.js

Docs

License

This project is licensed under MIT License. See the license file for more details.

mokker's People

Contributors

fidelman avatar opicacek avatar ronaldruzicka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mokker's Issues

Allow Access-Control-Allow-Headers by setting

@fidelman could you please add an option to set Access-Control-Allow-Headers from mokker.start or somewhere else?

Because I need another header x-on-behalf-of which you don't set in the start of the server and maybe there can be other headers later as well.

// hardcoded headers
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With, X-Redmine-API-Key');

Thanks!

Repository improvement

What

Sharing my thoughts and pieces of advice to improve this repository.

Why

Good repository - good library - good experience.

How

  • index.js@31 consider the scenario when the port provided to mokker is already in use. Express knows how to fallback to another port, make sure to print out the fallback port in case this happens.
  • routes.js@31 missing space. Right now it would produce: GETis (a) wrong method.
  • Isn't request a save dependency?
  • Export library in the supported format. Right now you are using arrow functions, which is a relatively new feature. This may cause your library to fail on old projects. Use bundle tools (webpack, rollup) to bundle the transformed library (see libraryTarget option in webpack and ES6 => ES2015).
  • Introduce minification to the built bundle. The tools mentioned above will help.
  • Do not use version 1.0.0 if it's not yet released (does not have stable API, etc.). A good place to start is 0.1.0. Make sure to read about Semantic versioning.

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.