vv-httpgate
v0.1.8
Published
**MIT** ## Install ``` npm i vv-httpgate ``` ## Example See full example in directory /demo. Small example: ```typescript import { Create as CreateHttpGate } from 'vv-httpgate'
Downloads
5
Readme
For backend NodeJS. Simple lib for work with RestAPI and Server Side Event
License
MIT
Install
npm i vv-httpgate
Example
See full example in directory /demo. Small example:
import { Create as CreateHttpGate } from 'vv-httpgate'
const httpGate = CreateHttpGate({url: 'localhost:8080'})
httpGate.onError(error => console.error(error))
httpGate.onRequest(request => {
request.reply(200, `hello from api`)
})
httpGate.onServerEvent(event => {
event.reply(`hello from api`, (error, isOpened) => {
if (error) {
console.error(error)
}
})
event.onClose(() => {
console.log('event connection closed')
})
})
httpGate.start(addr => {
console.log(addr)
})