0.5.2 • Published 7 years ago
stubon v0.5.2
Stubon
stubon is simple dummy api server.
0. install
$ npm i -D stubon1. Make source file by JSON or YAML or both.
When "http request" includes all condition that written under "request", value returned that under correspond "response.body". Sample is here.
// ./dev/src/dummy.yml
'/aaa/get':
-
request:
method: 'GET'
response:
status: 200
body:
result: 'OK!'2. Create server.
2.1 The way to make with a file.
var Stubon = require('stubon').default; // = import Stubon from 'stubon';
var srcPath = './dev/src';
var stubon = new Stubon(srcPath, {
debug : true,
ssl : true,
});
stubon.server().listen(8080);2.2 The way to make with a command line.
$ $(npm bin)/stubon -p 8080 -s ./dev/src --debug --ssl3. Call a dummy API.
$ open https://localhost:8080/aaa/getIf you call API from node script, you need setting option 'agent'. When you call from browser, you can do permission setting on the browser side.
// call_api.js
fetch('https://localhost:8080/aaa/get', {
agent : new https.Agent({ rejectUnauthorized : false }),
})
.then(function(res) {
return res.json();
})
.then(function(json) {
console.log(json.result); // OK!
});$ node call_api.js0.5.2
7 years ago
0.5.1
7 years ago
0.5.0
7 years ago
0.4.0
8 years ago
0.3.6
8 years ago
0.3.5
8 years ago
0.3.4
9 years ago
0.3.3
9 years ago
0.3.2
9 years ago
0.3.1
9 years ago
0.2.4
9 years ago
0.2.3
9 years ago
0.2.2
9 years ago
0.2.1
9 years ago
0.2.0
9 years ago
0.1.3
9 years ago
0.1.2
10 years ago
0.1.1
10 years ago
0.1.0
10 years ago
0.0.7
10 years ago
0.0.6
10 years ago
0.0.5
10 years ago
0.0.4
10 years ago
0.0.3
10 years ago
0.0.2
10 years ago
0.0.1
10 years ago