File tree Expand file tree Collapse file tree 2 files changed +20
-17
lines changed
packages/nuxt/src/runtime/app Expand file tree Collapse file tree 2 files changed +20
-17
lines changed Original file line number Diff line number Diff line change
1
+ import { deleteApp , type FirebaseApp } from 'firebase/app'
2
+ import { LRUCache } from 'lru-cache'
3
+
4
+ // TODO: allow customizing
5
+ // TODO: find sensible defaults. Should they change depending on the platform?
6
+
7
+ // copied from https://github.com/FirebaseExtended/firebase-framework-tools/blob/e69f5bdd44695274ad88dbb4e21aac778ba60cc8/src/constants.ts
8
+ export const LRU_MAX_INSTANCES = 100
9
+ export const LRU_TTL = 1_000 * 60 * 5
10
+ export const appCache = new LRUCache < string , FirebaseApp > ( {
11
+ max : LRU_MAX_INSTANCES ,
12
+ ttl : LRU_TTL ,
13
+ allowStale : true ,
14
+ updateAgeOnGet : true ,
15
+ dispose : ( value ) => {
16
+ deleteApp ( value )
17
+ } ,
18
+ } )
Original file line number Diff line number Diff line change 1
- import { deleteApp , type FirebaseApp , initializeApp } from 'firebase/app'
1
+ import { type FirebaseApp , initializeApp } from 'firebase/app'
2
2
import { type User } from 'firebase/auth'
3
3
import { DecodedIdToken } from 'firebase-admin/auth'
4
- import { LRUCache } from 'lru-cache'
5
4
import { logger } from '../logging'
6
5
import { DECODED_ID_TOKEN_SYMBOL } from '../constants'
6
+ import { appCache } from './lru-cache'
7
7
import { defineNuxtPlugin , useAppConfig } from '#app'
8
8
9
- // TODO: allow customizing
10
- // TODO: find sensible defaults. Should they change depending on the platform?
11
- // copied from https://github.com/FirebaseExtended/firebase-framework-tools/blob/e69f5bdd44695274ad88dbb4e21aac778ba60cc8/src/constants.ts
12
- export const LRU_MAX_INSTANCES = 100
13
- export const LRU_TTL = 1_000 * 60 * 5
14
- const appCache = new LRUCache < string , FirebaseApp > ( {
15
- max : LRU_MAX_INSTANCES ,
16
- ttl : LRU_TTL ,
17
- allowStale : true ,
18
- updateAgeOnGet : true ,
19
- dispose : ( value ) => {
20
- deleteApp ( value )
21
- } ,
22
- } )
23
-
24
9
/**
25
10
* Initializes the app and provides it to others.
26
11
*/
You can’t perform that action at this time.
0 commit comments