contactlab / saray

:warning: This project is no longer mantained - 'Yet Another Rest API Stubber'.split(' ').reverse().map(item => item[0].toLowerCase()).join('')
Apache License 2.0
13 stars 7 forks source link

Using saray as a middleware #79

Open Slumber86 opened 7 years ago

Slumber86 commented 7 years ago

Is possible to user saray as a middleware for another node application like React HRM or BrowserSync?

Thanks

pferretti commented 7 years ago

To be true, I don't know if saray could be used as a middleware for another node application. Basically, everything in saray is a middleware, so I think that it would be possibile to use it as a middleware for another application.

Actually I see only a limitation to that: the main route ( https://github.com/contactlab/saray/blob/master/index.js#L191 ) is an anonymous function, so it cannot be used outside saray. Probably you can use saray as a middleware in another nodejs app extracting this function and exporting it. You can try and submit a PR if it works!