rest-io-router
v0.1.1
Published
Share routes between socket and http requests
Downloads
2
Readme
rest-io-router
Shared routing for socket.io and http requests
Installation
With node [installed]:
$ npm install rest-io-router --save
Usage
routes.js
export default [
[ 'get', '/users', (req, res) => { res.send("hello world") }],
[ 'post', '/users', (req, res) => { res.send("post to users")}]
]
server.js
import routes from './routes'
import router from '/.rest-io-router'
...
router(routes, app, io)
client.js
io.emit('rest', {method: 'get', url: '/users'})
io.on('rest', (data) => console.log(data)
//console logs => "hello world"