{"id":17497021,"url":"https://github.com/evex-dev/singlend","last_synced_at":"2025-04-23T01:05:41.715Z","repository":{"id":258293181,"uuid":"872235757","full_name":"evex-dev/singlend","owner":"evex-dev","description":"Multiple operations on a single endpoint with hono and zod 🚀","archived":false,"fork":false,"pushed_at":"2024-10-17T13:34:11.000Z","size":45,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T01:05:31.747Z","etag":null,"topics":["hono","singlend","zod"],"latest_commit_sha":null,"homepage":"https://evex.land","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/evex-dev.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":"2024-10-14T04:47:22.000Z","updated_at":"2025-02-08T08:16:18.000Z","dependencies_parsed_at":"2024-10-18T10:20:11.935Z","dependency_job_id":null,"html_url":"https://github.com/evex-dev/singlend","commit_stats":null,"previous_names":["evex-dev/singlend"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evex-dev%2Fsinglend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evex-dev%2Fsinglend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evex-dev%2Fsinglend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evex-dev%2Fsinglend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evex-dev","download_url":"https://codeload.github.com/evex-dev/singlend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250349054,"owners_count":21415914,"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":["hono","singlend","zod"],"created_at":"2024-10-19T15:09:58.210Z","updated_at":"2025-04-23T01:05:41.700Z","avatar_url":"https://github.com/evex-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# singlend\n\nMultiple operations on a single endpoint with hono and zod 🚀\n\nWhen using singlend, headers and cookies are anti-patterns ✖ Everything is\nmanaged by the body, so session should be stored in localStorage, etc.\\\nIt is more secure 🔓\n\n- 🔥 Support Hono RPC Client\n- 🌪️ Fastest\n- 🌍️ Support All Runtime\n- 🧩 Highly Typed\n\n## How to use\n\n```bash\nnpx jsr add @evex/singlend\nbunx jsr add @evex/singlend\ndeno add @evex/singlend\n```\n\n```ts\nimport { Hono } from \"@hono/hono\";\nimport { z } from \"zod\";\nimport { Singlend } from \"@evex/singlend\";\nimport { hc } from \"@hono/hono/client\";\n\nconst app = new Hono();\nconst singlend = new Singlend();\n\nconst sub = singlend.on(\n\t\"getIcon\",\n\tz.object({}),\n\t(_query, ok) =\u003e {\n\t\treturn ok({\n\t\t\ticonUrl: \"default.png\",\n\t\t});\n\t},\n);\n\nconst singleRoute = singlend\n\t.group(\n\t\tz.object({\n\t\t\tid: z.string(),\n\t\t}),\n\t\t(query, next, error) =\u003e {\n\t\t\tif (!query.id.startsWith(\"@\")) {\n\t\t\t\treturn error({\n\t\t\t\t\tmessage: \"Invalid id\",\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\treturn next({\n\t\t\t\t\tid: query.id.slice(1),\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\t(singlend) =\u003e\n\t\t\tsinglend.on(\n\t\t\t\t\"setIcon\",\n\t\t\t\tz.object({\n\t\t\t\t\ticonUrl: z.string(),\n\t\t\t\t}),\n\t\t\t\t(query, value, ok) =\u003e\n\t\t\t\t\tok({\n\t\t\t\t\t\tmessage: \"Set icon of \" + value.id + \" to \" +\n\t\t\t\t\t\t\tquery.iconUrl,\n\t\t\t\t\t}),\n\t\t\t),\n\t)\n\t.on(\n\t\t\"setBackgroundColor\",\n\t\tz.object({\n\t\t\tbackgroundColor: z.string().length(7),\n\t\t}),\n\t\t(query, ok, error) =\u003e {\n\t\t\tif (!query.backgroundColor.startsWith(\"#\")) {\n\t\t\t\treturn error({\n\t\t\t\t\tmessage: \"Invalid background color\",\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn ok({\n\t\t\t\tmessage: \"Set background color to \" + query.backgroundColor,\n\t\t\t});\n\t\t},\n\t)\n\t.mount(sub);\n\nconst routes = app.post(\"/api/singlend\", singleRoute.handler());\n\n// launch server\n\n// in client\nconst client = hc\u003ctypeof routes\u003e(\"/\");\n\nconst response = await client.api.singlend.$post({\n\tjson: {\n\t\ttype: \"setIcon\",\n\t\tquery: {\n\t\t\tid: \"@12345\",\n\t\t\ticonUrl: \"default.png\",\n\t\t},\n\t},\n});\n\nconst data = await response.json();\n```\n\n```ts\nfetch(\"/api/singlend\", {\n\tmethod: \"POST\",\n\tbody: JSON.stringify({\n\t\ttype: \"setIcon\",\n\t\tquery: {\n\t\t\tid: \"@114514\",\n\t\t\ticonUrl: \"default.png\",\n\t\t},\n\t}),\n});\n```\n\nMore:\n[https://jsr.io/@evex/singlend/doc/~/Singlend](https://jsr.io/@evex/singlend/doc/~/Singlend)\n\n## Authors\n- @EdamAme-x \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevex-dev%2Fsinglend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevex-dev%2Fsinglend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevex-dev%2Fsinglend/lists"}