koajs/koa
This is an external open-source GitHub repository imported into the WOCSOL Marketplace for discovery. The original repository owner is the primary creator.
Repository Details
Repository Description
Expressive middleware for node.js using ES2017 async functions
Expressive middleware for node.js using ES2017 async functions
<img src="/docs/logo.png" alt="Koa middleware framework for nodejs"/> [![gitter][gitter-image]][gitter-url] [![NPM version][npm-image]][npm-url] [![build status][github-action-image]][github-action-url] [![Test coverage][coveralls-image]][coveralls-url] [![OpenCollective Backers][backers-image]](#backers) [![OpenCollective Sponsors][sponsors-image]](#sponsors) [![PR's Welcome][pr-welcoming-image]][pr-welcoming-url] 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. ```sh npm install koa ``` ## Hello Koa ```js const Koa = require('koa'); const app = new Koa(); // response app.use(ctx => { ctx.body = 'Hello Koa'; }); app.listen(3000); ``` ## Getting started - [Kick-Off-Koa](https://github.com/koajs/kick-off-koa) - An intro to Koa via a set of self-guided workshops. - [Guide](docs/guide.md) - 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+) ```js app.use(async (ctx, next) => { const start = Date.now(); await next(); const ms = Date.now() - start; console.log(`${ctx.method} ${ctx.url
Related Repositories
Product Discussion
Ask questions or discuss this product. New comments are reviewed before publishing.
Loading comments...