{"id":25866305,"url":"https://github.com/struckchure/xrpc","last_synced_at":"2026-05-09T12:36:04.072Z","repository":{"id":279083570,"uuid":"937672018","full_name":"struckchure/xrpc","owner":"struckchure","description":"RPC Framework for Golang","archived":false,"fork":false,"pushed_at":"2025-02-26T19:27:49.000Z","size":63,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-26T19:34:06.505Z","etag":null,"topics":["golang","grpc","microservices","rpc"],"latest_commit_sha":null,"homepage":"https://xrpc.vercel.app","language":"Go","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/struckchure.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":"2025-02-23T16:26:58.000Z","updated_at":"2025-02-26T19:27:53.000Z","dependencies_parsed_at":"2025-02-26T19:34:09.341Z","dependency_job_id":null,"html_url":"https://github.com/struckchure/xrpc","commit_stats":null,"previous_names":["struckchure/go-trpc","struckchure/xrpc"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/struckchure%2Fxrpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/struckchure%2Fxrpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/struckchure%2Fxrpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/struckchure%2Fxrpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/struckchure","download_url":"https://codeload.github.com/struckchure/xrpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241448574,"owners_count":19964470,"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":["golang","grpc","microservices","rpc"],"created_at":"2025-03-02T02:29:35.582Z","updated_at":"2026-05-09T12:35:59.028Z","avatar_url":"https://github.com/struckchure.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./images/logo-w-text.png\" width=\"100px\" /\u003e\n\u003c/p\u003e\n\n# xRPC\n\nThis project was inspired by [TRPC](https://trpc.io) and [Zod](https://zod.dev). It provides a simple and flexible way to define and validate input for HTTP procedures using [Echo](https://echo.labstack.com) as the HTTP server.\n\n## Features\n\n- **Validation**: Define validation rules for your input types.\n- **Procedures**: Create query and mutation procedures with type-safe input and output.\n- **Echo Integration**: Easily integrate with Echo to handle HTTP requests and responses.\n\n## Installation\n\nTo install the library, run:\n\n```bash\ngo get github.com/struckchure/xrpc\n```\n\n## Usage\n\n### Define Your Types\n\nDefine the types for your input and output:\n\n```go\ntype Post struct {\n  Id      int    `json:\"id\"`\n  Title   string `json:\"title\"`\n  Content string `json:\"content\"`\n}\n\ntype ListPostInput struct {\n  Skip  *int `query:\"skip\" json:\"skip\"`\n  Limit *int `query:\"limit\" json:\"limit\"`\n}\n\ntype CreatePostInput struct {\n  Title   string `json:\"title\"`\n  Content string `json:\"content\"`\n}\n\ntype GetPostInput struct {\n  Id       *int   `query:\"id\" json:\"id\"`\n  AuthorId string `query:\"author_id\" json:\"author_id\"`\n}\n```\n\n### Create Procedures\n\nCreate procedures for listing posts, creating a post, and getting a post:\n\n```go\nfunc main() {\n  t := xrpc.InitTRPC()\n\n  listPostsProcedure := xrpc.NewProcedure[ListPostInput, []Post](\"list\").\n    Input(xrpc.NewValidator().\n      Field(\"Skip\", xrpc.Number().Min(0).Required()).\n      Field(\"Limit\", xrpc.Number().Max(10)),\n    ).\n    Query(func(c xrpc.Context[ListPostInput, []Post]) error {\n      return c.Json(200, []Post{})\n    })\n\n  createPostProcedure := xrpc.NewProcedure[CreatePostInput, *Post](\"create\").\n    Input(xrpc.NewValidator().\n      Field(\"Title\", xrpc.String().MinLength(10)).\n      Field(\"Content\", xrpc.String().MinLength(10)),\n    ).\n    Mutation(func(c xrpc.Context[CreatePostInput, *Post]) error {\n      return c.Json(201, \u0026Post{})\n    })\n\n  getPostProcedure := xrpc.NewProcedure[GetPostInput, *Post](\"get\").\n    Input(xrpc.NewValidator().\n      Field(\"Id\", xrpc.Number().Required()).\n      Field(\"AuthorId\", xrpc.String()),\n    ).\n    Query(func(c xrpc.Context[GetPostInput, *Post]) error {\n      return c.Json(200, \u0026Post{})\n    })\n\n  listPostsProcedure(t)\n  createPostProcedure(t)\n  getPostProcedure(t)\n\n  t.Start(9090)\n}\n```\n\n### Running the HTTP Server\n\nThe `main` function initializes the TRPC instance, defines the procedures, and starts the Echo HTTP server on port 9090.\n\n## Custom Validation Library\n\nThe custom validation library provides a fluent API for defining validation rules. The library supports validation for various types such as strings and numbers, and allows specifying custom error messages.\n\n### Example Usage\n\n```go\nvalidator := xrpc.NewValidator().\n  Field(\"Name\", xrpc.String().MinLength(3).MaxLength(50)).\n  Field(\"Email\", xrpc.String().Email()).\n  Field(\"Age\", xrpc.Number().Min(18).Max(65))\n\nerr := validator.Validate(input)\nif err != nil {\n  // handle validation error\n}\n```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Acknowledgements\n\n- [TRPC](https://xrpc.io)\n- [Zod](https://zod.dev)\n- [Echo](https://echo.labstack.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstruckchure%2Fxrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstruckchure%2Fxrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstruckchure%2Fxrpc/lists"}