nokit icon indicating copy to clipboard operation
nokit copied to clipboard

A route DSL sugar middleware for noflow

Open ysmood opened this issue 9 years ago • 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-

ysmood avatar Aug 17 '15 08:08 ysmood

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

magnus- avatar Aug 19 '15 10:08 magnus-

A good point to start.

ysmood avatar Aug 19 '15 18:08 ysmood

So what's your plan to implement it?

ysmood avatar Aug 19 '15 18:08 ysmood

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.

magnus- avatar Aug 20 '15 08:08 magnus-

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

magnus- avatar Aug 20 '15 08:08 magnus-

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

ysmood avatar Aug 20 '15 08:08 ysmood