@stanfordspezi/spezi-firebase
Spezi Firebase Abstractions to Develop Spezi-Based Firebase Projects
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.2%) to scientific vocabulary
Repository
Spezi Firebase Abstractions to Develop Spezi-Based Firebase Projects
Basic Info
Statistics
- Stars: 2
- Watchers: 8
- Forks: 0
- Open Issues: 14
- Releases: 4
Metadata Files
README.md
Spezi Firebase
A collection of Firebase utilities and further components to kickstart the development for firebase-related functions in the Stanford Spezi Ecosystem.
Repository Structure
This repository is organized as an npm workspace containing two main packages:
- spezi-firebase-utils (
packages/spezi-firebase-utils): Base utility functions for Firebase projects - spezi-firebase-cloud-messaging (
packages/spezi-firebase-cloud-messaging): Firebase Cloud Messaging (FCM) remote notifications package that builds on the utilities
Features
- Device registration and token management
- Multi-language notification support
- Platform-specific message formatting (iOS, Android, Web)
- Support for rich notification content
- Token invalidation handling
- Firestore integration for device storage
Installation
For End Users
Install the packages you need:
```bash
For Firebase Cloud Messaging functionality
npm install @stanfordspezi/spezi-firebase-cloud-messaging
For Firebase utilities only
npm install @stanfordspezi/spezi-firebase-utils ```
For Development
This project uses npm workspaces for managing multiple packages. To set up the development environment:
- Clone the repository:
bash
git clone https://github.com/StanfordSpezi/spezi-firebase.git
cd spezi-firebase
- Install dependencies:
bash
npm install
This will install dependencies for all workspace packages.
- Build all packages:
bash
npm run build
- Run tests:
bash npm test
Workspace Commands
For more advanced development, you can use npm workspace commands:
- Build all packages:
npm run build --workspaces - Build specific package:
npm run build -w @stanfordspezi/spezi-firebase-utils - Test all packages:
npm run test --workspaces - Test specific package:
npm run test -w @stanfordspezi/spezi-firebase-cloud-messaging - Start development mode:
npm run dev
Learn more about npm workspaces in the official documentation.
Quick Start
```typescript import { initializeApp, cert } from 'firebase-admin/app' import { getMessaging } from 'firebase-admin/messaging' import { getFirestore } from 'firebase-admin/firestore' import { FirebaseNotificationService, FirestoreDeviceStorage, Message, DevicePlatform, Device, LocalizedText, } from '@stanfordspezi/spezi-firebase-cloud-messaging'
// Initialize Firebase const app = initializeApp() const messaging = getMessaging(app) const firestore = getFirestore(app)
// Initialize device storage const deviceStorage = new FirestoreDeviceStorage(firestore)
// Initialize notification service const notificationService = new FirebaseNotificationService( messaging, deviceStorage, )
// Register a device await notificationService.registerDevice( 'user123', new Device({ notificationToken: 'fcm-token-123', platform: DevicePlatform.iOS, language: 'en', appVersion: '1.0.0', }), )
// Send a notification await notificationService.sendNotification('user123', { title: { en: 'Hello', de: 'Hallo' }, body: { en: 'This is a test notification', de: 'Dies ist eine Test-Benachrichtigung', }, data: { action: 'open_home' }, })
// Create and send a message notification const message = Message.createInformation({ title: { en: 'Information', de: 'Information' }, description: { en: 'This is important information', de: 'Dies ist eine wichtige Information', }, action: 'view_details', isDismissible: true, data: { itemId: '123' }, })
// Send a message-based notification await notificationService.sendMessageNotification('user123', { id: 'message-123', path: '/messages/message-123', lastUpdate: new Date(), content: message, })
// Unregister a device await notificationService.unregisterDevice( 'user123', 'fcm-token-123', DevicePlatform.iOS, ) ```
Firebase Functions Integration
This package includes helpers for creating Firebase Functions:
```typescript import { onCall } from 'firebase-functions/v2/https' import { createRegisterDeviceHandler, createUnregisterDeviceHandler, registerDeviceInputSchema, unregisterDeviceInputSchema, } from '@stanfordspezi/spezi-firebase-cloud-messaging'
// Create function handlers const registerDeviceHandler = createRegisterDeviceHandler(notificationService) const unregisterDeviceHandler = createUnregisterDeviceHandler(notificationService)
// Create Firebase Functions export const registerDevice = onCall( { schema: registerDeviceInputSchema, }, async (request) => { const userId = request.auth?.uid if (!userId) throw new Error('Unauthorized')
return registerDeviceHandler(userId, request.data)
}, )
export const unregisterDevice = onCall( { schema: unregisterDeviceInputSchema, }, async (request) => { const userId = request.auth?.uid if (!userId) throw new Error('Unauthorized')
return unregisterDeviceHandler(userId, request.data)
}, ) ```
License
This project is licensed under the MIT License. See Licenses for more information.
Contributors
This project is developed as part of the Stanford Mussallem Center for Biodesign at Stanford University. See CONTRIBUTORS.md for a full list of all Spezi Firebase contributors.

