Firebase Development

作者 mindrally97184105b5da无许可证269 个星标收录于 2026年10月8日更新于 2026年10月8日仓库5周前更新

Firebase development guidelines for Firestore, Authentication, Functions, and Storage with TypeScript and Angular.

AI 生成的概览

使用 TypeScript 和 Angular 开发 Firebase 应用(Firestore、身份验证、云函数、存储)的指南。

功能
提供 Firebase 开发的编码指南与最佳实践,涵盖 Firestore、身份验证、云函数和存储。内容包括项目结构、代码组织、命名规范、性能优化和测试要求。产出的是建议性指导,而非代码或文件。
适用场景
适用于实现或审查基于 Firebase 的应用,尤其是使用 TypeScript 和 Angular 的场景。可用于组织 Firestore 集合、服务、安全规则和云函数。
运行要求
无需任何工具、软件包或凭据;仅为说明性内容,不附带脚本。

Firebase Development

You are an expert in Firebase development with Firestore, Authentication, Cloud Functions, and Storage.

Project Structure

  • Organize code by feature directories (services, components, pipes)
  • Use environment variables for development, staging, and production
  • Structure Firestore collections logically (users, spots, bookings)
  • Maintain separate Firebase configurations per environment

Code Organization Best Practices

  • Use descriptive naming: "getUsers", "calculateTotalPrice"
  • Keep classes small and focused
  • Minimize global state usage
  • Centralize API calls and error handling through services
  • Manage storage through a single point of entry with centralized key definitions

Firebase-Specific Patterns

Firestore

  • Create dedicated services for each Firestore collection type
  • Implement centralized Firebase error handling
  • Use transactions for data consistency
  • Apply Firebase security rules for data protection

Cloud Functions

  • Leverage Firebase Functions for serverless backend logic
  • Implement proper error handling and logging
  • Use typed function parameters and responses

Storage

  • Handle file uploads/downloads via Firebase Storage
  • Implement proper access control
  • Use signed URLs for secure file access

Authentication

  • Manage user identity through Firebase Authentication
  • Implement proper session management
  • Handle auth state changes reactively

Naming Conventions

  • camelCase: functions and variables
  • kebab-case: file names (user-service.ts)
  • PascalCase: classes (UserService)
  • Boolean prefixes: should, has, is (shouldLoadData, isLoading)
  • Collections: plural nouns
  • Documents: descriptive IDs

Performance Optimization

  • Implement lazy loading and data prefetching
  • Cache frequently accessed data
  • Use global error and alert handlers
  • Implement Firebase offline persistence
  • Apply query cursors for pagination
  • Optimize Firestore reads through proper indexing
  • Use batch operations for bulk updates

Testing Requirements

  • Write comprehensive unit tests covering edge cases
  • Mock native plugins and Firestore services
  • Test Firebase security rules thoroughly
  • Validate offline functionality

来源与署名

来源:mindrally/skills位于firebase-development提交9718410

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架