{"id":20645130,"url":"https://github.com/jesusgraterol/api-response-utils","last_synced_at":"2025-09-26T20:30:25.943Z","repository":{"id":242247043,"uuid":"808748148","full_name":"jesusgraterol/api-response-utils","owner":"jesusgraterol","description":"The api-response-utils package streamlines RESTful API data exchange by introducing a standardized data structure for HTTP response bodies. This structure simplifies client-side data handling, promoting consistency and readability in your API interactions.","archived":false,"fork":false,"pushed_at":"2024-12-03T15:38:03.000Z","size":75,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-04T13:03:23.740Z","etag":null,"topics":["api","api-response","api-rest","api-restful","body","http","http-body","rest","rest-api","restful","restful-api","utilities","utils"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/api-response-utils","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/jesusgraterol.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":"2024-05-31T18:21:35.000Z","updated_at":"2024-12-30T13:44:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"819865db-24b1-4b52-b627-7532f0198625","html_url":"https://github.com/jesusgraterol/api-response-utils","commit_stats":null,"previous_names":["jesusgraterol/api-response-utils"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jesusgraterol%2Fapi-response-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jesusgraterol%2Fapi-response-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jesusgraterol%2Fapi-response-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jesusgraterol%2Fapi-response-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jesusgraterol","download_url":"https://codeload.github.com/jesusgraterol/api-response-utils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234339823,"owners_count":18816732,"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","api-response","api-rest","api-restful","body","http","http-body","rest","rest-api","restful","restful-api","utilities","utils"],"created_at":"2024-11-16T16:18:47.700Z","updated_at":"2025-09-26T20:30:25.924Z","avatar_url":"https://github.com/jesusgraterol.png","language":"TypeScript","readme":"# API Response Utils\n\nThe `api-response-utils` package streamlines RESTful API data exchange by introducing a standardized data structure for HTTP response bodies. This structure simplifies client-side data handling, promoting consistency and readability in your API interactions.\n\n\n\n\n\n\u003c/br\u003e\n\n## Getting Started\n\nInstall the package:\n```bash\nnpm i -S api-response-utils\n```\n\n### Examples\n\nBuilding a successful response:\n\n```typescript\nimport { buildResponse } from 'api-response-utils';\n\nbuildResponse();\n// {\n//   success: true,\n//   data: undefined,\n//   error: undefined\n// }\n\n// building a successful response w/ data:\nbuildResponse({ id: 1, nickname: 'Jane Doe' });\n// {\n//   success: true,\n//   data: { id: 1, nickname: 'Jane Doe' },\n//   error: undefined\n// }\n```\n\n\u003cbr/\u003e\n\nBuilding an unsuccessful response:\n\n```typescript\nimport { buildResponse } from 'api-response-utils';\n\nbuildResponse(undefined, new Error('The user was not found in the db.'));\n// {\n//   success: false,\n//   data: undefined,\n//   error: 'The user was not found in the db.'\n// }\n```\n\n\u003cbr/\u003e\n\nChecking if a value is a response object:\n\n```typescript\nimport { isResponse } from 'api-response-utils';\n\nisResponse({ \n  success: true,\n  data: { id: 1, nickname: 'Jane Doe' },\n  error: undefined,\n});\n// true\n\nisResponse({ foo: 'bar' });\n// false\n```\n\n\n\n\n\n\u003cbr/\u003e\n\n## Types\n\n```typescript\n/**\n * API Response\n * The response object that is sent to the client via the HTTP body.\n */\ninterface IAPIResponse\u003cT\u003e {\n  // a response is considered to be successful if error === undefined\n  success: boolean,\n\n  // the data that will be sent to the client (regardless of the request's outcome)\n  data: T,\n\n  // the error thrown during the handling of the request (if any)\n  error: string | undefined\n}\n```\n\n\n\n\n\n\u003cbr/\u003e\n\n## Built With\n\n- TypeScript\n\n\n\n\n\u003cbr/\u003e\n\n## Running the Tests\n\n```bash\nnpm run test:unit\n```\n\n\n\n\n\n\u003cbr/\u003e\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjesusgraterol%2Fapi-response-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjesusgraterol%2Fapi-response-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjesusgraterol%2Fapi-response-utils/lists"}