{"id":17493580,"url":"https://github.com/elmariachi111/fastify-api-demo","last_synced_at":"2026-04-15T09:31:31.183Z","repository":{"id":148865186,"uuid":"362081090","full_name":"elmariachi111/fastify-api-demo","owner":"elmariachi111","description":"a sample repository how to build REST/GQL APIs in Typescript centered around entity definitions using Fastify","archived":false,"fork":false,"pushed_at":"2021-05-02T12:04:50.000Z","size":83,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-01T13:21:53.262Z","etag":null,"topics":["fastify","graphql","rest-api","typegraphql","typeorm","typescript"],"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/elmariachi111.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":"2021-04-27T11:03:47.000Z","updated_at":"2021-05-02T12:07:08.000Z","dependencies_parsed_at":"2023-07-09T10:01:05.430Z","dependency_job_id":null,"html_url":"https://github.com/elmariachi111/fastify-api-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/elmariachi111/fastify-api-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elmariachi111%2Ffastify-api-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elmariachi111%2Ffastify-api-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elmariachi111%2Ffastify-api-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elmariachi111%2Ffastify-api-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elmariachi111","download_url":"https://codeload.github.com/elmariachi111/fastify-api-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elmariachi111%2Ffastify-api-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31834506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T07:17:56.427Z","status":"ssl_error","status_checked_at":"2026-04-15T07:17:30.007Z","response_time":63,"last_error":"SSL_read: 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","graphql","rest-api","typegraphql","typeorm","typescript"],"created_at":"2024-10-19T12:08:41.775Z","updated_at":"2026-04-15T09:31:31.164Z","avatar_url":"https://github.com/elmariachi111.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fastify in Typescript with Graphql, Typeorm \u0026 Tests\n\nI've been a seasoned and very satisfied user of PHP's [API Platform](https://api-platform.com/) and since I'm still looking for a framework that lets me build APIs equally swiftly, I evaluated a lot of libraries in the JS space. [Fastify](https://www.fastify.io) turned out to be one promising candidate for the foundation. \n\n\nEven though it's a much more general purpose framework, it deals with many advantages that API Platform comes with.\n\nAfter cloning you can test it yourself:\n```\nyarn\nyarn run test\nyarn run dev\n```\n\nThe administrative endpoints are\n```\nhttp://localhost:3000/docs\nhttp://localhost:3000/graphql\n```\n\n\nThis application demonstrates REST API based persistence based on entity definitions. I defined two entities (Token, Transaction) that relate to each other as one to many. \n\nIt's using\n- [TypeORM](https://typeorm.io/#/) as persistence layer (analoguous to DoctrineORM)\n- [TypeGraphQL](https://typegraphql.com/) for GraphQL definitions\n- [TypeDI](https://www.npmjs.com/package/typedi) for dependency injection (mandatory for TypeGraphQL's ORM resolvers)\n- Fastify's JSON schema support and [typebox](https://github.com/sinclairzx81/typebox) for Typescript translation\n- [fastify-swagger](https://github.com/fastify/fastify-swagger) to generate a dynamic OpenAPI documentation\n- mocha as test runner\n- declaration merging for type safety and IDE completion \n\n## Opinion\n\nThere are lesser cobbles on the path to glory when you use API Platform. It's built around Doctrine ORM and JSON-LD and allows you to build complete REST APIs out of simple entity definitions by adding a mere `ApiResource` annotation. \n\nIn this repository's approach you'll still have to define schemas and fastify types along your entity (it's likely possible to infer them by analyzing the entity types but that's not clearly documented).\n\nIn this approach it's far more obvious  how to customize things since you're not relying on an opinionated framework. That leads to more boilerplate code but makes you feel much more in control after all.\n\n## execute migrations\n\ngen\nyarn run typeorm migration:generate -n initial -f src/config/ormconfig.json\n\nrun\nyarn run typeorm migration:run -f src/config/ormconfig.json","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felmariachi111%2Ffastify-api-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felmariachi111%2Ffastify-api-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felmariachi111%2Ffastify-api-demo/lists"}