{"id":13718653,"url":"https://oakserver.github.io/middleware/","last_synced_at":"2025-05-07T10:33:26.824Z","repository":{"id":56423860,"uuid":"264429792","full_name":"oakserver/middleware","owner":"oakserver","description":"A collection of middleware to use with oak. 🐿️ 🦕","archived":false,"fork":false,"pushed_at":"2020-11-09T02:07:13.000Z","size":11,"stargazers_count":31,"open_issues_count":5,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-29T04:43:13.550Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://oakserver.github.io/middleware/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oakserver.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-16T12:16:14.000Z","updated_at":"2025-03-03T19:47:29.000Z","dependencies_parsed_at":"2022-08-15T18:30:31.373Z","dependency_job_id":null,"html_url":"https://github.com/oakserver/middleware","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oakserver%2Fmiddleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oakserver%2Fmiddleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oakserver%2Fmiddleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oakserver%2Fmiddleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oakserver","download_url":"https://codeload.github.com/oakserver/middleware/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252859949,"owners_count":21815435,"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":[],"created_at":"2024-08-03T01:00:35.277Z","updated_at":"2025-05-07T10:33:26.538Z","avatar_url":"https://github.com/oakserver.png","language":"TypeScript","readme":"# oak middleware\n\n[![ci](https://github.com/oakserver/middleware/workflows/ci/badge.svg)](https://github.com/oakserver/middleware)\n[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/oak_middleware/mod.ts)\n\nA collection of middleware for the\n[oak framework](https://oakserver.github.io/oak/).\n\n## Usage\n\nEach middleware has its own module, as well as all the middleware being\nvia the root `mod.ts`. If you just want everything, you can simply import\nthe `mod.ts`, for example:\n\n```ts\nimport * as oakMiddleware from \"https://deno.land/x/oak_middleware/mod.ts\";\nimport { Application } from \"https://deno.land/x/oak/mod.ts\";\n\nconst app = new Application();\n\napp.use(oakMiddleware.responseTimeHeader);\n```\n\nAlso consider using a tagged version of the middleware so that changes to the\nmain branch won't provide unexpected results in your code. For example, to use\nversion `v0.1.0` you would do the following:\n\n```ts\nimport * as oakMiddleware from \"https://deno.land/x/oak_middleware@v0.1.0/mod.ts\";\n```\n\nIf you just want specific middleware, you can just import it from its module:\n\n```ts\nimport { responseTimeHeader } from \"https://deno.land/x/oak_middleware/observability/response_time_header.ts\";\n```\n\nIf you want to manage all your external dependencies in one place, just follow\nthe convention of `deps.ts` and re-export what you want:\n\n```ts\nexport { responseTimeHeader } from \"https://deno.land/x/oak_middleware@v0.1.0/observability/response_time_header.ts\";\nexport { Application } from \"https://deno.land/x/oak@4.0.0/mod.ts\";\n```\n\nAnd then in your other modules, just import from `deps.ts`:\n\n```ts\nimport { Application, responseTimeHeader } from \"./deps.ts\";\n\nconst app = new Application();\napp.use(responseTimeHeader);\n// ...\nawait app.listen({ port: 80 });\n```\n\n## Middleware\n\nThis section contains middleware that is intended to be used with the `.use()`\nmethod on the application.\n\n### Observability\n\nThis is middleware that is used for instrumentation and observability of a\nserver created with oak.\n\n#### responseTimeHeader\n\nA middleware that will set the response time for other middleware in\nmilliseconds as `X-Response-Time` which can be used for diagnostics and other\ninstrumentation of an application. Utilise the middleware before the \"real\"\nprocessing occurs.\n\n```ts\nimport { responseTimeHeader } from \"https://deno.land/x/oak-middleware/mod.ts\";\nimport { Application } from \"https://deno.land/x/oak/mod.ts\";\n\nconst app = new App();\napp.use(responseTimeHeader);\n\n// other middleware\n\nawait app.listen(\":80\");\n```\n\n## Router Middleware\n\nThis section contains middleware designed to work with the oak `Router`.\n\n---\n\nCopyright 2020 the oak authors. All rights reserved.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/oakserver.github.io%2Fmiddleware%2F","html_url":"https://awesome.ecosyste.ms/projects/oakserver.github.io%2Fmiddleware%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/oakserver.github.io%2Fmiddleware%2F/lists"}