-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robby Rabbitman
committed
Jan 24, 2024
1 parent
12cca35
commit bb3171f
Showing
21 changed files
with
625 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,27 @@ | ||
import { provideHttpClient } from '@angular/common/http'; | ||
import { | ||
ApplicationConfig, | ||
importProvidersFrom, | ||
makeEnvironmentProviders, | ||
ɵprovideZonelessChangeDetection, | ||
} from '@angular/core'; | ||
import { initializeApp, provideFirebaseApp } from '@angular/fire/app'; | ||
import { connectAuthEmulator, getAuth, provideAuth } from '@angular/fire/auth'; | ||
import { | ||
connectFirestoreEmulator, | ||
getFirestore, | ||
provideFirestore, | ||
} from '@angular/fire/firestore'; | ||
|
||
import { provideRouter } from '@angular/router'; | ||
import { provideAuthData } from '@cv/auth/data'; | ||
import { provideCommonData } from '@cv/common/data'; | ||
import { provideFirebase } from '@cv/common/util'; | ||
import { provideCvData } from '@cv/data'; | ||
import { provideI18nData } from '@cv/i18n/data'; | ||
import { environment } from '../environments/environment'; | ||
import { appRoutes } from './app.routes'; | ||
|
||
function provideFirebase() { | ||
return makeEnvironmentProviders([ | ||
importProvidersFrom([ | ||
provideFirebaseApp(() => initializeApp(environment.firebase)), | ||
// auth | ||
provideAuth(() => { | ||
const auth = getAuth(); | ||
const emulators = environment.firebase.emulators; | ||
|
||
if (emulators?.auth) { | ||
connectAuthEmulator( | ||
auth, | ||
`http://${emulators.auth.host}:${emulators.auth.port}`, | ||
); | ||
} | ||
|
||
return auth; | ||
}), | ||
// firestore | ||
provideFirestore(() => { | ||
const firestore = getFirestore(); | ||
const emulators = environment.firebase.emulators; | ||
|
||
if (emulators?.firestore) { | ||
connectFirestoreEmulator( | ||
firestore, | ||
emulators.firestore.host, | ||
emulators.firestore.port, | ||
); | ||
} | ||
|
||
return firestore; | ||
}), | ||
]), | ||
]); | ||
} | ||
|
||
export const appConfig: ApplicationConfig = { | ||
providers: [ | ||
provideRouter(appRoutes), | ||
provideFirebase(), | ||
provideFirebase(environment.firebase), | ||
provideCommonData(), | ||
provideCvData(), | ||
provideAuthData(), | ||
provideI18nData(), | ||
provideHttpClient(), | ||
ɵprovideZonelessChangeDetection(), | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,6 @@ | ||
import { FirebaseOptions } from '@angular/fire/app'; | ||
import { FirebaseConfig } from '@cv/common/util'; | ||
|
||
export interface Environment { | ||
stage: 'prod' | 'dev' | 'local'; | ||
firebase: FirebaseOptions & { | ||
emulators?: Record< | ||
'firestore' | 'auth', | ||
{ | ||
host: string; | ||
port: number; | ||
} | ||
>; | ||
}; | ||
firebase: FirebaseConfig; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { ThemeSelect } from './theme-select'; | ||
|
||
describe('ThemeSelect', () => { | ||
let component: ThemeSelect; | ||
let fixture: ComponentFixture<ThemeSelect>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ThemeSelect], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ThemeSelect); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); | ||
test.todo('ThemeSelect'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './lib/document'; | ||
export * from './lib/firebase'; | ||
export * from './lib/signal'; | ||
export * from './lib/theme'; | ||
export * from './lib/uuid'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { FirebaseApp, FirebaseOptions, initializeApp } from 'firebase/app'; | ||
import { Auth, connectAuthEmulator, getAuth } from 'firebase/auth'; | ||
import { | ||
Firestore, | ||
connectFirestoreEmulator, | ||
getFirestore, | ||
} from 'firebase/firestore'; | ||
import { createNoopInjectionToken } from 'ngxtension/create-injection-token'; | ||
|
||
export const [firebaseApp, provideFirebaseApp] = | ||
createNoopInjectionToken<FirebaseApp>('[Firebase] App'); | ||
|
||
export const [firestore, provideFirestore] = | ||
createNoopInjectionToken<Firestore>('[Firebase] Firestore'); | ||
|
||
export const [firebaseAuth, provideFirebaseAuth] = | ||
createNoopInjectionToken<Auth>('[Firebase] Auth'); | ||
|
||
export interface FirebaseConfig { | ||
options: FirebaseOptions; | ||
features?: Partial<{ | ||
auth: { | ||
emulators?: { host: string; port: number }; | ||
}; | ||
firestore: { | ||
emulators?: { host: string; port: number }; | ||
}; | ||
}>; | ||
} | ||
|
||
export function provideFirebase({ options, features }: FirebaseConfig) { | ||
const app = initializeApp(options); | ||
const providers = [provideFirebaseApp(app)]; | ||
|
||
for (const feature in features) { | ||
switch (feature) { | ||
case 'auth': { | ||
const auth = getAuth(app); | ||
providers.push(provideFirebaseAuth(auth)); | ||
|
||
const emulators = features[feature]?.emulators; | ||
|
||
if (emulators) { | ||
connectAuthEmulator( | ||
auth, | ||
`http://${emulators.host}:${emulators.port}`, | ||
); | ||
} | ||
|
||
break; | ||
} | ||
case 'firestore': { | ||
const firestore = getFirestore(app); | ||
providers.push(provideFirestore(firestore)); | ||
|
||
const emulators = features[feature]?.emulators; | ||
|
||
if (emulators) { | ||
connectFirestoreEmulator(firestore, emulators.host, emulators.port); | ||
} | ||
|
||
break; | ||
} | ||
} | ||
} | ||
|
||
return providers; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.