@adminjs/firebase 中文文档教程

发布于 3 年前 浏览 7 更新于 2 年前

AdminJS Firebase Adapter

允许添加您自己的 Firebase 资源的 AdminJS 适配器

Prerequisites

您需要为您的项目配置 AdminJS 面板。 有关说明,请参阅 AdminJS 存储库

在将资源连接到 AdminJS 之前,您必须初始化您的 Firebase 应用程序。 这意味着您必须编写如下内容:

// Your firebase config see https://firebase.google.com/docs/web/setup
export const firebaseConfig = {
  // [...]
};

Firebase.initializeApp(firebaseConfig);

Installing

要将适配器连接到您的 AdminJS 实例,您只需要:

  1. Register this adapter into AdminJS instance
  2. Write resource with schema
  3. Pass resource to AdminJS config object

检查 example 文件夹以获取完整的示例应用程序!

import * as firebase from "firebase";
import AdminJSExpress from '@adminjs/express';
import AdminJSFirebase from '@adminjs/firebase';
import AdminJS from 'adminjs'; 

const setupAdmin = async expressApp => {
  AdminJS.registerAdapter(AdminJSFirebase);
  const adminJs = new AdminJS({
    branding: {
      companyName: 'Firebase example',
    },
    resources: [
      {
        collection: firebase.firestore().collection('Users'),
        schema: {
          name: 'string',
          isAdmin: 'boolean',
          location: 'mixed',
          attributes: {
            type: 'mixed',
            schema: {
              birthdate: 'date',
              height: 'number',
              eyeColors: 'mixed',
            },
          },
        },
      },
    ],
  });

  const router = await AdminJSExpress.buildRouter(adminJs);
  app.use(adminJs.options.rootPath, router);
};

Authors

Known Issues

在问题选项卡中描述。

随意贡献。

License

这个项目是根据麻省理工学院许可证获得许可的

AdminJS Firebase Adapter

Adapter for AdminJS which allows to add your own Firebase resources

Prerequisites

You will need AdminJS panel configured for your project. See AdminJS Repository for instructions

You have to initialize your Firebase app before connecting resources to AdminJS. That means you have to write something like:

// Your firebase config see https://firebase.google.com/docs/web/setup
export const firebaseConfig = {
  // [...]
};

Firebase.initializeApp(firebaseConfig);

Installing

To connect adapter to your AdminJS instance all you need is to:

  1. Register this adapter into AdminJS instance
  2. Write resource with schema
  3. Pass resource to AdminJS config object

Check example folder for full example application!

import * as firebase from "firebase";
import AdminJSExpress from '@adminjs/express';
import AdminJSFirebase from '@adminjs/firebase';
import AdminJS from 'adminjs'; 

const setupAdmin = async expressApp => {
  AdminJS.registerAdapter(AdminJSFirebase);
  const adminJs = new AdminJS({
    branding: {
      companyName: 'Firebase example',
    },
    resources: [
      {
        collection: firebase.firestore().collection('Users'),
        schema: {
          name: 'string',
          isAdmin: 'boolean',
          location: 'mixed',
          attributes: {
            type: 'mixed',
            schema: {
              birthdate: 'date',
              height: 'number',
              eyeColors: 'mixed',
            },
          },
        },
      },
    ],
  });

  const router = await AdminJSExpress.buildRouter(adminJs);
  app.use(adminJs.options.rootPath, router);
};

Authors

Known Issues

Described in Issues tab.

Feel free to contribute.

License

This project is licensed under the MIT License

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文