{"id":16640372,"url":"https://github.com/loreanvictor/tyfon","last_synced_at":"2025-03-21T15:32:13.788Z","repository":{"id":57383123,"uuid":"313378645","full_name":"loreanvictor/tyfon","owner":"loreanvictor","description":"typed functions over network","archived":false,"fork":false,"pushed_at":"2021-02-19T10:28:27.000Z","size":1190,"stargazers_count":38,"open_issues_count":7,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-18T02:44:40.479Z","etag":null,"topics":["api","api-client","cloud-functions","nodejs","serverless","typescript"],"latest_commit_sha":null,"homepage":"https://loreanvictor.github.io/tyfon","language":"JavaScript","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/loreanvictor.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}},"created_at":"2020-11-16T17:33:35.000Z","updated_at":"2025-02-02T04:16:00.000Z","dependencies_parsed_at":"2022-09-14T00:31:38.562Z","dependency_job_id":null,"html_url":"https://github.com/loreanvictor/tyfon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loreanvictor%2Ftyfon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loreanvictor%2Ftyfon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loreanvictor%2Ftyfon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loreanvictor%2Ftyfon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loreanvictor","download_url":"https://codeload.github.com/loreanvictor/tyfon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244822722,"owners_count":20516154,"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":["api","api-client","cloud-functions","nodejs","serverless","typescript"],"created_at":"2024-10-12T07:08:39.532Z","updated_at":"2025-03-21T15:32:13.307Z","avatar_url":"https://github.com/loreanvictor.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"/tyfon-type.svg\" width=\"320px\"/\u003e\n  \u003cp align=\"center\"\u003e\u003cb\u003eTy\u003c/b\u003eped \u003cb\u003eF\u003c/b\u003eunctions \u003cb\u003eO\u003c/b\u003ever \u003cb\u003eN\u003c/b\u003eetwork\u003c/p\u003e\n\n  [![version](https://img.shields.io/npm/v/tyfon?logo=npm\u0026style=flat-square)](https://www.npmjs.com/package/tyfon)\n  [![docs](https://img.shields.io/badge/%20-docs-blue?logo=read%20the%20docs\u0026logoColor=white\u0026style=flat-square)](https://loreanvictor.github.io/tyfon/)\n\n\u003c/div\u003e\n\n\u003cbr\u003e\u003cbr\u003e\n\nSeamlessly use server-side TypeScript functions on the client.\n\n```ts\n// server:\n\nexport async function getMessage(name: string) {\n  return `Hellow ${name}!`;\n}\n```\n```ts\n// client:\n\nimport { getMessage } from '@api/my-server';\n\ngetMessage('World').then(console.log):\n```\n\n👉 [Read the docs](https://loreanvictor.github.io/tyfon).\n\n\u003cbr\u003e\u003cbr\u003e\n\n# Installation\n\nTyFON is a singular CLI tool that runs on Node, so you need Node.js installed beforehand.\n```bash\nnpm i -g tyfon\n```\n\n\u003cbr\u003e\u003cbr\u003e\n\n# Usage\n\n[Read the docs](https://loreanvictor.github.io/tyfon) for detailed usage information and\na getting-started tutorial.\n\n\u003cbr\u003e\n\n## Server Side\n\nExport your functions in `index.ts`:\n\n```ts\nexport async const getMessage = name =\u003e `Hellow ${name}!`;\n```\n\nNow serve them:\n```bash\ntyfon serve\n```\n\n👉 Check it out on `localhost:8000/message?0=\"World\"`.\n\n\u003cbr\u003e\u003cbr\u003e\n\n## Client Side\n\nAdd the SDK on client side and use it:\n```bash\ntyfon i localhost:8000\n```\n```ts\nimport { getMessage } from '@api/my-server';\n\ngetMessage('World').then(console.log);\n```\n\n👉 The name `my-server` comes from `package.json` of your server code.\n\n\u003cbr\u003e\u003cbr\u003e\n\n## Syncing Updates\n\nUse `tyfon watch` while working on server and client simultaneously:\n```bash\ntyfon watch -c \u003cclient-path\u003e     # --\u003e run this on server side code\n```\n\n\u003cbr\u003e\n\nOr sync updates manually (in other situations):\n- On server-side code, rebuild client SDK metadata and serve it again:\n```bash\ntyfon build                      # --\u003e run this on server side code\n```\n```bash\ntyfon serve                      # --\u003e run this on server side code\n```\n\n- On client-side code, update TyFONs you are using:\n```bash\ntyfon i                          # --\u003e run this on client side code\n```\n\n\u003cbr\u003e\u003cbr\u003e\n\n## Server Environment Variables\n\nYou can pass environment variables to `tyfon serve` command using `-e` option:\n\n```bash\ntyfon serve -e ENV=dev -e LOGS=verbose\n```\n\n\u003cbr\u003e\u003cbr\u003e\n\n## Client Environments\n\nIt is common practice for client-code to use different API URLs for different environments (i.e. development, production, staging, etc).\nYou can use the `--env` flag on `tyfon i` command to mark the environment a TyFON should be used in:\n```bash\ntyfon i https://my-server.cloud --env production\ntyfon i https://staging.my-server.cloud --env staging\ntyfon i localhost:8000 --env dev\n```\n\nNow for building client-code in production, use the following command:\n```bash\ntyfon i --env production        # --\u003e this will install all generic TyFONs and all production TyFONs\n```\n\n\u003cbr\u003e\u003cbr\u003e\n\n## Deploying\n\nRun your TyFON in production mode:\n\n```bash\ntyfon serve --mode prod\n```\n\n### Docker\n\nBuild a docker image and deploy it:\n\n```bash\ntyfon build --image my-server\n\ndocker tag my-server https://my-registry.cloud/my-server\ndocker push my-server\n```\n\n👉 [docker](https://www.docker.com) **MUST** be installed for using this option.\n\n\u003cbr\u003e\u003cbr\u003e\n\n# Conventions\n\nTyFON leans heavily towards the _convention over configuration_ principle. It is pretty opinionated in how it wraps normal functions within\nAPI end-points and how code should be structured, for example it picks endpoint methods based on the name of the function, or it expects\nall API functions to be exported from `index.ts` from the root of the project.\n\n👉 [Read the docs](https://loreanvictor.github.io/tyfon).\n\n\u003cbr\u003e\u003cbr\u003e\n\n# CLI Commands\n\n- [`tyfon init`](https://loreanvictor.github.io/tyfon/cli/init)\n- [`tyfon build`](https://loreanvictor.github.io/tyfon/cli/build)\n- [`tyfon serve`](https://loreanvictor.github.io/tyfon/cli/serve)\n- [`tyfon install`](https://loreanvictor.github.io/tyfon/cli/install)\n- [`tyfon uninstall`](https://loreanvictor.github.io/tyfon/cli/uninstall)\n- [`tyfon help`](https://loreanvictor.github.io/tyfon/cli/help)\n- [`tyfon version`](https://loreanvictor.github.io/tyfon/cli/version)\n\n\u003cbr\u003e\u003cbr\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floreanvictor%2Ftyfon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floreanvictor%2Ftyfon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floreanvictor%2Ftyfon/lists"}