{"id":19849406,"url":"https://github.com/nhttp/raptor","last_synced_at":"2026-05-09T23:05:05.543Z","repository":{"id":62422440,"uuid":"441098804","full_name":"nhttp/raptor","owner":"nhttp","description":"Fast router handler for Deno and Deno Deploy","archived":false,"fork":false,"pushed_at":"2021-12-27T01:33:01.000Z","size":35,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-11T12:48:46.954Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/nhttp.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":"2021-12-23T07:28:35.000Z","updated_at":"2021-12-27T01:31:57.000Z","dependencies_parsed_at":"2022-11-01T17:33:15.866Z","dependency_job_id":null,"html_url":"https://github.com/nhttp/raptor","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhttp%2Fraptor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhttp%2Fraptor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhttp%2Fraptor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhttp%2Fraptor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nhttp","download_url":"https://codeload.github.com/nhttp/raptor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241228969,"owners_count":19930706,"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-11-12T13:20:39.495Z","updated_at":"2026-05-09T23:05:05.507Z","avatar_url":"https://github.com/nhttp.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Raptor\n\n[![License](https://img.shields.io/:license-mit-blue.svg)](http://badges.mit-license.org)\n[![deno.land](https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Flatest-version%2Fx%2Fraptor@0.0.8%2Fmod.ts)](https://deno.land/x/raptor)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](http://makeapullrequest.com)\n![deps badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fdep-count%2Fhttps%2Fdeno.land%2Fx%2Fraptor%2Fmod.ts)\n![cache badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fcache-size%2Fhttps%2Fdeno.land%2Fx%2Fraptor%2Fmod.ts)\n\nFast router handler for [Deno](https://deno.land/) server and\n[Deploy](https://deno.com/deploy).\n\n\u003e Raptor implemented to [nhttp](https://nhttp.deno.dev)\n\n## Features\n\n- Middleware support.\n- Sub Router support.\n\n## Usage\n\n```ts\nimport { serve } from \"https://deno.land/std@0.118.0/http/server.ts\";\nimport { JsonResponse, raptor } from \"https://deno.land/x/raptor@0.0.8/mod.ts\";\n\nserve(\n  raptor()\n    .make(\"GET\", () =\u003e new Response(\"Hello World\"))\n    .make(\"GET/hello/:name\", (req) =\u003e new Response(`Hello ${req.params.name}`))\n    .make(\"GET/hello-json\", () =\u003e new JsonResponse({ name: \"raptor\" }))\n    .resolve,\n);\n\nconsole.log(\"Raptor was here !!\");\n```\n\n## Run\n\n```bash\ndeno run --allow-net file.ts\n```\n\nand visit `http://localhost:8000` with path `/` or `/hello-json` or\n`/hello/yourname`\n\n## Make\n\nMake everything with `raptor().make(verb, ...fns)`.\n\nthe verb is =\u003e\n`GET | POST | DELETE | PUT | PATCH | OPTIONS | HEAD | ANY | ROUTER | WARE | ERROR | 404`\nand path.\n\n### Make Method Handlers\n\n```ts\nserve(\n  raptor()\n    .make(\"GET/hello/:name\", (req) =\u003e new Response(`Hello ${req.params.name}`))\n    .resolve,\n);\n```\n\n### Make Global Middleware\n\n```ts\nserve(\n  raptor()\n    .make(\"WARE\", (req, next) =\u003e {\n      req.foo = \"foo\";\n      return next();\n    })\n    .make(\"GET/hello\", (req) =\u003e new Response(`Hello ${req.foo}`))\n    .resolve,\n);\n```\n\n### If Inline Middleware\n\n```ts\nserve(\n  raptor()\n    .make(\"GET/hello\", (req, next) =\u003e {\n      req.foo = \"foo\";\n      return next();\n    }, (req) =\u003e {\n      return new Response(`Hello ${req.foo}`);\n    })\n    .resolve,\n);\n```\n\n### Make Sub Router\n\n```ts\nconst router = raptor.createRouter();\nrouter.make(\"GET/user\", () =\u003e new Response(\"Hello from router\"));\n\nserve(\n  raptor()\n    .make(\"ROUTER/api/v1\", [router])\n    .resolve,\n);\n\n// visit http://localhost:8000/api/v1/user\n```\n\n### Make onError\n\nGlobal error response.\n\n```ts\nserve(\n  raptor()\n    // example\n    .make(\n      \"ERROR\",\n      (err, req) =\u003e new Response(err.message, { status: err.status || 500 }),\n    )\n    .resolve,\n);\n```\n\n### Make on404\n\nGlobal 404 response.\n\n```ts\nserve(\n  raptor()\n    // example\n    .make(\"404\", (req) =\u003e new Response(\"404 not found url\", { status: 404 }))\n    .resolve,\n);\n```\n\n[See examples](https://github.com/nhttp/raptor/tree/master/examples)\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhttp%2Fraptor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhttp%2Fraptor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhttp%2Fraptor/lists"}