Skip to main content

Import

const { FirebaseExpressSdk } = require("firebase-express-sdk");

Instantiation

const firebaseExpressSdk = new FirebaseExpressSdk({
  app,
  serviceAccountFile,
  collections,
  port: 3001,
});

Parameters

app
Express
required
The Express application instance. Pass the result of express().
serviceAccountFile
object
required
The Firebase service account credentials object. Import the downloaded JSON file directly:
require("./serviceAccount.json")
collections
object
required
An object mapping Firestore collection names to their schema. Each value must include a documentAttributes array listing the fields that belong to documents in that collection.
const collections = {
  users: {
    documentAttributes: ["name", "age", "email"],
  },
};
port
number
default:"3000"
The port number the Express server will listen on.
The constructor throws an error if any collection in collections is missing the documentAttributes array.