ysmood/nokit

A route DSL sugar middleware for noflow

ysmood opened this issue · 6 comments

Such as

let http = require('http');
let { route, flow } = kit.proxy;

route
  .get('/items', ctx => ctx.body = [1, 2, 3])
  .post('/upload', uploader)
  .error(errorHanlder)
.end();

http.createServer(flow(route)).listen(8080);

@magnus-

I prefer to apply the DSL as illustrated below:

// acquire an instance of verbalizer
var I = verbalizer();

// GET /getUserInfo
// method getUserInfo can injected within global scope
I.get.an.instance.of('UserInfo').by.method('getUserInfo')
    .with.arguments.schema('SchemaUser')
    .when.arguments.error('status 400').with.comment('input argument invalid')

The syntax of the verbalizer can be discussed later

A good point to start.

So what's your plan to implement it?

I’ll take several days to weave the syntax tree and to determinate words category. Besides, words for different purpose usage can be gathered into different categories, which you could reckon them as normal English grammatical categories something like conjunction or predicate.

And what matters most will be the customization of the injection and error handling.

The essentiality of the Verbalizer is to promote user with straightforward syntax-bound words to documentize their logic behavior.

Additionally, Verbalizer should stick to express or other middle-ware based frameworks as well. What do u think? @ysmood

For now, I don't have any better idea than yours. Looking forward to your code.