[FR] Dedicated initializer function for connecting to the Firebase emulator suite
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- node.js, typescript
调研方向
首先阅读 Admin SDK 的入口点 initializeApp、getAuth 和 getFirestore,以及当前对 FIRESTORE_EMULATOR_HOST 的处理方式。将所请求的 emulator 初始化方式与现有的 Web 和 mobile 客户端方案进行比较。在不使用临时环境变量的情况下支持 emulator 和远程 FirebaseApp 实例分离,并包括 Auth 和 Firestore 的使用,即表示完成。
由索引模型根据 Issue 内容生成。
描述
The use case involves use of two initialized instances of FirebaseApp, one for the emulator and another for an actual project. Specifically, it's desirable to programmatically copy data from one to the other without having to export then import separately.
Currently, the Admin SDK requires that an env var is set with host and port in order to connect to the emulator. This is unnecessarily complex when it comes time to init the app. For example, using Auth and Firestore together (and potentially more products) requires code like this:
import { initializeApp } from "firebase-admin/app"
import { getAuth } from "firebase-admin/auth"
import { getFirestore } from "firebase-admin/firestore"
export const remote = initializeApp()
export const remoteAuth = getAuth(remote)
export const remoteFirestore = getFirestore(remote)
process.env.FIRESTORE_EMULATOR_HOST = 'localhost:8080'
export const local = initializeApp(undefined, "local")
export const localAuth = getFirestore(local)
export const localFirestore = getFirestore(local)
delete process.env.FIRESTORE_EMULATOR_HOST
The use of the temporary env var is clunky here, and it would be more straightforward if there was a dedicated function that allowed the caller to pass the host and port instead:
const host, port = ...
export const local = initializeEmulatorApp(host, port, "local")
export const localAuth = getFirestore(local)
export const localFirestore = getFirestore(local)
Either that, or something similar to the way the web and mobile clients work for connecting to the emulator.
- 主要语言
- TypeScript
- 星标
- 1.7k
- 派生
- 419
- 平均合并
- 4 天 20 小时
- 30 天内合并 PR
- 16
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
firebase/firebase-admin-node 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 35/100
firebase/firebase-admin-node#3234 ·
-
[email protected] stable dependency tree fails npm audit via Storage uuid and Firestore google-gax 未关闭
firebase/firebase-admin-node#3221 · 3 条评论 · 已指派 1 人 ·
-
api: messaging
难度 3/5 1-2 天 新手友好度 70/100
firebase/firebase-admin-node#3215 ·
-
api: messaging
难度 5/5 一周以上 新手友好度 28/100
firebase/firebase-admin-node#3214 ·
-
api: firestore type: feature request
firebase/firebase-admin-node#3183 · 1 条评论 · 已指派 1 人 ·
查看 firebase/firebase-admin-node 的全部 Issue
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 88/100
motiondivision/motion#3849 ·
-
check:passed streams:add
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 68/100
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
i-am-bee/beeai-framework#1697 · 1 个 reaction ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 75/100
antfu/node-modules-inspector#214 ·