@microbackend/plugin-firebase
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@microbackend/plugin-firebase

Microbackend plugin to add support for firebase.

Installation

npx microbackend plugin add @microbackend/plugin-firebase

Usage

import createPluginConfig from "@microbackend/plugin-core/build/webpack.build";

await createPluginConfig({
  pluginOptions: {
    "@microbackend/plugin-firebase": {
      serviceAccountEnvVariable: "CUSTOM_GOOGLE_SERVICE_ACCOUNT",
      serviceAccountPath: path.resolve(
        "credential",
        "google_service_account.json"
      ),
    },
  },
});

If not provided, serviceAccountEnvVariable defaults to GOOGLE_SERVICE_ACCOUNT_CREDENTIALS.

The above configuration does the following steps:

  • Read the service account file specified by serviceAccountPath.
  • Store the service account credentials in the environment variable specified by serviceAccountEnvVariable, which can then be accessed during runtime like this: process.env["CUSTOM_GOOGLE_SERVICE_ACCOUNT"].

The plugin creates an extension on app to expose a firebaseAdmin property using the service account credentials.

app.use((req, res, next) => {
  const firebaseAuth = req.app.firebaseAdmin.auth();
  /** Perform auth */
  next();
});

For more information on how to use the firebase Node.js SDK, please read its documentation.

Readme

Keywords

none

Package Sidebar

Install

npm i @microbackend/plugin-firebase

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

16.3 kB

Total Files

16

Last publish

Collaborators

  • protoman92
  • haipham