@hyper-fetch/firebase-admin
TypeScript icon, indicating that this package has built-in type declarations

7.0.2 • Public • Published

🔥 Hyper Fetch Firebase Admin


Description

@hyper-fetch/firebase-admin is the official Firebase Admin SDK adapter for Hyper Fetch. It brings the same declarative, type-safe API you use on the client to your server or cloud functions.


:::tip Purpose

  1. One API – everywhere – share request definitions between the browser and Node.js environments.
  2. First-class TypeScript – strong typing for parameters, payloads and responses out of the box.
  3. Queue & Retry – leverage Hyper Fetch queueing on top of Firebase Admin SDK.
  4. Unified tooling – logging, events and interceptors identical on both sides.
  5. Works with Firestore and Realtime Database – pick the storage that fits your use-case.

:::

Installation

npm install @hyper-fetch/core @hyper-fetch/firebase-admin firebase-admin
# or
yarn add @hyper-fetch/core @hyper-fetch/firebase-admin firebase-admin

firebase-admin is a peer dependency and must be installed separately.

Quick start

1. Initialize Firebase Admin SDK

import { initializeApp, applicationDefault } from "firebase-admin/app";
import { getFirestore } from "firebase-admin/firestore";

initializeApp({
  credential: applicationDefault(),
});

export const db = getFirestore();

2. Create Hyper Fetch client with the Firebase Admin adapter

import { createClient } from "@hyper-fetch/core";
import { FirebaseAdminAdapter } from "@hyper-fetch/firebase-admin";
import { db } from "./firebase";

export const client = createClient({ url: "" }).setAdapter(FirebaseAdminAdapter(db));

3. Server-side request example

interface MessagePayload {
  text: string;
}

export const addMessage = client.createRequest<{ payload: MessagePayload; response: null }>()({
  endpoint: "/messages",
  method: "addDoc",
});

await addMessage.send({ payload: { text: "Hello from the server!" } });

Supported methods

Firestore Realtime Database
getDoc, getDocs get
setDoc, addDoc set, push
updateDoc, deleteDoc update, remove

Resources

Contributing

We ❤️ contributions! Please read the contributing guide and open an issue or pull request.


Made with ☕ by BetterTyped

Package Sidebar

Install

npm i @hyper-fetch/firebase-admin

Weekly Downloads

184

Version

7.0.2

License

Apache-2.0

Unpacked Size

126 kB

Total Files

42

Last publish

Collaborators

  • geras_nyx
  • prc5