Skip to main content
Pass an array of action objects to addActions. Each action maps an HTTP endpoint to a Firestore CRUD operation. After registering all actions, addActions starts the Express server.

Signature

firebaseExpressSdk.addActions(actions: Action[])

Parameters

actions
Action[]
required
An array of action objects. Each action defines a collection, an endpoint, and a request configuration.

Example

firebaseExpressSdk.addActions([
  {
    collection: "users",
    endpoint: "/api/users",
    request: { type: "GET" },
  },
  {
    collection: "users",
    endpoint: "/api/users/:id",
    request: { type: "GET", paramKey: "id" },
  },
  {
    collection: "users",
    endpoint: "/api/users",
    request: { type: "POST" },
  },
  {
    collection: "users",
    endpoint: "/api/users/:id",
    request: { type: "PUT", paramKey: "id" },
  },
  {
    collection: "users",
    endpoint: "/api/users/:id",
    request: { type: "PATCH", paramKey: "id" },
  },
  {
    collection: "users",
    endpoint: "/api/users/:id",
    request: { type: "DELETE", paramKey: "id" },
  },
]);
addActions starts the Express server after registering all actions. Call it last, after all other setup is complete.