vigour-state-json-server
v3.0.0
Published
Simple json server for state objects
Downloads
9
Maintainers
Readme
vigour-state-json-server
const createServer = require('vigour-state-json-server')
const s = require('vigour-state/s')
const state = s({ hello: 'world' })
const http = require('http')
// state, port, queuing-interval, filter
const server = createServer(
state,
8080,
100,
// filters response
(prop) => prop.key !== 'secrect'
)
//example request
http.request({
host: 'localhost',
port: 8080
}, (res) => {
var data = ''
res.on('data', (chunk) => { data += chunk })
res.on('end', () => {
console.log(JSON.parse(data)) // → { hello: 'world' }
})
}).end()