Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support lib require in route file #178

Merged
merged 8 commits into from
Apr 13, 2020
Merged

Support lib require in route file #178

merged 8 commits into from
Apr 13, 2020

Conversation

xuchaoying
Copy link
Member

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests is needed?
    • Tests for the changes have been added
  • Docs is needed?
    • Docs have been added / updated

What kind of change does this PR introduce?

  • Bug fix
  • Feature
  • Enhencement
  • Refactor
  • Documents
  • Others
  1. Support lib require in route file
const bodyParser = require('koa-bodyparser');

post('/XXXX').to.middleware(bodyParser).handle((ctx) => {
  console.log('ctx', ctx.request.body);
  ctx.type = 'html';
  ctx.body = ctx.request.body;
});

What is the related issue?

#157

Does this PR introduce a breaking change?

  • breaking change?

Other information:

@xuchaoying xuchaoying added the PR: new feature :rocket: New Feature label Jan 6, 2020
@codecov
Copy link

codecov bot commented Jan 6, 2020

Codecov Report

Merging #178 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #178      +/-   ##
==========================================
+ Coverage   95.97%   95.98%   +0.01%     
==========================================
  Files          50       50              
  Lines        1688     1694       +6     
==========================================
+ Hits         1620     1626       +6     
  Misses         68       68              
Impacted Files Coverage Δ
packages/svrx/lib/router/loader.js 100.00% <100.00%> (ø)
packages/svrx/lib/router/router.js 100.00% <100.00%> (ø)
packages/svrx/lib/svrx.js 95.28% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d48b18d...53cebae. Read the comment docs.

@xuchaoying xuchaoying requested a review from leeluolee January 6, 2020 09:01
@xuchaoying xuchaoying requested review from a team and removed request for leeluolee April 8, 2020 03:10
Copy link
Member

@int64ago int64ago left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Documents needed
  • I prefer use instead of middleware

const bodyParserRelative = require('./node_modules/koa-bodyparser'); //relative path
const bodyParser = require('koa-bodyparser');

post('/test/post').to.handle(bodyParser()).handle((ctx) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

middleware or handle ?

@xuchaoying
Copy link
Member Author

  • middleware

doc here: svrxjs/svrx-docs#41

@xuchaoying xuchaoying merged commit d215ddf into master Apr 13, 2020
@xuchaoying xuchaoying deleted the cy-route-require branch April 13, 2020 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: new feature :rocket: New Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants