{"id":19419071,"url":"https://github.com/launchcodedev/api-fields-middleware","last_synced_at":"2026-06-17T11:31:58.022Z","repository":{"id":42799275,"uuid":"271835445","full_name":"launchcodedev/api-fields-middleware","owner":"launchcodedev","description":"API Fields, as composable koa middleware","archived":false,"fork":false,"pushed_at":"2023-01-24T02:54:04.000Z","size":1342,"stargazers_count":2,"open_issues_count":11,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-25T03:43:32.221Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/launchcodedev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-12T15:49:02.000Z","updated_at":"2020-12-12T21:30:08.000Z","dependencies_parsed_at":"2023-02-13T13:31:09.156Z","dependency_job_id":null,"html_url":"https://github.com/launchcodedev/api-fields-middleware","commit_stats":null,"previous_names":["servall/api-fields-middleware"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/launchcodedev/api-fields-middleware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchcodedev%2Fapi-fields-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchcodedev%2Fapi-fields-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchcodedev%2Fapi-fields-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchcodedev%2Fapi-fields-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/launchcodedev","download_url":"https://codeload.github.com/launchcodedev/api-fields-middleware/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchcodedev%2Fapi-fields-middleware/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34447264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-10T13:16:04.933Z","updated_at":"2026-06-17T11:31:58.006Z","avatar_url":"https://github.com/launchcodedev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# API Fields Middlware\n[![Licensed under MPL 2.0](https://img.shields.io/badge/license-MPL_2.0-green.svg)](https://www.mozilla.org/en-US/MPL/2.0/)\n[![Build Status](https://github.com/launchcodedev/api-fields-middleware/workflows/CI/badge.svg)](https://github.com/launchcodedev/api-fields-middleware/actions)\n[![npm](https://img.shields.io/npm/v/@lcdev/api-fields-middleware.svg)](https://www.npmjs.com/package/@lcdev/api-fields-middleware)\n\nUse API Fields easily in Koa.\n\n```bash\nyarn add @lcdev/api-fields-middleware@0.1\n```\n\n```typescript\nimport { ApiField } from '@lcdev/api-fields';\n\n// somewhere, where your model is defined\nclass EntityA {\n  @ApiField()\n  publicFieldA: any;\n\n  @ApiField()\n  publicFieldB: any;\n\n  privateFieldA: any;\n  privateFieldB: any;\n}\n\nimport { extractApiFieldsMiddleware } from '@lcdev/api-fields-middleware';\n\n// somewhere, where you have a koa router\napp\n  .get('/foo/bar', extractApiFieldsMiddleware(EntityA), async (ctx, next) =\u003e {\n    // the body ends up as an object that is, or looks like an 'EntityA'\n    ctx.body = new EntityA();\n\n    return next();\n  });\n```\n\nThis will perform the `extract` with `ApiFields` of `EntityA`, after your router\nmiddleware has run. This will only apply **if the response is a 200**.\n\nFeatures:\n- Supports `extractApiFieldsMiddleware([EntityA])` to imply that the api response is an array of EntityA\n- Supports `extractApiFieldsMiddleware({ ... }, true)` to pass a \"raw\" `Extraction` object to use (you might use `getApiFields` with an extension here)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchcodedev%2Fapi-fields-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaunchcodedev%2Fapi-fields-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchcodedev%2Fapi-fields-middleware/lists"}