{"id":16720218,"url":"https://github.com/jorgevrgs/fastify-type-provider-yup","last_synced_at":"2026-04-24T12:32:32.684Z","repository":{"id":194205699,"uuid":"690306613","full_name":"jorgevrgs/fastify-type-provider-yup","owner":"jorgevrgs","description":"Type provider, serializer and validator compiler using Yup schemas for Fastify v4/v5","archived":false,"fork":false,"pushed_at":"2026-02-16T14:13:27.000Z","size":400,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-16T21:42:51.941Z","etag":null,"topics":["fastify","fastify-plugins","typescript","yup"],"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/jorgevrgs.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-09-12T00:20:11.000Z","updated_at":"2025-09-16T22:14:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"8a51b2f7-d990-4cb1-9d30-4f036030a0f2","html_url":"https://github.com/jorgevrgs/fastify-type-provider-yup","commit_stats":null,"previous_names":["jorgevrgs/fastify-type-provider-yup"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/jorgevrgs/fastify-type-provider-yup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgevrgs%2Ffastify-type-provider-yup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgevrgs%2Ffastify-type-provider-yup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgevrgs%2Ffastify-type-provider-yup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgevrgs%2Ffastify-type-provider-yup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jorgevrgs","download_url":"https://codeload.github.com/jorgevrgs/fastify-type-provider-yup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jorgevrgs%2Ffastify-type-provider-yup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32223933,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T10:26:35.452Z","status":"ssl_error","status_checked_at":"2026-04-24T10:25:27.643Z","response_time":64,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-plugins","typescript","yup"],"created_at":"2024-10-12T22:06:15.210Z","updated_at":"2026-04-24T12:32:32.668Z","avatar_url":"https://github.com/jorgevrgs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastify-type-provider-yup\n\n[![NPM Version](https://img.shields.io/npm/v/fastify-type-provider-yup.svg)](https://npmjs.org/package/fastify-type-provider-yup) [![CI](https://github.com/jorgevrgs/fastify-type-provider-yup/actions/workflows/tests.yml/badge.svg)](https://github.com/jorgevrgs/fastify-type-provider-yup/actions/workflows/tests.yml)\n\n## Getting Started\n\n```sh\npnpm add fastify-type-provider-yup\nyarn add fastify-type-provider-yup\nnpm i fastify-type-provider-yup\n```\n\n| Package | Version | Fastify Compatibility |\n| ------- | ------- | --------------------- |\n| `pnpm add fastify-type-provider-yup@4` | 4.x | 4.x |\n| `pnpm add fastify-type-provider-yup@5` | 5.x | 5.x |\n\n## How to use\n\nSee [Examples](./examples) folder for more details.\n\n### Register Fastify plugin:\n\n```js\nimport { yupPlugin } from 'fastify-type-provider-yup';\nimport fp from 'fastify-plugin';\n\nexport const example = async (fastify) =\u003e {\n  fastify.register(fp(yupPlugin));\n};\n```\n\n### Manually registered with Typescript:\n\n```ts\nimport Fastify from \"fastify\";\nimport {\n  serializerCompiler,\n  validatorCompiler,\n  type YupTypeProvider\n} from 'fastify-type-provider-yup';\nimport * as yup from yup\n\nconst server = Fastify()\n\nserver.withTypeProvider\u003cwithTypeProvider\u003e().route({\n  method: 'POST',\n  url: '/',\n  schema: {\n    body: yup.object({\n      foo: yup.string().required()\n    }),\n    querystring: yup.object({\n      page: yup.number().default(1)\n    }),\n    response: {\n      200: yup.string()\n    }\n  },\n  handler: async (reques, reply) =\u003e {\n    const { foo } = request.body\n    const { page } = request.querystring\n    return `Received ${foo} for page ${page}`\n  }\n})\n\nserver.listen({port: 1337, host: '0.0.0.0'})\n```\n\n### Swagger\n\n```typescript\nimport fastifySwagger from '@fastify/swagger';\nimport fastifySwaggerUI from '@fastify/swagger-ui';\nimport Fastify from 'fastify';\nimport * as yup from 'yup';\nimport {\n  type YupTypeProvider,\n  validatorCompiler,\n  serializerCompiler,\n  jsonSchemaTransformer,\n} from 'fastify-type-provider-yup';\nimport { extendSchema } from '@sodaru/yup-to-json-schema';\nimport { Schema, addMethod } from 'yup';\n\nextendSchema({ addMethod, Schema });\n\nconst app = Fastify({ logger: true });\napp.setValidatorCompiler(validatorCompiler);\napp.setSerializerCompiler(serializerCompiler);\n\napp.register(fastifySwagger, {\n  openapi: {\n    info: {\n      title: 'SampleApi',\n      description: 'Sample backend service',\n      version: '1.0.0',\n    },\n    servers: [],\n  },\n  transform: jsonSchemaTransformer,\n});\n\napp.register(fastifySwaggerUI, {\n  routePrefix: '/docs',\n});\n\napp.after(() =\u003e {\n  app.withTypeProvider\u003cYupTypeProvider\u003e().route({\n    url: '/',\n    method: 'POST',\n    schema: {\n      description: 'Description details',\n      tags: ['home'],\n      body: yup.object({\n        page: yup.number().default(1),\n      }),\n      response: {\n        200: yup.object({\n          page: yup.string().example('1'),\n        }),\n      },\n    },\n    handler: async (request, reply) =\u003e {\n      const { page } = request.body;\n\n      return {\n        page: String(page),\n      };\n    },\n  });\n});\n\napp.listen({ port: 8080, host: '0.0.0.0' });\n```\n\n## Aknowledgements\n\nModule heavilty inspired by:\n\n- [fastify-type-provider-zod](https://github.com/turkerdev/fastify-type-provider-zod)\n- [fastify-yup-schema](https://github.com/balcieren/fastify-yup-schema)\n\n\n## Benchmarks\n\nRun:\n\nGo to folder `/benchmarks` and run the benchmark server:\n\n```sh\nnode (both|serializer|validation)-(json|yup|zod).benchmark.cjs\n```\n\nThen run:\n\n```sh\nautocannon http://localhost:3000\n```\n\nFind below the results using a MacBook Pro (16-inch, Apple M1 Pro, 2021, Sonoma 14.6.1) with 16 GB of RAM.\n\n### Serializer Results (Avg.)\n\n| Name | Version | Req/sec | Latency (ms) | Bytes/sec | Requests|\n| --- | --- | --- | --- | --- | --- |\n| fastify-type-provider-yup | 0.0.5 |  65,521.46 (84.58 %) | 0.01 | 12.3 MB | 721k req in 11.01s, 135 MB read  |\n| fastify-type-provider-zod | 2.0.0 |  77,119.00 (99.55 %) | 0.01 | 14.5 MB | 805k req in 11.01 s, 151 MB read |\n| fastify (raw) | 4.23.0 |  77,464.55 | 0.01 | 14.6 MB | 854k req in 11.01 s, 161 MB read |\n\n### Validation Results (Avg.)\n\n| Name | Version | Req/sec | Latency (ms) | Bytes/sec | Requests|\n| --- | --- | --- | --- | --- | --- |\n| fastify-type-provider-yup | 0.0.5 |  63,902.55 (89.74 %) | 0.01 | 11.6 MB | 703k req in 11.01s, 127 MB read  |\n| fastify-type-provider-zod | 2.0.0 |  70,893.10 (99.56 %) | 0.01 | 12.8 MB | 780k req in 11.01 s, 141 MB read |\n| fastify (raw) | 4.23.0 |  71,207.28 | 0.01 | 12.9 MB | 783k req in 11.02 s, 142 MB read |\n\n### Validation And Serialization Results (Avg.)\n\n| Name | Version | Req/sec | Latency (ms) | Bytes/sec | Requests|\n| --- | --- | --- | --- | --- | --- |\n| fastify-type-provider-yup | 0.0.5 |  57,133.10 (73.38 %) | 0.01 | 10.5 MB | 629k req in 11.01s, 115 MB read  |\n| fastify-type-provider-zod | 2.0.0 |  51,389.82 (66.00 %) | 0.01 | 9.4 MB | 565k req in 11.01 s, 103 MB read |\n| fastify (raw) | 4.23.0 |  77,861.82 | 0.01 | 14.2 MB | 856k req in 11.01 s, 157 MB read |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorgevrgs%2Ffastify-type-provider-yup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjorgevrgs%2Ffastify-type-provider-yup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorgevrgs%2Ffastify-type-provider-yup/lists"}