stellar-deprecated / stex

DEPRECATED. An opinionated framework built on top of expressjs used to build better web services for stellar
Other
30 stars 11 forks source link

Promise-enabled REPL #11

Closed nullstyle closed 10 years ago

nullstyle commented 10 years ago

STORY

As a developer running in a stex console process, I want to be able to execute javascript that returns a promise which is then resolved before printing, so that I can have a more friendly asynchronous experience when using the REPL.

RATIONALE

Presently, the stex repl process is very bare-bones... simply using the built in node 'repl' module with no customization. Given that most of the useful code in node is asynchronous (and for stex, promise-based), the repl is quite hard to use because you pretty much end up having to write lines like: db("wallets").where("id", id).select().then(console.log)

This is a pain and slows down the explorative experience of a repl, IMO. It would nicer instead if we built a repl that saw the return value of a statement was a Promise, resolve it, then printout the value for the developer... essentially automating the .then(console.log) part.

lookis commented 10 years ago

I try to keep the modification as minimal as possible, so I just customise the repl and implement the .then(console.log) part, that keeps us to run other script as before. please have a review https://github.com/lookis/stex/commit/1a542c3f6a49394e10631fb0a465963f956da408