How to use the @firebase/app.default function in @firebase/app

To help you get started, we’ve selected a few @firebase/app examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github firebase / firebase-js-sdk / packages / database / index.node.ts View on Github external
instance.registerVersion(name, version, 'node');

  if (isNodeSdk()) {
    module.exports = Object.assign({}, namespace, { initStandalone });
  }
}

try {
  // If @firebase/app is not present, skip registering database.
  // It could happen when this package is used in firebase-admin which doesn't depend on @firebase/app.
  // Previously firebase-admin depends on @firebase/app, which causes version conflict on
  // @firebase/app when used together with the js sdk. More detail:
  // https://github.com/firebase/firebase-js-sdk/issues/1696#issuecomment-501546596
  // eslint-disable-next-line import/no-extraneous-dependencies, @typescript-eslint/no-require-imports
  const firebase = require('@firebase/app').default;
  registerDatabase(firebase);
} catch (err) {
  // catch and ignore 'MODULE_NOT_FOUND' error in firebase-admin context
  // we can safely ignore this error because RTDB in firebase-admin works without @firebase/app
  if (err.code !== 'MODULE_NOT_FOUND') {
    throw err;
  }
}

// Types to export for the admin SDK
export { Database, Query, Reference, enableLogging, ServerValue };

export { DataSnapshot } from './src/api/DataSnapshot';
export { OnDisconnect } from './src/api/onDisconnect';

declare module '@firebase/app-types' {
github cheeaun / node-hnapi / lib / hnapi.js View on Github external
const firebase = require('@firebase/app').default;
require('@firebase/database');
var moment = require('moment');
var extend = require('extend');
var url = require('url');
var he = require('he');

firebase.initializeApp({
  databaseURL: 'https://hacker-news.firebaseio.com',
});
var hn = firebase.database().ref('/v0');
var hnRecentItems = hn.child('updates/items');

var typeMapping = {
  story: 'link'
};