dash1291 / roamer

Mock a web service using ServiceWorkers
MIT License
3 stars 0 forks source link

just do node #4

Open amitu opened 8 years ago

amitu commented 8 years ago

No need to create your own API.

dash1291 commented 8 years ago

Thanks. Sounds like a god idea.

But, node (std http server or if you consider express) style is binding event listeners to callback functions. I wanted a rather simpler declarative style, where you do not even need to define methods/callbacks that return the response to their URL endpoints.

If I want to bind two url endpoints say, /url1, and /url2. Node style would be

Roamer.on('/url1/', function() { return 'response' }) Roamer.on('/url2/', function() { return 'response2' })

Current way of doing it is simpler -

Roamer.bind({ '/url1/': 'response', '/url2/': 'response2' })

If you're thinking of a more convenient way of doing it, let me know :)

amitu commented 8 years ago

What I was thinking was a drop in replacement of node api (as far as possible). Make express work(cool) instead of thinking about APIs(why another api?).

On Mon, Nov 2, 2015 at 1:22 PM Ashish Dubey notifications@github.com wrote:

Thanks. Sounds like a god idea.

But, node (std http server or if you consider express) style is binding event listeners to callback functions. I wanted a rather simpler declarative style, where you do not even need to define methods/callbacks that return the response to their URL endpoints.

If I want to bind two url endpoints say, /url1, and /url2. Node style would be

Roamer.on('/url1/', function() { return 'response' })
Roamer.on('/url2/', function() { return 'response2' })

Current way of doing it is simpler -

Roamer.bind({
'/url1/': 'response',
'/url2/': 'response2'
})

If you're thinking of a more convenient way of doing it, let me know :)

On Mon, Nov 2, 2015 at 12:58 PM, Amit Upadhyay notifications@github.com wrote:

No need to create your own API.

— Reply to this email directly or view it on GitHub https://github.com/dash1291/roamer/issues/4.

Ashish Dubey http://dash1291.github.io

— Reply to this email directly or view it on GitHub https://github.com/dash1291/roamer/issues/4#issuecomment-152945258.