0.1.1 • Published 8 years ago

rest-io-router v0.1.1

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

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"

For simpler promised based client api checkout https://github.com/jjwtay/rest-io-client