dependabot[bot] 7716028fec build(deps-dev): bump c8 from 8.0.1 to 10.1.3 (#1874)
Bumps [c8](https://github.com/bcoe/c8) from 8.0.1 to 10.1.3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/bcoe/c8/releases">c8's
releases</a>.</em></p>
<blockquote>
<h2>v10.1.3</h2>
<h2><a
href="https://github.com/bcoe/c8/compare/v10.1.2...v10.1.3">10.1.3</a>
(2024-12-10)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>deps:</strong> update bcoe/v8-coverage addressing v8 issue
(<a href="https://redirect.github.com/bcoe/c8/issues/552">#552</a>) (<a
href="b32a563e25">b32a563</a>)</li>
</ul>
<h2>v10.1.2</h2>
<h2><a
href="https://github.com/bcoe/c8/compare/v10.1.1...v10.1.2">10.1.2</a>
(2024-06-13)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>deps:</strong> make monocart-coverage-reports an optional
with meta defined (<a
href="3b91fdaa0e">3b91fda</a>)</li>
</ul>
<h2>v10.1.1</h2>
<h2><a
href="https://github.com/bcoe/c8/compare/v10.1.0...v10.1.1">10.1.1</a>
(2024-06-11)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>stop installing monocart-coverage-reports (<a
href="https://redirect.github.com/bcoe/c8/issues/535">#535</a>) (<a
href="13979a76b5">13979a7</a>)</li>
</ul>
<h2>v10.1.0</h2>
<h2><a
href="https://github.com/bcoe/c8/compare/v10.0.0...v10.1.0">10.1.0</a>
(2024-06-11)</h2>
<h3>Features</h3>
<ul>
<li>add experimental monocart reports (<a
href="https://redirect.github.com/bcoe/c8/issues/521">#521</a>) (<a
href="2e5e297ac0">2e5e297</a>)</li>
</ul>
<h2>v10.0.0</h2>
<h2><a
href="https://github.com/bcoe/c8/compare/v9.1.0...v10.0.0">10.0.0</a>
(2024-06-10)</h2>
<h3>⚠ BREAKING CHANGES</h3>
<ul>
<li><strong>deps:</strong> Node 18 is now the minimum supported Node.js
version</li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li><strong>deps:</strong> update test-exclude with new glob / minimatch
(<a href="https://redirect.github.com/bcoe/c8/issues/531">#531</a>) (<a
href="e33cf30d0c">e33cf30</a>)</li>
</ul>
<h2>v9.1.0</h2>
<h2><a
href="https://github.com/bcoe/c8/compare/v9.0.0...v9.1.0">9.1.0</a>
(2024-01-11)</h2>
<h3>Features</h3>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/bcoe/c8/blob/main/CHANGELOG.md">c8's
changelog</a>.</em></p>
<blockquote>
<h2><a
href="https://github.com/bcoe/c8/compare/v10.1.2...v10.1.3">10.1.3</a>
(2024-12-10)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>deps:</strong> update bcoe/v8-coverage addressing v8 issue
(<a href="https://redirect.github.com/bcoe/c8/issues/552">#552</a>) (<a
href="b32a563e25">b32a563</a>)</li>
</ul>
<h2><a
href="https://github.com/bcoe/c8/compare/v10.1.1...v10.1.2">10.1.2</a>
(2024-06-13)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>deps:</strong> make monocart-coverage-reports an optional
with meta defined (<a
href="3b91fdaa0e">3b91fda</a>)</li>
</ul>
<h2><a
href="https://github.com/bcoe/c8/compare/v10.1.0...v10.1.1">10.1.1</a>
(2024-06-11)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>stop installing monocart-coverage-reports (<a
href="https://redirect.github.com/bcoe/c8/issues/535">#535</a>) (<a
href="13979a76b5">13979a7</a>)</li>
</ul>
<h2><a
href="https://github.com/bcoe/c8/compare/v10.0.0...v10.1.0">10.1.0</a>
(2024-06-11)</h2>
<h3>Features</h3>
<ul>
<li>add experimental monocart reports (<a
href="https://redirect.github.com/bcoe/c8/issues/521">#521</a>) (<a
href="2e5e297ac0">2e5e297</a>)</li>
</ul>
<h2><a
href="https://github.com/bcoe/c8/compare/v9.1.0...v10.0.0">10.0.0</a>
(2024-06-10)</h2>
<h3>⚠ BREAKING CHANGES</h3>
<ul>
<li><strong>deps:</strong> Node 18 is now the minimum supported Node.js
version</li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li><strong>deps:</strong> update test-exclude with new glob / minimatch
(<a href="https://redirect.github.com/bcoe/c8/issues/531">#531</a>) (<a
href="e33cf30d0c">e33cf30</a>)</li>
</ul>
<h2><a
href="https://github.com/bcoe/c8/compare/v9.0.0...v9.1.0">9.1.0</a>
(2024-01-11)</h2>
<h3>Features</h3>
<ul>
<li>support passing reporter options from config (<a
href="https://redirect.github.com/bcoe/c8/issues/459">#459</a>) (<a
href="88db5db56e">88db5db</a>)</li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li><strong>refactor:</strong> remove stale check for
createDynamicModule (<a
href="5e18365b15">5e18365</a>)</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="1ec3cc41ff"><code>1ec3cc4</code></a>
chore(main): release 10.1.3 (<a
href="https://redirect.github.com/bcoe/c8/issues/553">#553</a>)</li>
<li><a
href="b32a563e25"><code>b32a563</code></a>
fix(deps): update bcoe/v8-coverage addressing v8 issue (<a
href="https://redirect.github.com/bcoe/c8/issues/552">#552</a>)</li>
<li><a
href="75fa99f7bc"><code>75fa99f</code></a>
chore(deps): update dependency <code>@​types/node</code> to v22 (<a
href="https://redirect.github.com/bcoe/c8/issues/548">#548</a>)</li>
<li><a
href="ff146b4dde"><code>ff146b4</code></a>
chore(main): release 10.1.2 (<a
href="https://redirect.github.com/bcoe/c8/issues/538">#538</a>)</li>
<li><a
href="3b91fdaa0e"><code>3b91fda</code></a>
fix(deps): make monocart-coverage-reports an optional with meta
defined</li>
<li><a
href="e3560e1211"><code>e3560e1</code></a>
chore(main): release 10.1.1 (<a
href="https://redirect.github.com/bcoe/c8/issues/536">#536</a>)</li>
<li><a
href="13979a76b5"><code>13979a7</code></a>
fix: stop installing monocart-coverage-reports (<a
href="https://redirect.github.com/bcoe/c8/issues/535">#535</a>)</li>
<li><a
href="15ac6905cd"><code>15ac690</code></a>
chore(main): release 10.1.0 (<a
href="https://redirect.github.com/bcoe/c8/issues/533">#533</a>)</li>
<li><a
href="96e869ff8c"><code>96e869f</code></a>
build(deps-dev): bump braces from 3.0.2 to 3.0.3 (<a
href="https://redirect.github.com/bcoe/c8/issues/534">#534</a>)</li>
<li><a
href="2e5e297ac0"><code>2e5e297</code></a>
feat: add experimental monocart reports (<a
href="https://redirect.github.com/bcoe/c8/issues/521">#521</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/bcoe/c8/compare/v8.0.1...v10.1.3">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=c8&package-manager=npm_and_yarn&previous-version=8.0.1&new-version=10.1.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-26 23:49:47 -07:00
2025-03-16 21:30:24 -07:00
2025-03-21 22:42:08 -07:00
2015-10-13 09:23:57 +02:00
2020-06-21 22:26:48 +08:00
2023-11-08 23:05:20 +08:00
2016-03-12 14:22:16 -08:00
2019-01-07 16:41:45 +08:00

Koa middleware framework for nodejs

gitter NPM version build status Test coverage OpenCollective Backers OpenCollective Sponsors PR's Welcome

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.

$ npm install koa

Hello Koa

const Koa = require('koa');
const app = new Koa();

// response
app.use(ctx => {
  ctx.body = 'Hello Koa';
});

app.listen(3000);

Getting started

  • Kick-Off-Koa - An intro to Koa via a set of self-guided workshops.
  • Guide - Go straight to the docs.

Middleware

Koa is a middleware framework that can take two different kinds of functions as middleware:

  • async function
  • common function

Here is an example of logger middleware with each of the different functions:

async functions (node v7.6+)

app.use(async (ctx, next) => {
  const start = Date.now();
  await next();
  const ms = Date.now() - start;
  console.log(`${ctx.method} ${ctx.url} - ${ms}ms`);
});

Common function

// Middleware normally takes two parameters (ctx, next), ctx is the context for one request,
// next is a function that is invoked to execute the downstream middleware. It returns a Promise with a then function for running code after completion.

app.use((ctx, next) => {
  const start = Date.now();
  return next().then(() => {
    const ms = Date.now() - start;
    console.log(`${ctx.method} ${ctx.url} - ${ms}ms`);
  });
});

Koa v1.x Middleware Signature

The middleware signature changed between v1.x and v2.x. The older signature is deprecated.

Old signature middleware support will be removed in v3

Please see the Migration Guide for more information on upgrading from v1.x and using v1.x middleware with v2.x.

Context, Request and Response

Each middleware receives a Koa Context object that encapsulates an incoming http message and the corresponding response to that message. ctx is often used as the parameter name for the context object.

app.use(async (ctx, next) => { await next(); });

Koa provides a Request object as the request property of the Context.
Koa's Request object provides helpful methods for working with http requests which delegate to an IncomingMessage from the node http module.

Here is an example of checking that a requesting client supports xml.

app.use(async (ctx, next) => {
  ctx.assert(ctx.request.accepts('xml'), 406);
  // equivalent to:
  // if (!ctx.request.accepts('xml')) ctx.throw(406);
  await next();
});

Koa provides a Response object as the response property of the Context.
Koa's Response object 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 IncomingMessage can still be directly accessed as the req property on the Context and ServerResponse can be directly accessed as the res property on the Context.

Here is an example using Koa's Response object to stream a file as the response body.

app.use(async (ctx, next) => {
  await next();
  ctx.response.type = 'xml';
  ctx.response.body = fs.createReadStream('really_large.xml');
});

The Context object also provides shortcuts for methods on its request and response. In the prior examples, ctx.type can be used instead of ctx.response.type and ctx.accepts can be used instead of ctx.request.accepts.

For more information on Request, Response and Context, 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

$ npm test

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

Job Board

Looking for a career upgrade?

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

Description
No description provided
Readme MIT 3.9 MiB
Languages
JavaScript 100%