chore: Add workflow_dispatch trigger to npm-publish workflow (#1930)
Enables manual triggering of the npm publish workflow with a specific tag input, so tags created from non-default branches (e.g.
v2.x) can be published.
- Added
workflow_dispatchtrigger with a requiredtagstring input- Updated checkout step to use
inputs.tag || github.ref— manual runs check out the specified tag, tag-push runs retain existing behaviorNote: GitHub Actions
workflow_dispatchdoes not support dynamic dropdowns, so the tag is a free-text input field.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.
Co-authored-by: copilot-swe-agent[bot] 198982749+Copilot@users.noreply.github.com Co-authored-by: fengmk2 156269+fengmk2@users.noreply.github.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802032778号
Expressive HTTP middleware framework for node.js to make web applications and APIs more enjoyable to write. Koa’s middleware stack flows in a stack-like manner, allowing you to perform actions downstream then filter and manipulate the response upstream.
Only methods that are common to nearly all HTTP servers are integrated directly into Koa’s small ~570 SLOC codebase. This includes things like content negotiation, normalization of node inconsistencies, redirection, and a few others.
Koa is not bundled with any middleware.
Installation
Koa requires node v18.0.0 or higher for ES2015 and async function support.
Hello Koa
Getting started
Middleware
Koa is a middleware framework that can take two different kinds of functions as middleware:
Here is an example of logger middleware with each of the different functions:
async functions (node v7.6+)
Common function
Koa v1.x Middleware Signature
The middleware signature changed between v1.x and v2.x. The older signature is deprecated.
Old signature middleware support has been removed in v3
Please see the Migration Guide from v2.x to v3.x for information on upgrading from v2.x to v3.x, and the Migration Guide from v1.x to v2.x for information on upgrading from v1.x to v2.x.
Context, Request and Response
Each middleware receives a Koa
Contextobject that encapsulates an incoming http message and the corresponding response to that message.ctxis often used as the parameter name for the context object.Koa provides a
Requestobject as therequestproperty of theContext. Koa’sRequestobject provides helpful methods for working with http requests which delegate to an IncomingMessage from the nodehttpmodule.Here is an example of checking that a requesting client supports xml.
Koa provides a
Responseobject as theresponseproperty of theContext. Koa’sResponseobject provides helpful methods for working with http responses which delegate to a ServerResponse .Koa’s pattern of delegating to Node’s request and response objects rather than extending them provides a cleaner interface and reduces conflicts between different middleware and with Node itself as well as providing better support for stream handling. The
IncomingMessagecan still be directly accessed as thereqproperty on theContextandServerResponsecan be directly accessed as theresproperty on theContext.Here is an example using Koa’s
Responseobject to stream a file as the response body.The
Contextobject also provides shortcuts for methods on itsrequestandresponse. In the prior examples,ctx.typecan be used instead ofctx.response.typeandctx.acceptscan be used instead ofctx.request.accepts.For more information on
Request,ResponseandContext, see the Request API Reference, Response API Reference and Context API Reference.Koa Application
The object created when executing
new Koa()is known as the Koa application object.The application object is Koa’s interface with node’s http server and handles the registration of middleware, dispatching to the middleware from http, default error handling, as well as configuration of the context, request and response objects.
Learn more about the application object in the Application API Reference.
Documentation
Troubleshooting
Check the Troubleshooting Guide or Debugging Koa in the general Koa guide.
Running tests
Reporting vulnerabilities
To report a security vulnerability, please do not open an issue, as this notifies attackers of the vulnerability. Instead, please email dead_horse, jonathanong, and niftylettuce to disclose.
Authors
See AUTHORS.
Community
Backers
Support us with a monthly donation and help us continue our activities.
Sponsors
Become a sponsor and get your logo on our README on Github with a link to your site.
License
MIT