{"id":14973130,"url":"https://github.com/ya-s-u/typesafe-functions","last_synced_at":"2025-10-26T23:30:21.796Z","repository":{"id":57157955,"uuid":"320085655","full_name":"ya-s-u/typesafe-functions","owner":"ya-s-u","description":"A library of typescript interfaces that extend existing firebase functions classes, adding type safety and a better autocomplete experience.","archived":false,"fork":false,"pushed_at":"2020-12-09T22:13:43.000Z","size":31,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-01T00:51:06.442Z","etag":null,"topics":["firebase","firebase-functions","firestore","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/typesafe-functions","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/ya-s-u.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-12-09T21:37:34.000Z","updated_at":"2023-09-09T23:28:25.000Z","dependencies_parsed_at":"2022-08-26T09:31:43.936Z","dependency_job_id":null,"html_url":"https://github.com/ya-s-u/typesafe-functions","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ya-s-u%2Ftypesafe-functions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ya-s-u%2Ftypesafe-functions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ya-s-u%2Ftypesafe-functions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ya-s-u%2Ftypesafe-functions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ya-s-u","download_url":"https://codeload.github.com/ya-s-u/typesafe-functions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238408545,"owners_count":19467113,"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":["firebase","firebase-functions","firestore","typescript"],"created_at":"2024-09-24T13:48:10.197Z","updated_at":"2025-10-26T23:30:21.386Z","avatar_url":"https://github.com/ya-s-u.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# typesafe-functions\n\n[![npm version](https://badge.fury.io/js/typesafe-functions.svg)](https://badge.fury.io/js/typesafe-functions)\n\nA library of typescript interfaces that extend existing firebase functions classes, adding type safety and a better autocomplete experience.\n\nDepends on [typesafe-node-firestore](https://github.com/mozilla-fxa/typesafe-node-firestore).\n\n## Installation\n\n```shell\nyarn add typesafe-functions --dev\n```\n\n## Usage\n\nYou most likely want to import `TypedDocumentBuilder` and define functions document.\n\n```typescript\nimport * as functions from 'firebase-functions';\nimport { TypedDocumentBuilder } from 'typesafe-functions';\n\ninterface Author {\n  penName: string;\n  shortBiography: string;\n  posts: string[];\n};\n\ninterface Params {\n  authorId: string;\n};\n\nconst document = functions.firestore.document('authors/{authorId}') as TypedDocumentBuilder\u003cAuthor, Params\u003e;\n```\n\nAnd trigger your typesafe firestore events.\n\n```typescript\ndocument.onWrite((change, context) =\u003e {\n  console.log(change.before.data()) //=\u003e  Author | undefined\n  console.log(change.after.data()) //=\u003e  Author | undefined\n  console.log(context.params.authorId) //=\u003e  string\n});\n\ndocument.onChange((change, context) =\u003e {\n  console.log(change.before.data()) //=\u003e  Author | undefined\n  console.log(change.after.data()) //=\u003e  Author | undefined\n  console.log(context.params.authorId) //=\u003e  string\n});\n\ndocument.onWrite((snapshot, context) =\u003e {\n  console.log(snapshot.data()) //=\u003e  Author\n  console.log(context.params.authorId) //=\u003e  string\n});\n\ndocument.onDelete((snapshot, context) =\u003e {\n  console.log(snapshot.data()) //=\u003e  Author\n  console.log(context.params.authorId) //=\u003e  string\n});\n```\n\n### License\n\ntypesafe-functions is [MIT licensed](./LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fya-s-u%2Ftypesafe-functions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fya-s-u%2Ftypesafe-functions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fya-s-u%2Ftypesafe-functions/lists"}