|
1 | | -import * as admin from "firebase-admin" |
| 1 | +import { initializeApp, App } from "firebase-admin/app" |
| 2 | +import { getAuth } from "firebase-admin/auth" |
| 3 | +import { |
| 4 | + getFirestore, |
| 5 | + Timestamp, |
| 6 | + FieldValue, |
| 7 | + FieldPath, |
| 8 | + DocumentData, |
| 9 | + QueryDocumentSnapshot, |
| 10 | + DocumentSnapshot, |
| 11 | + QuerySnapshot |
| 12 | +} from "firebase-admin/firestore" |
| 13 | +import { getStorage } from "firebase-admin/storage" |
| 14 | + |
| 15 | +export const app: App = initializeApp() |
| 16 | +export const db = getFirestore(app) |
| 17 | +export const storage = getStorage(app) |
| 18 | +export const auth = getAuth(app) |
2 | 19 |
|
3 | | -admin.initializeApp() |
4 | | -export const db = admin.firestore() |
5 | | -export const storage = admin.storage() |
6 | | -export const auth = admin.auth() |
7 | | -export { admin } |
8 | 20 | // Gotta use the same Timestamp class as the admin package. |
9 | | -export const Timestamp = admin.firestore.Timestamp |
10 | | -export type Timestamp = admin.firestore.Timestamp |
11 | | -export const FieldValue = admin.firestore.FieldValue |
12 | | -export type FieldValue = admin.firestore.FieldValue |
13 | | -export const FieldPath = admin.firestore.FieldPath |
14 | | -export type FieldPath = admin.firestore.FieldPath |
15 | | -export type DocumentData = admin.firestore.DocumentData |
16 | | -export type QueryDocumentSnapshot = admin.firestore.QueryDocumentSnapshot |
17 | | -export type DocumentSnapshot = admin.firestore.DocumentSnapshot |
18 | | -export type QuerySnapshot = admin.firestore.QuerySnapshot |
| 21 | +export { Timestamp, FieldValue, FieldPath } |
| 22 | +export type { |
| 23 | + DocumentData, |
| 24 | + QueryDocumentSnapshot, |
| 25 | + DocumentSnapshot, |
| 26 | + QuerySnapshot |
| 27 | +} |
19 | 28 |
|
20 | | -// Extreme hack to extract the File type from the admin storage package. For |
21 | | -// some reason admin.storage does not resolve the storage namespace, as |
22 | | -// admin.firestore does. |
| 29 | +// Extreme hack to extract the File type from the admin storage package. |
23 | 30 | export type File = ReturnType< |
24 | | - ReturnType<ReturnType<typeof admin.storage>["bucket"]>["file"] |
| 31 | + ReturnType<ReturnType<typeof getStorage>["bucket"]>["file"] |
25 | 32 | > |
0 commit comments