Fetch api.orders.getAll with these arguments a,b,c \r\n\r\n```\r\ncomments: \r\n- I left out the comments as I don't know how to document it right, so here are some comments. \r\n- is use proxies to solve the missing key errors. \r\n- Functions are needed making it possible to be `api.orders` and `api.orders()`. \r\n- _path saves the path like `api.orders.getAll`\r\n- When somewhere a function is called, handlers.apply is called. \r\n- this is *an* implementation not *the* implementation, rather a proof of concept. I use the proxy syntax never, but vue's reactivity system uses it.\r\n\r\n## Final notes\r\nI trying my best to make it easy to grasp, Try the code provided in technical details in your own sandbox to understand a little bit better how it works. Personally, I think this is the easiest syntax as it feels like your calling a function on your backend. I also understand this not Graphql like syntax. Potentially you can have multiple client interfaces. To be honest, I only know this library for a couple of days, because Theo appeared in my youtube feed. So I also don't know if this syntax is in line with the vision of trpc. \r\n\r\nAfter all, I still wanted to show this javascript trickery and proposal, especially after the many hours figuring it out. Do not hesitate to ask further questions if something is unclear. \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n",[2931],{"name":2932,"color":2933},"💡 ideas","bfdadc",2215,"Documentation Proxy Api and @trcp/client","2022-10-04T06:09:12Z","https://github.com/trpc/trpc/issues/2215",0.68319476,{"description":2940,"labels":2941,"number":2945,"owner":2868,"repository":2868,"state":2869,"title":2946,"updated_at":2947,"url":2948,"score":2949},"Would you be open to adding an API Gateway adapter? I haven't dived in deeply enough to the express and standalone ones to know exactly what it'd entail, but here's our current approach:\r\n\r\n```ts\r\nimport * as trpc from '@trpc/server'\r\nimport * as trpcExpress from '@trpc/server/adapters/express'\r\nimport {z} from 'zod'\r\nimport serverless from 'serverless-http'\r\nimport express from 'express'\r\n\r\nconst appRouter = trpc.router\u003C{foo: string}>().query('getUser', {\r\n input: z.string(),\r\n async resolve(req) {\r\n return {id: req.input, name: 'Bilbo', now: Date.now()}\r\n },\r\n})\r\n\r\nexport const app = express()\r\n\r\napp.use(\r\n trpcExpress.createExpressMiddleware({\r\n router: appRouter,\r\n createContext: () => ({foo: 'bar'}),\r\n }),\r\n)\r\n\r\nexport const handler = serverless(app)\r\n\r\nexport type AppRouter = typeof appRouter\r\n```\r\n\r\nWhich is fine, but we're relying on the `serverless-http` library to do all the magic hacks that make our _entire_ backend work. And it doesn't feel right that we need express and serverless-http as prod dependencies at all, since API Gateway lambdas are actually already kind of closer to what trpc/server does in the first place, I think (just functions that take inputs and return promise outputs, rather than weird `res.status(...).send(...)` side-effects). How I imagine it could look:\r\n\r\n```ts\r\nimport * as trpc from '@trpc/server'\r\nimport * as trpcApiGateway from '@trpc/server/adapters/apiGateway'\r\nimport {z} from 'zod'\r\n\r\nconst appRouter = trpc.router\u003C{foo: string}>().query('getUser', {\r\n input: z.string(),\r\n async resolve(req) {\r\n return {id: req.input, name: 'Bilbo', now: Date.now()}\r\n },\r\n})\r\n\r\nexport const handler = trpcApiGateway.createApiGatewayHandler({\r\n router: appRouter,\r\n createContext: () => ({foo: 'bar'}),\r\n})\r\n\r\nexport type AppRouter = typeof appRouter\r\n```\r\n\r\nSo I think it fits pretty neatly in alongside the other adapters. A simple API Gateway handler looks something like:\r\n\r\n```ts\r\nexport const handler = async event => {\r\n return {\r\n statusCode: 200,\r\n headers: {'x-foo': 'bar'},\r\n body: JSON.stringify({\r\n result: `Hello ${event.queryStringParameters.abc} ${event.body.def}`,\r\n }),\r\n }\r\n}\r\n```",[2942],{"name":2943,"color":2944},"💬 discussion","4B318A",709,"API Gateway adapter?","2021-07-24T08:59:13Z","https://github.com/trpc/trpc/issues/709",0.6859395,{"description":2951,"labels":2952,"number":2956,"owner":2868,"repository":2868,"state":2869,"title":2957,"updated_at":2958,"url":2959,"score":2960},"### Provide environment information\r\n\r\n System:\r\n OS: macOS 13.0\r\n CPU: (10) arm64 Apple M1 Pro\r\n Memory: 160.72 MB / 16.00 GB\r\n Shell: 5.8.1 - /bin/zsh\r\n Binaries:\r\n Node: 18.13.0 - /opt/homebrew/opt/node@18/bin/node\r\n Yarn: 1.22.19 - /opt/homebrew/bin/yarn\r\n npm: 8.19.3 - /opt/homebrew/opt/node@18/bin/npm\r\n Browsers:\r\n Chrome: 110.0.5481.177\r\n Firefox: 109.0\r\n Safari: 16.1\r\n npmPackages:\r\n @trpc/client: ^10.13.0 => 10.13.0 \r\n @trpc/server: ^10.13.0 => 10.13.0 \r\n typescript: ^4.8.3 => 4.9.5 \r\n\r\n### Describe the bug\r\n\r\nWhen sending a `GET` request to `http://localhost:2022/trpc/posts/list` using a local version of the Fastify example app, it responds with:\r\n```\r\n{\r\n \"message\": \"Route GET:/trpc/posts/list not found\",\r\n \"error\": \"Not Found\",\r\n \"statusCode\": 404\r\n}\r\n```\r\n\r\nIt seems like nested routers are causing an issue, but un-nesting them and putting the procedures in the outermost app router works fine.\r\n\r\nLink to code example https://codesandbox.io/s/elated-wildflower-cojy3t\r\n\r\n\r\n### Link to reproduction\r\n\r\nhttps://codesandbox.io/s/elated-wildflower-cojy3t\r\n\r\n### To reproduce\r\n\r\nClone the code sandbox @ https://codesandbox.io/s/elated-wildflower-cojy3t\r\nRun `yarn install`\r\nRun `yarn dev:server`\r\nSend a curl request to `http://localhost:2022/trpc/posts/list`\r\n\r\n### Additional information\r\n\r\nUsing the tRPC client directly works, but not via HTTP\r\n\r\n### 👨👧👦 Contributing\r\n\r\n- [ ] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[2953],{"name":2954,"color":2955},"👻 invalid","e4e669",3886,"bug: Nested routers with Fastify plugin not working, HTTP routes not found","2023-03-14T12:02:38Z","https://github.com/trpc/trpc/issues/3886",0.68824905,{"description":2962,"labels":2963,"number":2964,"owner":2868,"repository":2868,"state":2869,"title":2965,"updated_at":2966,"url":2967,"score":2968},"### Provide environment information\n\n```\r\n System:\r\n OS: macOS 13.1\r\n CPU: (10) arm64 Apple M1 Max\r\n Memory: 16.34 GB / 64.00 GB\r\n Shell: 5.8.1 - /bin/zsh\r\n Binaries:\r\n Node: 18.4.0 - ~/.nvm/versions/node/v18.4.0/bin/node\r\n Yarn: 1.22.19 - ~/.nvm/versions/node/v18.4.0/bin/yarn\r\n npm: 8.12.1 - ~/.nvm/versions/node/v18.4.0/bin/npm\r\n Browsers:\r\n Chrome: 110.0.5481.177\r\n Safari: 16.2\r\n npmPackages:\r\n @tanstack/react-query: ^4.24.10 => 4.24.10\r\n @trpc/client: ^10.13.2 => 10.13.2\r\n @trpc/react-query: ^10.13.2 => 10.13.2\r\n @trpc/server: ^10.13.2 => 10.13.2\r\n react: 18.1.0 => 18.1.0\r\n typescript: ^4.9.4 => 4.9.5\r\n```\n\n### Describe the bug\n\nNot sure if I want to track this as a client or a server bug, but I'm more worried about the server part.\r\n\r\nI know this request down there is not very realistic and was a result of an error where the client repeatedly asked for the same data. However I don't think this should result in a `404` from fastify.\r\n\r\nHere is the error that is happening:\r\n\r\n{\"level\":30,\"time\":1678292845000,\"pid\":739816,\"hostname\":\"ip-172-31-36-177\",\"reqId\":\"req-4\",\"msg\":\"Route GET:/trpc/outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending,outputMedia.get,outputMedia.getPending?batch=1&input=%7B%7D not found\"}\r\n\r\nUp until this point everything is fine, but this query then failed.\r\n\r\nHere's my fastify server config\r\n```ts\r\nimport initEnv from \"./lib/env\";\r\ninitEnv();\r\n\r\nimport { fastifyTRPCPlugin } from \"@trpc/server/adapters/fastify\";\r\nimport fastify from \"fastify\";\r\nimport { initFirebase } from \"./lib/firebase\";\r\nimport { mainRouter } from \"./api\";\r\nimport webHooks from \"./http-routes/web-hooks\";\r\nimport modelNotifications from \"./http-routes/model-notifications\";\r\nimport { createContext } from \"./lib/trpc\";\r\nimport {\r\n serializerCompiler,\r\n validatorCompiler,\r\n} from \"fastify-type-provider-zod\";\r\n\r\ninitFirebase();\r\n\r\nconst server = fastify({ logger: true });\r\n\r\nserver.setValidatorCompiler(validatorCompiler);\r\nserver.setSerializerCompiler(serializerCompiler);\r\n\r\nserver.register(modelNotifications);\r\nserver.register(webHooks);\r\n\r\nserver.register(fastifyTRPCPlugin, {\r\n prefix: \"/trpc\",\r\n trpcOptions: { router: mainRouter, createContext },\r\n});\r\n\r\nserver.get(\"/\", () => \"Running 🧘♀️\");\r\n\r\nserver\r\n .listen({\r\n host: \"0.0.0.0\",\r\n port: 3000,\r\n })\r\n .catch((err) => {\r\n server.log.error(err);\r\n process.exit(1);\r\n });\r\n```\r\n\n\n### Link to reproduction\n\nnone\n\n### To reproduce\n\nNot sure how to reproduce, but happens from time to time. Maybe someone has an idea just given the request.\n\n### Additional information\n\n_No response_\n\n### 👨👧👦 Contributing\n\n- [X] 🙋♂️ Yes, I'd be down to file a PR fixing this bug!",[],3950,"bug: ","2023-03-08T18:51:50Z","https://github.com/trpc/trpc/issues/3950",0.6883473,{"description":2970,"labels":2971,"number":2973,"owner":2868,"repository":2868,"state":2869,"title":2974,"updated_at":2975,"url":2976,"score":2977},"Some recommendations for improvements to the API:\r\n\r\n- I don't really see any reason to split up `@trpc/server` and `@trpc/client`. I think they should be merged into a single `trpc` module. It makes the out-of-the-box experience so much cleaner.\r\n- Then the `@trpc` scope can be used for specific plugins/adapters etc. You could publish the Express adapter as `@trpc/express` for instance. That would also let you properly specify all the requisite peerDependencies (which I don't believe are specified using the current `@trpc/server/adapters/express` approach since it doesn't have its own package.json.\r\n- I think `import * as` imports are a bad user experience. I submitted a PR with a solution.\r\n- Simplify the function names: `createTRPCClient` => `createClient`, `createNextApiHandler` => `createHandler`, `CreateNextContextOptions` => `ContextOptions`. It should be standard across adapters. It's obvious that a function called `createHandler` imported from `\"@trpc/server/adapters/next\"` is creating a Next.js API handler. It doesn't need to be in the name.\r\n- The adapters should export a `createContext` function that can automatically type `opts` with the necessary types.\r\n- I think all requests (queries and mutations) should get served from a single URL. The `path` can be added as an additional query parameter for queries and in the `body` for mutations. This would also simplify the Next/Express adapters (no need for a catchall API route).\r\n\r\n\r\nLess important:\r\n\r\nI think there should be a way of manually typing the input of a resolver without passing a validator into `input`. This is easy to do if the resolver functions had two parameters instead of one. I have this working on a local branch (type inference still works the same).\r\n\r\nI propose this syntax/convention:\r\n\r\n```ts\r\nconst router = trpc.router\u003CContext>().query('test', {\r\n resolve(input: number, req) {\r\n return input;\r\n },\r\n });\r\n```\r\n\r\nThe `req` variable above if of type `{ ctx: TContext, type: ProcedureType }`. This leaves the door open to future API expansion, as `req` can act like a catchall for any additional properties we want to pass into resolvers. ",[2972],{"name":2943,"color":2944},211,"API recommendations","2021-04-12T21:57:33Z","https://github.com/trpc/trpc/issues/211",0.68918025,["Reactive",2979],{},["Set"],["ShallowReactive",2982],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$fZvMEzxLKqjX205_LbdsuBwvdW8EC0p_Zy5MWKC0WSTA":-1},"/trpc/trpc/524"]