{"id":16903844,"url":"https://github.com/jacobweisenburger/freerstore","last_synced_at":"2025-03-22T10:31:08.214Z","repository":{"id":152919526,"uuid":"626116259","full_name":"JacobWeisenburger/freerstore","owner":"JacobWeisenburger","description":"Firestore cost optimizer","archived":false,"fork":false,"pushed_at":"2025-03-04T18:40:12.000Z","size":501,"stargazers_count":24,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T10:21:27.443Z","etag":null,"topics":["firebase","firestore","typescript","zod"],"latest_commit_sha":null,"homepage":"","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/JacobWeisenburger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"JacobWeisenburger"}},"created_at":"2023-04-10T20:41:48.000Z","updated_at":"2025-03-04T18:40:16.000Z","dependencies_parsed_at":"2024-01-29T21:32:18.299Z","dependency_job_id":null,"html_url":"https://github.com/JacobWeisenburger/freerstore","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/JacobWeisenburger%2Ffreerstore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobWeisenburger%2Ffreerstore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobWeisenburger%2Ffreerstore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobWeisenburger%2Ffreerstore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JacobWeisenburger","download_url":"https://codeload.github.com/JacobWeisenburger/freerstore/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244943725,"owners_count":20536290,"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","firestore","typescript","zod"],"created_at":"2024-10-13T18:29:00.569Z","updated_at":"2025-03-22T10:31:08.206Z","avatar_url":"https://github.com/JacobWeisenburger.png","language":"TypeScript","funding_links":["https://github.com/sponsors/JacobWeisenburger"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align='center'\u003e\n    \u003ch1\u003eFreerstore\u003c/h1\u003e\n    \u003ch3\u003eFirestore cost optimizer\u003c/h3\u003e\n\u003c/div\u003e\n\n\u003cdiv align='center'\u003e\n    \u003ca href='https://github.com/JacobWeisenburger' rel='nofollow'\u003e\n        \u003cimg alt='Created by Jacob Weisenburger'\n            src='https://img.shields.io/badge/created%20by-Jacob%20Weisenburger-274D82.svg'\u003e\n    \u003c/a\u003e\n    \u003ca href='https://github.com/JacobWeisenburger/freerstore/stargazers' rel='nofollow'\u003e\n        \u003cimg alt='stars' src='https://img.shields.io/github/stars/JacobWeisenburger/freerstore?color=blue'\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align='center'\u003e\n    \u003ca href='https://www.npmjs.com/package/freerstore' rel='nofollow' target='_blank'\u003e\n        \u003cimg alt='npm' src='https://img.shields.io/npm/v/freerstore?color=blue'\u003e\n    \u003c/a\u003e\n    \u003ca href='https://www.npmjs.com/package/freerstore' rel='nofollow' target='_blank'\u003e\n        \u003cimg alt='downloads' src='https://img.shields.io/npm/dw/freerstore?color=blue'\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003ca href=\"https://github.com/JacobWeisenburger/freerstore#freerstore\"\u003eDocs\u003c/a\u003e\n    \u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n    \u003ca href=\"https://github.com/JacobWeisenburger/freerstore\"\u003egithub\u003c/a\u003e\n    \u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n    \u003ca href=\"https://www.npmjs.com/package/freerstore\"\u003enpm\u003c/a\u003e\n\u003c/div\u003e\n\n\u003c!-- Dist Readme Stops Here --\u003e\n\n\u003cbr /\u003e\n\n## Table of contents\n- [Purpose](#purpose)\n- [Contribute](#contribute)\n- [Installation](#installation)\n    - [From npm (Node/Bun)](#from-npm-nodebun)\n- [Getting Started](#getting-started)\n    - [import](#import)\n- [TODO](#todo)\n\n## Purpose\nTo optimize firestore costs by:\n- batching and debouncing writes\n- caching documents in IndexedDB\n\nTo provide a better developer experience by:\n- validating documents with `zod`\n\n## Contribute\nAlways open to ideas. Positive or negative, all are welcome. Feel free to contribute an [issue](https://github.com/JacobWeisenburger/freerstore/issues) or [PR](https://github.com/JacobWeisenburger/freerstore/pulls).\n\n## Installation\n[npmjs.com/package/freerstore](https://www.npmjs.com/package/freerstore)\n```sh\nnpm install freerstore firebase zod\n```\n\n## Getting Started\n\n```ts\nimport { z } from 'zod'\nimport { initializeApp } from 'firebase/app'\nimport { freerstore } from 'freerstore'\n\n// get your firebase config from:\n// https://console.firebase.google.com\nconst firebaseConfig = {\n    apiKey: '',\n    authDomain: '',\n    projectId: '',\n    storageBucket: '',\n    messagingSenderId: '',\n    appId: ''\n}\n\nconst firebaseApp = initializeApp( firebaseConfig )\n\n// only supports top level collections currently\n// feel free to open a PR to add support for subcollections\nconst collectionName = 'foobar'\n\nconst documentSchema = z.object( {\n    name: z.string(),\n    exp: z.number(),\n} )\ntype DocumentData = z.infer\u003ctypeof documentSchema\u003e\n// type DocumentData = {\n//     name: string\n//     exp: number\n// }\n\nconst collection = freerstore.getCollection( {\n    firebaseApp,\n    name: collectionName,\n    documentSchema,\n} )\n\nconst unsubscribe = collection.onSnapshot( resultsMap =\u003e {\n    // resultsMap: Map\u003cstring, z.SafeParseReturnType\u003e\n\n    // Do something with the results\n    resultsMap.forEach( ( result, id ) =\u003e {\n        if ( result.success ) {\n            // result.data: DocumentData \u0026 {\n            //     freerstore: {\n            //         modifiedAt: string /* ISO date string */\n            //     }\n            // }\n            console.log( id, result.data )\n        } else {\n            // result.error: ZodError\n            console.error( id, result.error )\n        }\n    } )\n} )\n\nsetTimeout( () =\u003e {\n    /* setDocs handles batches for you */\n    collection.setDocs( {\n        someId1: { name: 'Frodo', exp: 13 },\n        someId2: { name: 'Aragorn', exp: 87 },\n        someId3: { name: 'Gandalf', exp: 9999 },\n    } )\n}, 1000 )\n\n// unsubscribe at some point to prevent memory leaks \nsetTimeout( () =\u003e {\n    unsubscribe()\n}, 10_000 )\n```\n\n## TODO\nAlways open to ideas. Positive or negative, all are welcome. Feel free to contribute an [issue](https://github.com/JacobWeisenburger/freerstore/issues) or [PR](https://github.com/JacobWeisenburger/freerstore/pulls).\n- Logo\n- GitHub Actions\n    - Auto publish to npm","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobweisenburger%2Ffreerstore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacobweisenburger%2Ffreerstore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobweisenburger%2Ffreerstore/lists"}