{"id":15364662,"url":"https://github.com/venables/koa-plus","last_synced_at":"2025-04-15T07:31:23.736Z","repository":{"id":66220056,"uuid":"79670601","full_name":"venables/koa-plus","owner":"venables","description":"The Koa framework extended for APIs. Optimized for security, scalability, and productivity.","archived":false,"fork":false,"pushed_at":"2017-03-16T02:07:01.000Z","size":65,"stargazers_count":16,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T14:01:57.914Z","etag":null,"topics":["helmet","koa","koa-framework","middleware","node","nodejs","scalability","secure","secure-by-default"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/venables.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-21T20:22:20.000Z","updated_at":"2023-10-13T19:54:54.000Z","dependencies_parsed_at":"2023-03-27T22:05:52.989Z","dependency_job_id":null,"html_url":"https://github.com/venables/koa-plus","commit_stats":{"total_commits":44,"total_committers":1,"mean_commits":44.0,"dds":0.0,"last_synced_commit":"aa4d08c8ba8b1cfc4fb0673bc40e7681d21f03f9"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venables%2Fkoa-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venables%2Fkoa-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venables%2Fkoa-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venables%2Fkoa-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/venables","download_url":"https://codeload.github.com/venables/koa-plus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248690799,"owners_count":21146206,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["helmet","koa","koa-framework","middleware","node","nodejs","scalability","secure","secure-by-default"],"created_at":"2024-10-01T13:12:59.344Z","updated_at":"2025-04-15T07:31:23.378Z","avatar_url":"https://github.com/venables.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# koa-plus\n\n[![Version](https://img.shields.io/npm/v/koa-plus.svg?style=flat-square)](https://www.npmjs.com/package/koa-plus)\n[![Build Status](https://img.shields.io/travis/venables/koa-plus/master.svg?style=flat-square)](https://travis-ci.org/venables/koa-plus)\n[![Coverage Status](https://img.shields.io/coveralls/venables/koa-plus.svg?style=flat-square)](https://coveralls.io/github/venables/koa-plus)\n[![Dependency Status](https://img.shields.io/david/venables/koa-plus.svg?style=flat-square)](https://david-dm.org/venables/koa-plus)\n[![Standard - JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)\n[![Downloads](https://img.shields.io/npm/dm/koa-plus.svg?style=flat-square)](https://www.npmjs.com/package/koa-plus)\n\nkoa-plus is the [koa framework](https://github.com/koajs/koa) (v2) extended for APIs. Optimized for security, scalability, and productivity.\n\n## Features\n\n* Important security headers via [helmet](https://github.com/venables/koa-helmet).\n* CORS support via [kcors](https://github.com/koajs/cors/tree/v2.x).\n* Adds an [X-Response-Time](https://github.com/koajs/response-time/tree/v2.x) header to all responses.\n* Adds an [X-Request-Id](lib/middleware/request-id.js) header to all requests as they come in for easier debugging.\n  * Also passes through client/proxy/load-balancer generated `X-Request-Id` headers as `X-Client-Request-Id`\n* Uses [koa-body](https://github.com/dlau/koa-body) to parse any request body type\n* Adds ETag headers to allow conditional GET requests (respond with `304 Not Modified`)\n* Object stream support via [koa-json](https://github.com/koajs/json)\n* Request logging via [koa-morgan](https://github.com/koa-modules/morgan)\n* Simple `ctx.debug` (or `ctx.app.debug`) logging via the [debug](https://github.com/visionmedia/debug) module\n* Pretty-printed JSON in development\n* Exposes the app configuration on ctx as `ctx.config` (or, app.context.config)\n\nEach feature [can be disabled](#disabling-middleware) individually.\n\n## Installation\n\nInstall `koa-plus` via yarn or npm:\n\n```\nyarn add koa-plus\n```\n\n```\nnpm install koa-plus --save\n```\n\n## Usage\n\n### Existing apps:\n\nSimply replace your existing `koa` require with `koa-plus`\n\nOld:\n\n```js\nconst Koa = require('koa')\nconst app = new Koa()\n// ...\n```\n\nNew:\n\n```js\nconst Koa = require('koa-plus')\nconst app = new Koa()\n// ...\n```\n\n### Configuration\n\nSome of the middleware included in `koa-plus` allows for options.  To pass options to these\nmiddleware, simply pass the options to the constructor.\n\n#### Options\n\n* `body`:  Use the same options as the `koa-body` middleware accepts. [Docs](https://github.com/dlau/koa-body)\n* `compress`: Use the same options as the `koa-compress` middleware accepts. [Docs](https://github.com/koajs/compress/tree/v2.x)\n* `cors`: Use the same options as the `kcors` middleware accepts. [Docs](https://github.com/koajs/cors/tree/v2.x)\n* `debug`: Set the `name` of the debug logger\n* `helmet`: Use the same options as the `helmet` middleware accepts. [Docs](https://helmetjs.github.io/docs/)\n* `json`: Use the same options as the `koa-json` middleware accepts. [Docs](https://github.com/koajs/json/tree/next)\n* `logger`: Use `format` for the logger format, and the remaining options as what `morgan` accepts [Docs](https://github.com/expressjs/morgan)\n\n#### Example\n\n```js\nconst Koa = require('koa-plus')\n\nconst app = new Koa({\n  body: {\n    jsonLimit: '10kb' // Sets the json request body limit to 10k\n  },\n  compress: {\n    threshold: 2048 // Sets the threshold to Gzip responses at 2k (2048 bytes)\n  },\n  cors: {\n    origin: '*' // Set the `Access-Control-Allow-Origin` header to be `*`\n  },\n  debug: {\n    name: 'worker' // Set the debug logger name\n  },\n  helmet: {\n    noCache: true,  // Sets the `Cache-Control` headers to prevent caching\n    frameguard: {\n      action: 'deny' // Set the `X-Frame-Options' header to be `DENY`\n    }\n  },\n  json: {\n    pretty: false // Disables pretty-printing\n  },\n  logger: {\n    format: 'dev' // Use the `dev` format of logging\n  }\n})\n```\n\n#### Disabling middleware\n\nEach of the middleware in koa-plus can be disabled individually by using the `enabled` option.\n\nAs an example, to reset `koa-plus` back to basic `koa` functionality, use the following config:\n\n```js\nconst Koa = require('koa-plus')\n\nconst app = new Koa({\n  body: {\n    enabled: false\n  },\n  compress: {\n    enabled: false\n  },\n  cors: {\n    enabled: false\n  },\n  debug: {\n    enabled: false\n  },\n  etag: {\n    enabled: false\n  },\n  helmet: {\n    enabled: false\n  },\n  json: {\n    enabled: false\n  },\n  logger: {\n    enabled: false\n  },\n  requestId: {\n    enabled: false\n  },\n  responseTime: {\n    enabled: false\n  }\n})\n```\n\n## Testing\n\nTo run the tests locally, simply run\n\n```\nyarn test\n```\n\nor\n\n```\nnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvenables%2Fkoa-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvenables%2Fkoa-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvenables%2Fkoa-plus/lists"}