{"id":30058930,"url":"https://github.com/tinchoz49/fastify-typebox-module","last_synced_at":"2026-05-20T14:09:07.441Z","repository":{"id":276677397,"uuid":"929958789","full_name":"tinchoz49/fastify-typebox-module","owner":"tinchoz49","description":"A Fastify plugin that enables the use of TypeBox module types by registering them as standard AJV schemas.","archived":false,"fork":false,"pushed_at":"2025-07-08T12:39:13.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-14T15:23:31.892Z","etag":null,"topics":["fastify","fastify-plugin","plugin","typebox"],"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/tinchoz49.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-09T19:36:51.000Z","updated_at":"2025-07-08T14:28:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"fbec9440-a1eb-4662-a705-d2a7f761cf1f","html_url":"https://github.com/tinchoz49/fastify-typebox-module","commit_stats":null,"previous_names":["tinchoz49/fastify-typebox-module-types","tinchoz49/fastify-typebox-module"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tinchoz49/fastify-typebox-module","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinchoz49%2Ffastify-typebox-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinchoz49%2Ffastify-typebox-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinchoz49%2Ffastify-typebox-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinchoz49%2Ffastify-typebox-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinchoz49","download_url":"https://codeload.github.com/tinchoz49/fastify-typebox-module/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinchoz49%2Ffastify-typebox-module/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28335207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"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":["fastify","fastify-plugin","plugin","typebox"],"created_at":"2025-08-08T00:37:59.436Z","updated_at":"2026-01-12T05:32:52.695Z","avatar_url":"https://github.com/tinchoz49.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastify-typebox-module\n\n\u003e A plugin for Fastify that allows you to use TypeBox module schemas and register them as normal ajv schemas.\n\n![Tests](https://github.com/tinchoz49/fastify-typebox-module/actions/workflows/test.yml/badge.svg)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard--ext-05ae89.svg)](https://github.com/tinchoz49/eslint-config-standard-ext)\n[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat)](https://github.com/RichardLitt/standard-readme)\n\n## Install\n\n```bash\n$ npm install fastify-typebox-module\n```\n\n## Usage\n\n```ts\nimport { type TypeBoxTypeProvider } from '@fastify/type-provider-typebox'\nimport { Type } from '@sinclair/typebox'\nimport fastify from 'fastify'\nimport fastifyTypeboxModule, { type SchemaType } from 'fastify-typebox-module'\n\nconst schemas = {\n  UserParams: Type.Object({\n    id: Type.String(),\n  }),\n  User: Type.Object({\n    id: Type.String(),\n    name: Type.String(),\n    address: Type.Ref('Address'),\n    phones: Type.Array(Type.Ref('Phone')),\n  }),\n  Address: Type.Object({\n    street: Type.String(),\n    city: Type.String(),\n    zip: Type.String(),\n  }),\n  Phone: Type.Object({\n    number: Type.String(),\n  }),\n}\n\ndeclare module 'fastify-typebox-module' {\n  interface FastifyTypeboxModule {\n    schemas: typeof schemas\n  }\n}\n\nconst app = fastify().withTypeProvider\u003cTypeBoxTypeProvider\u003e()\n\n// this is important to wait for the schemas to be registered before using them in the routes\nawait app.register(fastifyTypeboxModule, {\n  schemas,\n})\n\n// You can also access the TypeBox schema type directly with autocompletion\ntype User = SchemaType\u003c'User'\u003e\n\napp.get('/user/:id', {\n  schema: {\n    params: app.typeboxModule.ref('UserParams'),\n    response: {\n      200: app.typeboxModule.ref('User'),\n    },\n  },\n  handler: async (request, reply) =\u003e {\n    const { id } = request.params\n\n    const user = {\n      id,\n      name: 'John Doe',\n      address: { street: '123 Main St', city: 'Anytown', zip: '12345' },\n      phones: [{ number: '123-456-7890' }],\n    }\n\n    return user\n  },\n})\n```\n\nThe schemas are going to be register, compiled and be available as normal ajv schemas, then you can reference any schema by using `app.typeboxModule.ref` and it will work as expected validating the request schemas, response schemas and their types.\n\n## Important\n\nThis plugin is not compatible with the `TypeCompiler` of `@fastify/type-provider-typebox`, it only works with the built-in AJV compiler.\n\n## Issues\n\n:bug: If you found an issue we encourage you to report it on [github](https://github.com/tinchoz49/fastify-typebox-module/issues). Please specify your OS and the actions to reproduce it.\n\n## Contributing\n\n:busts_in_silhouette: Ideas and contributions to the project are welcome. You must follow this [guideline](https://github.com/tinchoz49/fastify-typebox-module/blob/main/CONTRIBUTING.md).\n\n## License\n\nMIT © 2025 Martin Acosta\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinchoz49%2Ffastify-typebox-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinchoz49%2Ffastify-typebox-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinchoz49%2Ffastify-typebox-module/lists"}