Closed nicknovitski closed 11 years ago
Good points, especially on responder. Also I noticed I did something incredibly stupid and broke /language!
Okay, much nicer now. All the parametrized routes use responder just like they used to. The "index" routes could use responder also, but I wasn't sure if they should.
Building a CLI should now be rather easy (with the new JavaScript API). Feel free to submit a new pull request. :)
Currently, all it does is call fetch_card.
I'm hardly married to this specific presentation, it's just my first pass at a compact display of what info people would want. Is the Set/Rarity line needed? Is there anything missing? Maybe alternate templates could be used with command line options, like
--verbose
or something.Another thing I could add before merging is set requests, preferably using parameters, like
tutor -s
ortutor --set
. That's probably best handled with an option parsing library like https://github.com/substack/node-optimist. I mean, I realize that currently, out requests to gatherer aren't fully parametrized (ie, we can't search where set = "something" and name includes "word"), but I'm trying to think of what my ideal command line interface for getting card information would be. And maybe someday we'll have a real database to query from.Proper testing of a module like this required mocking. I used Sinon.js for that, and it turns out to be pretty easy to use. Which is great, because I have a philosophical imperative to write the tests for the gatherer and server modules in the same style!
Speaking of which, I changed the api for the gatherer module so that it expects an object with named properties, and the server module to turn express' request parameters into such an object.