0.5.2 • Published 5 years ago
stubon v0.5.2
Stubon
stubon is simple dummy api server.
0. install
$ npm i -D stubon
1. 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 --ssl
3. Call a dummy API.
$ open https://localhost:8080/aaa/get
If 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.js
0.5.2
5 years ago
0.5.1
5 years ago
0.5.0
5 years ago
0.4.0
6 years ago
0.3.6
6 years ago
0.3.5
6 years ago
0.3.4
7 years ago
0.3.3
7 years ago
0.3.2
7 years ago
0.3.1
7 years ago
0.2.4
7 years ago
0.2.3
7 years ago
0.2.2
7 years ago
0.2.1
7 years ago
0.2.0
7 years ago
0.1.3
7 years ago
0.1.2
8 years ago
0.1.1
8 years ago
0.1.0
8 years ago
0.0.7
8 years ago
0.0.6
8 years ago
0.0.5
8 years ago
0.0.4
8 years ago
0.0.3
8 years ago
0.0.2
8 years ago
0.0.1
8 years ago