{"id":15780315,"url":"https://github.com/luismeyer/tlfc","last_synced_at":"2025-03-31T16:34:56.400Z","repository":{"id":180371058,"uuid":"664069570","full_name":"luismeyer/tlfc","owner":"luismeyer","description":"Ensure typesafe calls to AWS Lambda functions","archived":false,"fork":false,"pushed_at":"2023-09-27T13:46:58.000Z","size":3394,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-04T18:41:45.401Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://tlfc-docs.vercel.app/","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/luismeyer.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":"2023-07-08T20:43:48.000Z","updated_at":"2023-08-15T17:37:16.000Z","dependencies_parsed_at":"2023-07-15T18:34:37.119Z","dependency_job_id":"ad94882f-e892-4ec9-8bb5-e20281b355a1","html_url":"https://github.com/luismeyer/tlfc","commit_stats":null,"previous_names":["luismeyer/tsls","luismeyer/tlfc"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luismeyer%2Ftlfc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luismeyer%2Ftlfc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luismeyer%2Ftlfc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luismeyer%2Ftlfc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luismeyer","download_url":"https://codeload.github.com/luismeyer/tlfc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246498459,"owners_count":20787316,"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":[],"created_at":"2024-10-04T18:41:13.030Z","updated_at":"2025-03-31T16:34:56.377Z","avatar_url":"https://github.com/luismeyer.png","language":"TypeScript","readme":"\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"https://miro.medium.com/v2/resize:fit:1400/format:webp/1*vhXCF3elDEQt9g6YZraEEQ.png\"/\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\n# @tlfc\n\nWrite typesafe AWS lambda functions with:\n\n- ⚙️ minimal configuration effort\n- 🏗️ local dev environment\n- 🚀 quick deployments\n- 🔒 request and response validation\n- ⭐️ aws-sdk or fetch for either Browser or Node.js clients\n- 😷 typesafe client and server interface\n\n## How it works\n\n### A working vite example can be found in the [example app package](./apps/vite/readme.md) or [deployed here](https://tlfc-example.vercel.app/).\n\n### Simple lambda definition and implementation\n\n```ts\nimport { z } from \"zod\";\n\nimport { createLambda } from \"@tlfc/server\";\n\nexport default createLambda(\n  {\n    requestSchema: z.object({ name: z.string() }),\n    responseSchema: z.object({ message: z.string() }),\n    functionName: \"messageHandler\",\n  },\n  async (event) =\u003e {\n    const message = calculateMessage(event.name);\n    return { message };\n  }\n);\n```\n\n### Usage of the lambda in vite client\n\n```ts\nimport { configure } from \"@tlfc/client\";\n\nimport messageLambda from \"../server/message-lambda\";\n\nconfigure(import.meta.env.VITE_TLFC_API_PATH);\n\nasync function handleClick() {\n  const response = await messageLambda.call({ name: \"Foo\" });\n  title.innerText = response.message;\n}\n```\n\nUnder the hood the `@tlfc/vite` plugin transforms the `@tlfc/server` import to a `@tlfc/client` import. Also it strips the lambda implementation and environment Variables from the client bundle.\n\nThe `@tlfc/client` package uses the fetch api to call the lambda at a specific endpoint. For local development the endpoint is automatically resolved. For production the `VITE_TLFC_API_PATH` needs to be set to the URL that the `@tlfc/tools` deployment creates.\n\nIf the `@tlfc/client` is used outside the browser it will automatically switch to the `aws-sdk` to call the lambda.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluismeyer%2Ftlfc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluismeyer%2Ftlfc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluismeyer%2Ftlfc/lists"}