npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

@inpassor/firebase-config

1.2.1 • Public • Published

Firebase Remote Config library

This library used for interaction with Firebase Remote Config REST API to set or get Remote Config values in Node.js environment.

Dependacies

google-auth-library

The library uses google-auth-library npm package and provides a variety of ways to authenticate Remote Config API requests:

  • Provide a keyId and key of your Firebase project.
  • Provide a private key file for your Firebase service account.
  • Provide GOOGLE_APPLICATION_CREDENTIALS environment variable.
  • Use none of above in case of usage of the library on Google Cloud.

Read about Google Cloud API authentication at Getting Started with Authentication

node-cache

The library uses node-cache npm package for storing ETag value.

See cacheOptions config option.

flat

The library uses flat npm package for flatten and unflatten Remote Config parameters.

See delimiter config option.

Example

import * as path from 'path';
import {
    FirebaseConfig,
    DataObject,
} from '@inpassor/firebase-config';
 
/**
 * Instantiate FirebaseConfig
 */
const firebaseConfig = new FirebaseConfig({
    projectId: 'my-awesome-project-id',
    keyFileName: path.resolve('path', 'to', 'my-awesome-project-service-key.json'),
    // key: 'my-project-key',
    // keyId: 'my-project-key-id',
    // cacheOptions: {
    //     forceString?: boolean;
    //     objectValueSize?: number;
    //     arrayValueSize?: number;
    //     stdTTL?: number;
    //     checkperiod?: number;
    //     useClones?: boolean;
    //     errorOnMissing?: boolean;
    //     deleteOnExpire?: boolean;
    // },
    // delimiter: '___',
    // defaultErrorMessage: 'Invalid response from the Firebase Remote Config service',
});
 
/**
 * Set Remote Config 
 */
firebaseConfig.set({
    // [key: string]: any
}).then(
    () => console.log('published'),
    (error: any) => console.error(error),
);
 
/**
 * Get Remote Config 
 */
firebaseConfig.get().then(
    (parameters: DataObject) => console.log(parameters),
    (error: any) => console.error(error),
);

install

npm i @inpassor/firebase-config

Downloadsweekly downloads

53

version

1.2.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability