Socket
Socket
Sign inDemoInstall

koa-json-mock-server

Package Overview
Dependencies
244
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    koa-json-mock-server

[![npm version](https://badge.fury.io/js/koa-json-mock-server.svg)](https://badge.fury.io/js/koa-json-mock-server) ![npm](https://img.shields.io/npm/dy/koa-json-mock-server)


Version published
Weekly downloads
59
increased by18%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

npm version npm

Example of: https://www.npmjs.com/package/koa-json-mock-server

To install

npm install

##Run

npm start

#Data

###db/user.json

[
  { "id"          : 1,
    "name"        : "User 1",
    "favourites"  : [
        { "title" : "Favorito 1",
          "url"   : "url1"
        },
        { "title" : "Favorito 2",
          "url"   : "url2"
        }, {
          "title" : "Favorito 3",
          "url"   : "url3"
        }, {
          "title" : "Favorito 4",
          "url"   : "url4"
        }, {
          "title" : "Favorito 5",
          "url"   : "url5"
        }
      ]
  }
]  

###db/bets.json

[
  {
    "id": 1,
    "date": "19/05/2015",
    "reference": "39594382",
    "description": "Single RUP 25.00",
    "min": "Doble Chance - 90 Mins: Atletico Madrid / Draw @1.50",
    "equipment": "Atletico Madrid - Real Madrid",
    "player": "",
    "match": "",
    "result": "Won",
    "comment": "25.00",
    "in": "37.50",
    "userId": 1
  }
]

##To use

//server.js
var koa = require('koa');
var Router = require('koa-router');
var jsonServer = require('koa-json-mock-server');
var jsonBody = require('koa-json-body');

const app = new koa()

var koaRouter = new Router();

app.use(jsonBody());
app.use(jsonServer(__dirname + '/db'));

koaRouter.get('/hello', function *(next) {
  this.body = 'Hello World!';
});

app.use(koaRouter.routes());

app.listen(3000);

###Url to test

####GET

####POST

Post method save only in memory

FAQs

Last updated on 18 Aug 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc