{"id":13736849,"url":"https://github.com/matteocrippa/microraptor","last_synced_at":"2025-10-20T18:01:54.627Z","repository":{"id":144373243,"uuid":"264305695","full_name":"matteocrippa/microraptor","owner":"matteocrippa","description":"A deno lightweight middleware for easy REST development.","archived":false,"fork":false,"pushed_at":"2020-06-22T15:05:54.000Z","size":35,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-26T00:21:35.891Z","etag":null,"topics":["deno","middleware","rest-api","restful-api","web"],"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/matteocrippa.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-15T21:48:59.000Z","updated_at":"2022-10-23T19:57:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"e2fd80e6-e276-4791-ae66-3e7376d68a2c","html_url":"https://github.com/matteocrippa/microraptor","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/matteocrippa%2Fmicroraptor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matteocrippa%2Fmicroraptor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matteocrippa%2Fmicroraptor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matteocrippa%2Fmicroraptor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matteocrippa","download_url":"https://codeload.github.com/matteocrippa/microraptor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224737431,"owners_count":17361345,"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","middleware","rest-api","restful-api","web"],"created_at":"2024-08-03T03:01:29.731Z","updated_at":"2025-10-20T18:01:49.582Z","avatar_url":"https://github.com/matteocrippa.png","language":"TypeScript","funding_links":[],"categories":["基础设施","Modules"],"sub_categories":["JAM Stack/静态站点","Assistants"],"readme":"# ![](https://raw.githubusercontent.com/matteocrippa/microraptor/master/.github/velociraptor.png) Microraptor\n\n_Microraptor_ is a lightweight framework for easy routing on top of deno network lib.\nProject is a work-in-progress and in _pre-alpha_.\n\n## Install\n\nImport _Microraptor_ in your project with just one line of code:\n\n```ts\nimport { Microraptor } from \"https://deno.land/x/microraptor/microraptor.ts\";\n```\n\n## How to use (basic)\n\nA basic example of usage is creating a new file named for example `web.ts`:\n\n```ts\nimport { Microraptor, Method, MicroRequest } from \"../microraptor.ts\";\nconst server = new Microraptor({ port: 3000 });\n\nserver.route({\n  method: Method.get,\n  path: \"/\",\n  controller: {\n    response: (req: MicroRequest) =\u003e {\n      req.request.respond({ body: \"Hello Microraptor!\" });\n    },\n  },\n});\n\nserver.start();\n```\n\nThen in your terminal you can run:\n\n```bash\n$ deno run --allow-net web.ts\n```\n\nYou can discover a bit more for now in `/examples` directory.\n\n### Parameters\n\nParameters are easily accessible from `.param` variable of `MicroRequest`.\n\n```ts\nserver.route(\n  {\n    method: Method.get,\n    path: \"/:name\",\n    controller: {\n      response: (req: MicroRequest) =\u003e {\n        req.request.respond({ body: `Hello ${req.param.name}` });\n      },\n    },\n  },\n);\n```\n\n### Querystring\n\nQuerystring are easily accessible from `.query` variable of `MicroRequest`.\n\n```ts\nserver.route(\n  {\n    method: Method.get,\n    path: \"/\",\n    controller: {\n      response: (req: MicroRequest) =\u003e {\n        req.request.respond({ body: `Hello ${req.query.name}` });\n      },\n    },\n  },\n);\n```\n\n### Body\n\nBody is easily accessible from `.body` variable of `MicroRequest`.\n\n```ts\nserver.route(\n  {\n    method: Method.post,\n    path: \"/\",\n    controller: {\n      response: (req: MicroRequest) =\u003e {\n        req.request.respond({ body: `Hello ${req.body.name}` });\n      },\n    },\n  },\n);\n```\n\n### Cookie\n\nCookies are easily accessible from `.cookie` variable of `MicroRequest`.\n\n```ts\nserver.route(\n  {\n    method: Method.get,\n    path: \"/\",\n    controller: {\n      response: (req: MicroRequest) =\u003e {\n        req.request.respond({ body: `Hello ${req.cookie.name}` });\n      },\n    },\n  },\n);\n```\n\n### Validation\n\nValidation in _Microraptor_ is powered by [fossil](https://deno.land/x/fossil)/ a library that easily validate values and types.\n\nA simple usage can be the following:\n\n```ts\nserver.route(\n  {\n    method: Method.get,\n    path: \"/:country/:city\",\n    controller: {\n      response: (req: MicroRequest) =\u003e {\n        req.request.respond(\n          {\n            body: JSON.stringify(\n              {\n                param: req.param,\n                query: req.query,\n                cookie: req.cookie,\n                body: req.body,\n              },\n            ),\n          },\n        );\n      },\n    },\n    validation: new Validation(\n      {\n        param: [\n          new MicroValidator(\n            \"country\",\n            ValidatorType.string,\n            [\"Italy\", \"italy\"],\n          ),\n        ],\n      },\n    ),\n  },\n);\n```\n\n## Pending implementation\n\n- [x] Querystring\n- [x] Params\n- [x] Cookie\n- [ ] CORS\n- [ ] Middleware\n- [ ] Response type (text, json)\n- [ ] AWS Lambda support\n- [x] Test\n\n### Credits\n\nIcon made by [Freepik](https://www.flaticon.com/authors/freepik) from [www.flaticon.com](https://www.flaticon.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatteocrippa%2Fmicroraptor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatteocrippa%2Fmicroraptor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatteocrippa%2Fmicroraptor/lists"}