{"id":18830868,"url":"https://github.com/nhogs/nestjs-firebase","last_synced_at":"2025-04-14T04:03:23.601Z","repository":{"id":39861399,"uuid":"440168744","full_name":"Nhogs/nestjs-firebase","owner":"Nhogs","description":"Firebase plugin for NestJs","archived":false,"fork":false,"pushed_at":"2024-06-29T14:06:50.000Z","size":1243,"stargazers_count":7,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-02T13:08:50.304Z","etag":null,"topics":["firebase","nestjs"],"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/Nhogs.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},"funding":{"github":["nhogs"]}},"created_at":"2021-12-20T12:50:07.000Z","updated_at":"2024-08-20T16:58:58.000Z","dependencies_parsed_at":"2022-07-14T06:30:33.717Z","dependency_job_id":null,"html_url":"https://github.com/Nhogs/nestjs-firebase","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nhogs%2Fnestjs-firebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nhogs%2Fnestjs-firebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nhogs%2Fnestjs-firebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nhogs%2Fnestjs-firebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nhogs","download_url":"https://codeload.github.com/Nhogs/nestjs-firebase/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223619745,"owners_count":17174416,"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","nestjs"],"created_at":"2024-11-08T01:51:09.814Z","updated_at":"2024-11-08T01:51:10.408Z","avatar_url":"https://github.com/Nhogs.png","language":"TypeScript","funding_links":["https://github.com/sponsors/nhogs"],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://nhogs.com\"\u003e\u003cimg src=\"https://nhogs.com/nhogs_64.png\" align=\"right\" alt=\"nhogs-logo\" title=\"NHOGS Interactive\"\u003e\u003c/a\u003e\n\n# @nhogs/nestjs-firebase\n\n[![npm peer dependency version Firebase](https://img.shields.io/npm/dependency-version/@nhogs/nestjs-firebase/peer/firebase?label=Firebase\u0026logo=firebase)](https://firebase.google.com/)\n[![npm peer dependency version NestJS)](https://img.shields.io/npm/dependency-version/@nhogs/nestjs-firebase/peer/@nestjs/core?label=Nestjs\u0026logo=nestjs\u0026logoColor=e0234e)](https://github.com/nestjs/nest)\n\n## [Firebase](https://firebase.google.com/) module for [NestJS](https://github.com/nestjs/nest).\n\n[![CI](https://github.com/Nhogs/nestjs-firebase/actions/workflows/ci.yml/badge.svg)](https://github.com/Nhogs/nestjs-firebase/actions/workflows/ci.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/356bd937ca8b2e7b8d96/maintainability)](https://codeclimate.com/github/Nhogs/nestjs-firebase/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/356bd937ca8b2e7b8d96/test_coverage)](https://codeclimate.com/github/Nhogs/nestjs-firebase/test_coverage)\n\n\u003cfont size=\"1\"\u003eContinuous Integration tests with [Github Action](https://github.com/Nhogs/nestjs-firebase/actions/workflows/ci.yml) on [Firebase Emulator Suite](https://firebase.google.com/docs/emulator-suite) \u003c/font\u003e\n\n## Installation\n\n[![npm](https://img.shields.io/npm/v/@nhogs/nestjs-firebase?label=%40nhogs%2Fnestjs-firebase\u0026logo=npm)](https://www.npmjs.com/package/@nhogs/nestjs-firebase)\n\n```bash\n$ npm i --save @nhogs/nestjs-firebase\n```\n\nFirst you need to have a running firebase project.\nSee [Add Firebase to your JavaScript project](https://firebase.google.com/docs/web/setup)\n\n:warning: This module only uses Firebase client API\n\n- [x] Use [Firebase client API](https://firebase.google.com/docs/web/setup)\n- [ ] Use [Firebase admin SDK](https://firebase.google.com/docs/admin/setup)\n\n### Module\n\nAdd the module in app imports with project settings\n\n```javascript\n@Module({\n  imports: [\n    FirebaseModule.forRoot({\n      apiKey: \"API_KEY\",\n      authDomain: \"PROJECT_ID.firebaseapp.com\",\n      projectId: \"PROJECT_ID\",\n      storageBucket: \"PROJECT_ID.appspot.com\",\n      // Optional name of the app to initialize. Custom name for the Firebase App. The default value is \"[DEFAULT]\"\n      // appName: \"APP_NAME\",\n    }),\n    CatsModule,\n  ],\n})\nexport class AppModule {}\n```\n\n[Check here for an e2e test with real example on Cat module](e2e/src)\n\nThis module is a simple wrapper on Firebase API and export 3 services.\n\n- Cloud Firestore\n- Storage\n- Authentication\n\n### Cloud Firestore\n\nExposes most of [Firebase firestore web api](https://firebase.google.com/docs/firestore) in the service.\n\n```javascript\n// Add document example\n\nit(\"should addDoc\", async () =\u003e {\n  const users =\n    firestoreService.collection(\"users\").withConverter \u003c User \u003e userConverter;\n\n  const doc = (await firestoreService.addDoc) \u003c User \u003e (users, u1);\n\n  const snapshot = await firestoreService.getDoc(doc);\n  expect(snapshot.data()).toMatchInlineSnapshot(`\n    User {\n      \"age\": 1,\n      \"firstName\": \"fn1\",\n      \"lastName\": \"ln1\",\n    }\n  `);\n});\n```\n\nSee [firestore.service.spec.ts](lib/service/firestore/firestore.service.spec.ts) for detailed usage.\n\n### Storage\n\nExposes most of [Firebase storage web api](https://firebase.google.com/docs/storage/web/start) in the service.\n\n```javascript\n// Upload string and get download url example\nit(`should upload string`, async () =\u003e {\n  const fileName = \"file.txt\";\n  await storageService\n    .uploadString(fileName, \"text content\", \"raw\", {\n      contentType: \"text/plain\",\n    })\n    .then((snapshot) =\u003e {\n      expect(snapshot.metadata.contentType).toMatchInlineSnapshot(\n        `\"text/plain\"`\n      );\n    });\n\n  const downloadUrl = await storageService.getDownloadURL(fileName);\n  expect(downloadUrl).toMatchInlineSnapshot(\n    `\"http://localhost:9199/v0/b/default-bucket/o/file.txt?alt=media\u0026token=86739ce5-a96e-41ad-b807-e05b12e36516\"`\n  );\n});\n```\n\nSee [storage.service.spec.ts](lib/service/storage/storage.service.spec.ts) for detailed usage.\n\n### Authentication\n\nSee [auth.service.spec.ts](lib/service/auth/auth.service.spec.ts) for detailed usage.\n\n## License\n\n[![MIT license](https://img.shields.io/github/license/nhogs/nestjs-firebase)](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhogs%2Fnestjs-firebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhogs%2Fnestjs-firebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhogs%2Fnestjs-firebase/lists"}