{"id":15007841,"url":"https://github.com/yunisdev/routit","last_synced_at":"2026-03-09T18:06:43.909Z","repository":{"id":57355693,"uuid":"398247624","full_name":"yunisdev/routit","owner":"yunisdev","description":"routit is a tool for using your API easily in your project. It has an easy setup and implementation that will save you time.","archived":false,"fork":false,"pushed_at":"2021-08-22T20:47:11.000Z","size":1548,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-18T23:03:31.478Z","etag":null,"topics":["api","npm","package","routes","sdk","typescript"],"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/yunisdev.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-08-20T11:03:02.000Z","updated_at":"2021-08-22T20:47:13.000Z","dependencies_parsed_at":"2022-09-26T16:31:44.166Z","dependency_job_id":null,"html_url":"https://github.com/yunisdev/routit","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yunisdev%2Froutit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yunisdev%2Froutit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yunisdev%2Froutit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yunisdev%2Froutit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yunisdev","download_url":"https://codeload.github.com/yunisdev/routit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243180890,"owners_count":20249388,"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":["api","npm","package","routes","sdk","typescript"],"created_at":"2024-09-24T19:14:08.611Z","updated_at":"2026-03-09T18:06:38.425Z","avatar_url":"https://github.com/yunisdev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/yunisdev/routit/actions/workflows/main.yml/badge.svg)](https://github.com/yunisdev/routit/actions/workflows/main.yml)\n\n# routit\n\n`routit` is a tool for using your API easily in your project. It has an easy setup and implementation that will save your time.\n\n## Getting started\n\n### Installation\n\nTo install, run:\n\n```bash\n\u003e npm install routit\n```\n\n### Implementing in project\n\nFor using `routit` in your project, you must have it imported.\n\n```js\nimport { RestRoute, RoutitServer } from 'routit'\n```\n\n#### Creating server\n\nWe are assuming that you have a API server in `https://api.myserver.com` and it have an API route `/todos`. Let's look at how we can implement this\n\nFirst of all, you need to create a class that inherits from `RoutitServer` and add `serverRoot` property on it. `serverRoot` is the root URL of your server. **Note: Do not add a slash at the end of URL**.\n\n```js\nclass MyServer extends RoutitServer {\n  serverRoot = 'https://api.myserver.com'\n}\n```\n\nThe name of the class can be whatever you want.\n\n#### Creating route\n\nYou can create routes using the `RestRoute` class. It accepts two parameters:\n\n- `server` - `RoutitServer` object to set host server of the route. You can pass the object by passing `this` in class.\n- `routeName` - `string` for setting which route API call has to be done. In our example, it must be `todos`. **Note: Do not add a slash at the end of `routeName`**.\n\n```js\nclass MyServer extends RoutitServer {\n  serverRoot = 'https://api.myserver.com'\n  Todos = new RestRoute(this, 'todos')\n}\n```\n\n#### Creating server object\n\nThe last thing to use your api in your project is to create an object of the server.\n\n```js\nconst API = new MyServer()\n```\n\n## Making requests\n\n### GET\n\nThere 2 ways of get request. One is `getAll`, other is `getOne`.\n\n#### getAll\n\n`getAll` is used for fetch all the elements.\n\n```js\nvar response = await API.Todos.getAll()\n// This will request https://api.myserver.com/todos with GET\n```\n\n#### getOne\n\n`getOne` is used for fetch one element by id.\n\n```js\nvar response = await API.Todos.getOne(5)\n// This will request https://api.myserver.com/todos/5 with GET\n```\n\n### POST\n\n`post` method will send data to server. (Mostly for creating)\n\n```js\nvar response = await API.Todos.post({\n  id: 15,\n  completed: false,\n  title: 'lorem lorem',\n  userId: 1,\n})\n// This will request https://api.myserver.com/todos with POST\n```\n\n### PUT\n\n`put` method will send data to server by id. (Mostly for replacing data)\n\n```js\nvar response = await API.Todos.put(15, {\n  userId: 1,\n  title: 'lorem ipsum',\n  completed: true,\n})\n// This will request https://api.myserver.com/todos/15 with PUT\n```\n\n### PATCH\n\n`patch` method will send data to server by id. (Mostly for patching data)\n\n```js\nvar response = await API.Todos.patch(15, {\n  title: 'lorem ipsum dolor',\n})\n// This will request https://api.myserver.com/todos/15 with PATCH\n```\n\n### DELETE\n\n`delete` method will send delete request to server by id.\n\n```js\nvar response = await API.Todos.delete(15)\n// This will request https://api.myserver.com/todos/15 with DELETE\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyunisdev%2Froutit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyunisdev%2Froutit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyunisdev%2Froutit/lists"}