@stanfordspezi/spezi-firebase

Spezi Firebase Abstractions to Develop Spezi-Based Firebase Projects

https://github.com/stanfordspezi/spezi-firebase

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
Last synced: 6 months ago · JSON representation ·

Repository

Spezi Firebase Abstractions to Develop Spezi-Based Firebase Projects

Basic Info
  • Host: GitHub
  • Owner: StanfordSpezi
  • License: mit
  • Language: TypeScript
  • Default Branch: main
  • Homepage:
  • Size: 642 KB
Statistics
  • Stars: 2
  • Watchers: 8
  • Forks: 0
  • Open Issues: 14
  • Releases: 4
Created 11 months ago · Last pushed 6 months ago
Metadata Files
Readme License Citation

README.md

Spezi Firebase

Build and Test codecov

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:

  1. Clone the repository:

bash git clone https://github.com/StanfordSpezi/spezi-firebase.git cd spezi-firebase

  1. Install dependencies:

bash npm install

This will install dependencies for all workspace packages.

  1. Build all packages:

bash npm run build

  1. 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.

Stanford Mussallem Center for Biodesign Logo Stanford Mussallem Center for Biodesign Logo

Owner

  • Name: Stanford Spezi
  • Login: StanfordSpezi
  • Kind: organization

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
enhancement (4)
Pull Request Labels
enhancement (2) dependencies (1) javascript (1) bug (1)

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

  • Versions: 8
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 182 Last month
Rankings
Forks count: 12.4%
Stargazers count: 17.1%
Average: 22.4%
Dependent repos count: 24.5%
Dependent packages count: 35.4%
Maintainers (1)
Last synced: 6 months ago
npmjs.org: @stanfordspezi/spezi-firebase-fhir

Firebase fhir package for Spezi

  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 186 Last month
Rankings
Dependent repos count: 24.1%
Average: 29.5%
Dependent packages count: 34.8%
Maintainers (1)
Last synced: 6 months ago
npmjs.org: @stanfordspezi/spezi-firebase-utils

Utility functions for Firebase projects

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 183 Last month
Rankings
Dependent repos count: 24.5%
Average: 29.9%
Dependent packages count: 35.4%
Maintainers (1)
Last synced: 6 months ago
npmjs.org: @stanfordspezi/spezi-firebase

Stanford Biodesign Digital Health Spezi Firebase Packages

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 24.5%
Average: 29.9%
Dependent packages count: 35.4%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/build-and-test.yml actions
.github/workflows/codeql.yml actions
  • actions/checkout v4 composite
  • github/codeql-action/analyze v3 composite
  • github/codeql-action/init v3 composite
.github/workflows/main.yml actions
.github/workflows/monthly-markdown-link-check.yml actions
package-lock.json npm
  • 694 dependencies
package.json npm
  • @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
packages/spezi-frn/package-lock.json npm
  • 456 dependencies
packages/spezi-frn/package.json npm
  • @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