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'
22import { type User } from 'firebase/auth'
33import { DecodedIdToken } from 'firebase-admin/auth'
4- import { LRUCache } from 'lru-cache'
54import { logger } from '../logging'
65import { DECODED_ID_TOKEN_SYMBOL } from '../constants'
6+ import { appCache } from './lru-cache'
77import { defineNuxtPlugin , useAppConfig } from '#app'
88
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-
249/**
2510 * Initializes the app and provides it to others.
2611 */
You can’t perform that action at this time.
0 commit comments