-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdb.js
More file actions
40 lines (35 loc) · 1.13 KB
/
db.js
File metadata and controls
40 lines (35 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { Firestore } from '@google-cloud/firestore';
import { BigQuery } from '@google-cloud/bigquery';
// Initialize Firestore with basic optimizations (default connection using env variables)
const firestore = new Firestore({
projectId: process.env.PROJECT,
databaseId: process.env.DATABASE,
settings: {
// Enable connection pooling
maxIdleChannels: 10,
// Enable keepalive to reduce connection overhead
keepaliveTime: 30000,
keepaliveTimeout: 5000,
keepalivePermitWithoutCalls: true
}
});
// Initialize production Firestore connection with hardcoded database
const firestoreOld = new Firestore({
projectId: process.env.PROJECT,
databaseId: 'tech-report-apis-prod',
settings: {
// Enable connection pooling
maxIdleChannels: 10,
// Enable keepalive to reduce connection overhead
keepaliveTime: 30000,
keepaliveTimeout: 5000,
keepalivePermitWithoutCalls: true
}
});
// Export both connections - maintain backward compatibility
export { firestore, firestoreOld };
// Initialize BigQuery client
const bigquery = new BigQuery({
projectId: process.env.PROJECT
});
export { bigquery };