Owner
- Name: Stanford Spezi
- Login: StanfordSpezi
- Kind: organization
- Repositories: 1
- Profile: https://github.com/StanfordSpezi
Citation (CITATION.cff)
#
# This source file is part of the Stanford Biodesign Digital Health Next.js Template open-source project
#
# SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md)
#
# SPDX-License-Identifier: MIT
#
cff-version: 1.2.0
message: 'If you use this software, please cite it as below.'
authors:
- family-names: 'Schmiedmayer'
given-names: 'Paul'
orcid: 'https://orcid.org/0000-0002-8607-9148'
- family-names: 'Ravi'
given-names: 'Vishnu'
orcid: 'https://orcid.org/0000-0003-0359-1275'
title: 'NextJSTemplate'
doi: '10.5281/zenodo.10052055'
url: 'https://github.com/StanfordBDHG/NextJSTemplate'
GitHub Events
Total
- Create event: 22
- Release event: 4
- Issues event: 7
- Watch event: 1
- Delete event: 19
- Issue comment event: 16
- Push event: 100
- Pull request review comment event: 31
- Pull request review event: 43
- Pull request event: 29
Last Year
- Create event: 22
- Release event: 4
- Issues event: 7
- Watch event: 1
- Delete event: 19
- Issue comment event: 16
- Push event: 100
- Pull request review comment event: 31
- Pull request review event: 43
- Pull request event: 29
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 7
- Total pull requests: 17
- Average time to close issues: 2 days
- Average time to close pull requests: 2 days
- Total issue authors: 2
- Total pull request authors: 3
- Average comments per issue: 0.29
- Average comments per pull request: 0.47
- Merged pull requests: 11
- Bot issues: 0
- Bot pull requests: 1
Past Year
- Issues: 7
- Pull requests: 17
- Average time to close issues: 2 days
- Average time to close pull requests: 2 days
- Issue authors: 2
- Pull request authors: 3
- Average comments per issue: 0.29
- Average comments per pull request: 0.47
- Merged pull requests: 11
- Bot issues: 0
- Bot pull requests: 1
Top Authors
Issue Authors
- PaulGoldschmidt (4)
- pauljohanneskraft (2)
Pull Request Authors
- pauljohanneskraft (7)
- PaulGoldschmidt (7)
- dependabot[bot] (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 4
-
Total downloads:
- npm 551 last-month
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 0
(may contain duplicates) - Total versions: 22
- Total maintainers: 1
npmjs.org: @stanfordspezi/spezi-firebase-cloud-messaging
Firebase Cloud Messaging (FCM) remote notifications package for Spezi
- Homepage: https://github.com/StanfordSpezi/spezi-firebase#readme
- License: MIT
-
Latest release: 0.1.8
published 6 months ago
Rankings
Maintainers (1)
npmjs.org: @stanfordspezi/spezi-firebase-fhir
Firebase fhir package for Spezi
- Homepage: https://github.com/StanfordSpezi/spezi-firebase#readme
- License: MIT
-
Latest release: 0.1.8
published 6 months ago
Rankings
Maintainers (1)
npmjs.org: @stanfordspezi/spezi-firebase-utils
Utility functions for Firebase projects
- Homepage: https://github.com/StanfordSpezi/spezi-firebase#readme
- License: MIT
-
Latest release: 0.1.8
published 6 months ago
Rankings
Maintainers (1)
npmjs.org: @stanfordspezi/spezi-firebase
Stanford Biodesign Digital Health Spezi Firebase Packages
- Homepage: https://github.com/StanfordSpezi/spezi-firebase#readme
- License: MIT
- Status: removed
-
Latest release: 0.1.0
published 9 months ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v4 composite
- github/codeql-action/analyze v3 composite
- github/codeql-action/init v3 composite
- 694 dependencies
- @testing-library/jest-dom ^6 development
- @testing-library/react ^15 development
- @total-typescript/ts-reset ^0.5.1 development
- @types/jest ^29 development
- @types/node ^20 development
- @types/react ^18 development
- @types/react-dom ^18 development
- @typescript-eslint/eslint-plugin ^7 development
- @typescript-eslint/parser ^7 development
- autoprefixer ^10 development
- concurrently ^8 development
- eslint ^8 development
- eslint-config-next ^14 development
- eslint-config-prettier ^9 development
- eslint-plugin-import ^2 development
- eslint-plugin-prettier ^5 development
- jest ^29 development
- jest-environment-jsdom ^29 development
- postcss ^8 development
- prettier ^3 development
- tailwindcss ^3 development
- ts-jest ^29 development
- typedoc ^0.25 development
- typescript ^5 development
- @stanfordbdhg/example-package file:./packages/example-package
- next ^14
- prettier-plugin-tailwindcss ^0.5.14
- react ^18
- react-dom ^18
- sharp ^0.33
- 456 dependencies
- @types/chai ^4.3.16 development
- @types/mocha ^10.0.7 development
- @types/node ^20 development
- @types/sinon ^17.0.3 development
- @typescript-eslint/eslint-plugin ^7 development
- @typescript-eslint/parser ^7 development
- chai ^5.1.1 development
- eslint ^8.57 development
- eslint-config-google ^0.14 development
- eslint-config-prettier ^9 development
- eslint-plugin-import ^2 development
- eslint-plugin-prettier ^5 development
- mocha ^10.6.0 development
- sinon ^18.0.0 development
- ts-node ^10.9.2 development
- typescript ^5 development
- firebase-admin ^12.0
- zod ^3.23.8