Firestore-simple 项目教程
1. 项目的目录结构及介绍
Firestore-simple 项目的目录结构如下:
Firestore-simple/
├── src/
│ ├── admin/
│ │ ├── FirestoreSimple.ts
│ │ └── index.ts
│ ├── web/
│ │ ├── FirestoreSimple.ts
│ │ └── index.ts
│ ├── utils/
│ │ └── index.ts
│ └── index.ts
├── tests/
│ ├── admin/
│ │ └── FirestoreSimple.test.ts
│ ├── web/
│ │ └── FirestoreSimple.test.ts
│ └── utils/
│ └── index.test.ts
├── package.json
├── tsconfig.json
└── README.md
目录介绍
src/
: 包含项目的主要源代码。admin/
: 包含用于 Firebase Admin SDK 的 FirestoreSimple 实现。web/
: 包含用于 Firebase Web SDK 的 FirestoreSimple 实现。utils/
: 包含项目中使用的工具函数。
tests/
: 包含项目的测试代码。admin/
: 包含用于 Firebase Admin SDK 的测试。web/
: 包含用于 Firebase Web SDK 的测试。utils/
: 包含工具函数的测试。
package.json
: 项目的依赖和脚本配置文件。tsconfig.json
: TypeScript 配置文件。README.md
: 项目的说明文档。
2. 项目的启动文件介绍
项目的启动文件位于 src/index.ts
,该文件主要用于导出项目的主要功能模块:
export * from './admin';
export * from './web';
export * from './utils';
启动文件介绍
src/index.ts
: 导出admin
、web
和utils
模块,使得这些模块可以在项目外部被引用。
3. 项目的配置文件介绍
项目的配置文件主要包括 package.json
和 tsconfig.json
。
package.json
package.json
文件包含了项目的依赖、脚本和其他元数据:
{
"name": "firestore-simple",
"version": "1.0.0",
"description": "More simple powerfull and TypeScript friendly Firestore wrapper",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"test": "jest"
},
"dependencies": {
"firebase-admin": "^10.0.0",
"firebase": "^9.0.0"
},
"devDependencies": {
"@types/jest": "^27.0.0",
"jest": "^27.0.0",
"ts-jest": "^27.0.0",
"typescript": "^4.0.0"
}
}
tsconfig.json
tsconfig.json
文件包含了 TypeScript 编译器的配置:
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.test.ts"]
}
配置文件介绍
package.json
: 定义了项目的名称、版本、描述、入口文件、类型定义文件、脚本命令、依赖和开发依赖。tsconfig.json
: 定义了 TypeScript 编译器的选项,包括目标 ECMAScript 版本、模块系统、输出目录、严格模式等。