{"id":18015539,"url":"https://github.com/ehsan-shv/nuxt-api-layer-aspida","last_synced_at":"2025-04-04T15:17:24.512Z","repository":{"id":181498095,"uuid":"666862206","full_name":"ehsan-shv/nuxt-api-layer-aspida","owner":"ehsan-shv","description":"Type-safe API layer with Axios, Aspida, and composition api.","archived":false,"fork":false,"pushed_at":"2023-07-16T06:27:01.000Z","size":142,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T19:01:46.125Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ehsan-shv.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":"2023-07-15T20:41:58.000Z","updated_at":"2023-11-20T17:00:42.000Z","dependencies_parsed_at":"2024-12-17T18:52:07.590Z","dependency_job_id":null,"html_url":"https://github.com/ehsan-shv/nuxt-api-layer-aspida","commit_stats":null,"previous_names":["ehsan-shv/nuxt-api-layer-aspida"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsan-shv%2Fnuxt-api-layer-aspida","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsan-shv%2Fnuxt-api-layer-aspida/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsan-shv%2Fnuxt-api-layer-aspida/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsan-shv%2Fnuxt-api-layer-aspida/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ehsan-shv","download_url":"https://codeload.github.com/ehsan-shv/nuxt-api-layer-aspida/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198473,"owners_count":20900082,"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-10-30T04:14:18.019Z","updated_at":"2025-04-04T15:17:24.495Z","avatar_url":"https://github.com/ehsan-shv.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Type-safe API layer for Nuxt.js 3\n\n\u003e Type-safe API layer with Axios, [Aspida](https://github.com/aspida/aspida), and composition api.\n\n1.  Create a directory for each endpoint in /api directory\n2.  Create an endpoint type definition file\n3.  run `yarn run build:api`\n4.  Access to the whole auto generated endpoints by `useApi()` composition\n\n### Example:\n\n```typescript\n// api/types.ts\nexport type Post = {\n  UserId: number\n  title: string\n  body: string\n}\n\nexport type PostsListItem = {\n  UserId: number\n  id: number\n  title: string\n  body: string\n}\n```\n\n```typescript\n// /api/posts/index.ts\n\nimport { DefineMethods } from 'aspida'\nimport { Post, PostsListItem } from '~/api/types'\n\nexport type Methods = DefineMethods\u003c{\n  get: {\n    resBody: PostsListItem[]\n  }\n  post: {\n    reqBody: Post\n    resBody: Post\n  }\n}\u003e\n```\n\n```typescript\n// app.vue\n\n\u003ctemplate\u003e\n  \u003cdiv\u003e\n    \u003ch1\u003eHello World!\u003c/h1\u003e\n    \u003cbutton @click=\"getPosts\"\u003eGet Posts\u003c/button\u003e\n  \u003c/div\u003e\n\u003c/template\u003e\n\u003cscript lang=\"ts\" setup\u003e\nconst getPosts = async () =\u003e {\n  const response = await useApi().posts.get()\n}\n\u003c/script\u003e\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehsan-shv%2Fnuxt-api-layer-aspida","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehsan-shv%2Fnuxt-api-layer-aspida","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehsan-shv%2Fnuxt-api-layer-aspida/lists"}