@mtbjorn/firestorm
v0.0.4
Published
A driver for interacting with Firebase data storage
Downloads
2
Readme
Firestorm
An interface for interacting with Google Firebase data storage.
Getting Started
Get app config for your Firebase app from the Project Settings page
Setup the active Firebase app
import { setupActiveFirebaseApp } from '@mtbjorn/firestorm'; setupActiveFirebaseApp({ appName: 'appName', appConfig: {}, driverConfig: {} });
- TODO: support for managing multiple Firebase apps
Login to the active Firebase app
import { getActiveFirebaseApp } from '@mtbjorn/firestorm'; const { isUserLoggedIn, login } = getActiveFirebaseApp(); const userIsLoggedIn = await isUserLoggedIn('email'); if (!userIsLoggedIn) await login('email', 'password');
Logout of the active Firebase app
import { getActiveFirebaseApp } from '@mtbjorn/firestorm'; const { logout } = getActiveFirebaseApp(); await logout();
Respond to changes in authentication status of active Firebase app
import { getActiveFirebaseApp } from '@mtbjorn/firestorm'; const { addAuthStateListener } = getActiveFirebaseApp(); const removeAuthStateListener = await addAuthStateListener((auth) => { console.log(`Current user: ${auth.email}`) removeAuthStateListener(); });
Upload a file to storage
import { uploadFile } from '@mtbjorn/firestorm'; const url = await uploadFile('fileName', file, 'imagesDirectory');