3 ms·
Show HN: QEDServer: A standalone playground for JS and AJAX
- glhaynes 15y agoCool, thanks! Sorry to get off-topic, but this really spurred me to think of something somewhat similar that would be very useful to me personally: a generic "mock" server. A static call-responder, if you will. Rather than already having an API like this one does, it'd be one where a browser-side developer could specify on the server a list of static call/return pairs in a form similar to: for web service call c with parameters p[0] = 'abc', p[1] = 123, and any value for p[2], return string 'some JSON string'". That way one could easily have front-end folks working on browser-side code, making real web service calls and getting back real-looking results that are appropriate for this app. Later, as the real back-end progresses, the front-end can be repointed toward it. This would need to be setup-free enough that most front-end folks wouldn't have any trouble creating/maintaining sets of these. Perhaps best would be for it to be a public service so that the devs wouldn't even have to run their own server. Anybody know if anything like this exists?
- bphogan 15y agoHey. That was suggested to me by a good friend when I showed this to him. QEDServer's code is on Github... it's just a Sinatra app wrapped by jRuby. I could see a situation where we just have a config file and we just say "this route returns this string" or something. It wouldn't need to be anything fancy at all and probably wouldn't take terribly long to build. I wanted QEDServer to be zero-install, zero-setup because I do a lot of teaching with jQuery, etc. But this makes two people, plus me, who thinks that would be neat. Thanks for the feedback!
- js4all 15y agoYou can do what you are looking for with AppJet.jar. It has a built-in RESTful dispatcher. In your example you would write a JavaScript function like: function get_c() { if (request.params.p == '0') print 'abc'; if (request.params.p == '1') print '123'; if (request.params.p == '0') print ...; You can also respond to POST, PUT and DELETE request with put_c(), delete_c() and so on. It is a setup-free server in a jar with a persistent object store and many more tools. https://github.com/dvbportal/appjet https://github.com/dvbportal/appjet