{"id":24394435,"url":"https://github.com/decelerate/cruiseh","last_synced_at":"2026-02-17T13:02:49.989Z","repository":{"id":271590995,"uuid":"912221376","full_name":"Decelerate/cruiseh","owner":"Decelerate","description":"A simple TypeScript router class for handling HTTP routes for deno","archived":false,"fork":false,"pushed_at":"2025-01-16T00:00:41.000Z","size":12,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-16T00:16:01.689Z","etag":null,"topics":["deno","framework","http-server","router"],"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/Decelerate.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2025-01-05T00:16:39.000Z","updated_at":"2025-01-16T00:00:40.000Z","dependencies_parsed_at":"2025-01-08T17:54:42.112Z","dependency_job_id":"f3c7e5d1-4b60-45a9-bc77-a189f4a32197","html_url":"https://github.com/Decelerate/cruiseh","commit_stats":null,"previous_names":["decelerate/cruiseh"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Decelerate%2Fcruiseh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Decelerate%2Fcruiseh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Decelerate%2Fcruiseh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Decelerate%2Fcruiseh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Decelerate","download_url":"https://codeload.github.com/Decelerate/cruiseh/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243325066,"owners_count":20273213,"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":["deno","framework","http-server","router"],"created_at":"2025-01-19T19:24:41.125Z","updated_at":"2026-02-17T13:02:49.941Z","avatar_url":"https://github.com/Decelerate.png","language":"TypeScript","readme":"# Cruiseh\n[![jsr.io/@decelerate/cruiseh](https://jsr.io/badges/@decelerate/cruiseh)](https://jsr.io/@decelerate/cruiseh)\n[![jsr.io/@decelerate/cruiseh score](https://jsr.io/badges/@decelerate/cruiseh/score)](https://jsr.io/@decelerate/cruiseh)\n[![cruiseh ci](https://github.com/decelerate/cruiseh/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/decelerate/cruiseh)\n\n\u003e [!CAUTION]\n\u003e Only work with deno runtime for the moment\n\u003e\n\u003e Don't use it in production until 1.0.0 release\n\nA simple TypeScript router class for handling HTTP routes, inspired by Express.js. This router supports GET, POST, PUT, and DELETE methods.\n\nThis library is made for \"training\" purpose but you can use it for small project.\n\nFeel free to make a Pull request or issue if you want additional features, we don't bite ! 🧛\n\n## Features\n\n- Register routes for different HTTP methods (GET, POST, PUT, DELETE)\n- Middleware support\n- Simple and easy-to-use API\n\n## Installation\n\nFor now, the only way to use it is with JSR inside deno project\n\n```bash\ndeno add jsr:@decelerate/cruiseh\n```\n\n## Usage \n\nHere's an example of how to use the Router class with deno serve :\n\n```ts\n// server.ts\nimport { Router } from '@decelerate/cruiseh';\nimport { getUrlParams } from \"@decelerate/cruiseh/utils/getUrlParams\";\n\nconst app = new Router();\n\n// Register routes\napp.get(\"/hello\", (request) =\u003e new Response(\"Hello world\"));\n\napp.post(\"/hello\", async (req) =\u003e {\n  const body = { message: \"Message from body\" };\n\n  return new Response(JSON.stringify(body), {\n    status: 200,\n    headers: {\n      \"content-type\": \"application/json; charset=utf-8\",\n    },\n  });\n});\n\n// With params\napp.get(\"/hello/:id\", (req, matchedRoute) =\u003e {\n  // If you don't want to use utils function you can do the same thing manually\n  //const routePattern = matchedRoute.exec(req.url);\n  //const params = routePattern?.pathname.groups;\n\n  // For more secure way, you may need to try/catch your operations\n  const params = getUrlParams\u003c{ id: string }\u003e(matchedRoute, req.url);\n\n  const body = { id: params.id };\n\n  return new Response(JSON.stringify(body), {\n    status: 200,\n    headers: {\n      \"content-type\": \"application/json; charset=utf-8\",\n    },\n  });\n});\n\n// Register middleware (active on all routes)\napp.use(async (req, next) =\u003e {\n  console.log(`Request made to: ${req.url}`);\n  return next();\n});\n\n// Register middleware (active on GET /hello and children routes)\napp.use(\n  async (req, next) =\u003e {\n    console.log(`Request made to: ${req.url}`);\n    return next();\n  },\n  {\n    path: \"/hello\",\n    method: \"POST\",\n  }\n);\n\n// Handle incoming request\nexport default {\n  fetch(request: Request) {\n    return app.handler(request);\n  },\n} satisfies Deno.ServeDefaultExport;\n```\n\nYou can now run :\n```bash\ndeno serve -A --watch server.ts\n```\n\n## API\n`use(middleware: Middleware, options?: MiddlewareOptions)`\n\nRegisters a middleware function to be executed for every request.\n\n`get(path: string, handler: Handler)`\n\nRegisters a GET route with the specified path and handler.\n\n`post(path: string, handler: Handler)`\n\nRegisters a POST route with the specified path and handler.\n\n`put(path: string, handler: Handler)`\n\nRegisters a PUT route with the specified path and handler.\n\n`delete(path: string, handler: Handler)`\n\nRegisters a DELETE route with the specified path and handler.\n\n`handler(request: Request): Response`\n\nHandles incoming requests by matching them to the appropriate route.\n\n## Contributing\nSee [Contributing guide](https://github.com/Decelerate/cruiseh/tree/main/CONTRIBUTING.md)\n\n## License\nThis project is licensed under the MIT License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecelerate%2Fcruiseh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecelerate%2Fcruiseh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecelerate%2Fcruiseh/lists"}