当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript firebase-admin.initializeApp函数代码示例

本文整理汇总了TypeScript中firebase-admin.initializeApp函数的典型用法代码示例。如果您正苦于以下问题:TypeScript initializeApp函数的具体用法?TypeScript initializeApp怎么用?TypeScript initializeApp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了initializeApp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: initializeApp

 /**
  * Initialize Firebase App
  *
  * @param {any} serviceAccount
  * @param {any} databaseURL
  */
 initializeApp(serviceAccount: string, databaseURL: string) {
     admin.initializeApp({
         credential: admin.credential.cert(serviceAccount),
         databaseURL: databaseURL
     });
     return { 'firestore': admin.firestore() };
 }
开发者ID:ansidev,项目名称:firebase-functions-helper,代码行数:13,代码来源:firebase.ts

示例2: catch

const initializeApp = (projectId: string) => {
  try {
    admin.initializeApp({ projectId });
  } catch (error) {
    if (error.code !== 'app/duplicate-app') {
      throw error;
    }
  }
};
开发者ID:accosine,项目名称:poltergeist,代码行数:9,代码来源:util.ts

示例3: openFirebaseDashboardApp

export function openFirebaseDashboardApp(asGuest = false) {
  // Initialize the Firebase application with firebaseAdmin credentials.
  // Credentials need to be for a Service Account, which can be created in the Firebase console.
  return firebaseAdmin.initializeApp({
    databaseURL: dashboardDatabaseUrl,
    credential: firebaseAdmin.credential.cert({
      project_id: 'material2-board',
      client_email: 'material2-board@appspot.gserviceaccount.com',
      // In Travis CI the private key will be incorrect because the line-breaks are escaped.
      // The line-breaks need to persist in the service account private key.
      private_key: decode(process.env['MATERIAL2_BOARD_FIREBASE_SERVICE_KEY'])
    }),
  });
}
开发者ID:jiw0220,项目名称:jigsaw,代码行数:14,代码来源:firebase.ts

示例4: InvokeRuntimeWithFunctions

        const runtime = InvokeRuntimeWithFunctions(FunctionRuntimeBundles.onCreate, () => {
          const admin = require("firebase-admin");
          admin.initializeApp();
          admin.firestore().settings({
            timestampsInSnapshots: true,
          });

          return {
            function_id: require("firebase-functions")
              .firestore.document("test/test")
              // tslint:disable-next-line:no-empty
              .onCreate(async () => {}),
          };
        });
开发者ID:firebase,项目名称:firebase-tools,代码行数:14,代码来源:functionsEmulatorRuntime.spec.ts

示例5: openFirebaseDashboardApp

export function openFirebaseDashboardApp() {
  // Initialize the Firebase application with firebaseAdmin credentials.
  // Credentials need to be for a Service Account, which can be created in the Firebase console.
  return firebaseAdmin.initializeApp({
    credential: firebaseAdmin.credential.cert({
      project_id: 'material2-dashboard',
      client_email: 'firebase-adminsdk-ch1ob@material2-dashboard.iam.gserviceaccount.com',
      // In Travis CI the private key will be incorrect because the line-breaks are escaped.
      // The line-breaks need to persist in the service account private key.
      private_key: decode(process.env['MATERIAL2_DASHBOARD_FIREBASE_KEY'])
    }),
    databaseURL: 'https://material2-dashboard.firebaseio.com'
  });
}
开发者ID:StefanSinapov,项目名称:material2,代码行数:14,代码来源:firebase.ts

示例6: getInstance

 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import * as firebase from 'firebase-admin';
import * as firebaseServiceAccountJson from "../service-account-firebase.json";
import PlayDeveloperApiClientMock from './mocks/PlayDeveloperApiClientMock';
import DateMock from './mocks/DateMock';
import { PlayBilling } from '../../src/play-billing';

const firebaseServiceAccount:any = firebaseServiceAccountJson;
const TEST_FIREBASE_APP_NAME = 'libraryTestApp';
firebase.initializeApp({
  credential: firebase.credential.cert(firebaseServiceAccount),
  databaseURL: "https://ghdemo-b25b3.firebaseio.com"
}, TEST_FIREBASE_APP_NAME);

export class TestConfig {
  private static _instance: TestConfig;
  private _playBilling: PlayBilling;
  private _playApiClientMock: PlayDeveloperApiClientMock;
  private _dateMock: DateMock;
  
  static getInstance(): TestConfig {
    if (this._instance) {
      return this._instance;
    } else {
      this._instance = new TestConfig();
      return this._instance;
    }
开发者ID:StarshipVendingMachine,项目名称:android-play-billing,代码行数:32,代码来源:TestConfig.ts

示例7: corsOptions

import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin';

import * as corsOptions from 'cors';

import serviceAccount from "./etc/service-key";
import { Forum } from './model/forum/forum';

const cors = corsOptions({ origin: true });

const app = admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://" + serviceAccount.project_id + ".firebaseio.com"
});
const db = app.database();

exports.postApi = functions.https.onRequest((req, res) => {

  cors(req, res, () => {
    console.log("postApi() begins!");
    let forum = new Forum(db.ref('/'));
    //res.send( JSON.stringify( req.body ) + JSON.stringify( req.params ) + JSON.stringify( req.query ) );
    forum.postApi(req.body)
      .then(x => res.send({code: 0, data: x}))
      .catch(e => res.send({ code: e.message, message: forum.getLastErrorMessage }));
    console.log("Send");
  });

});

开发者ID:kurama4u,项目名称:demo-firebase-cms,代码行数:29,代码来源:index.ts

示例8:

 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import * as firebase from 'firebase-admin';
firebase.initializeApp();

import { content_basic, content_premium } from './controller/functions/content'
import { subscription_register, subscription_status, subscription_transfer, realtime_notification_listener } from './controller/functions/subscription'
import { instanceId_register, instanceId_unregister } from './controller/functions/instance_id'

/*
 * This file is the main entrace for Cloud Functions for Firebase.
 * It exposes functions that will be deployed to the backend
 */

// This is a trick to improve performance when there are many functions, 
// by only exporting the function that is needed by the particular instance.
if (!process.env.FUNCTION_NAME || process.env.FUNCTION_NAME === 'content_basic') {
  exports.content_basic = content_basic;
}
开发者ID:StarshipVendingMachine,项目名称:android-play-billing,代码行数:31,代码来源:index.ts

示例9: express

import * as express from 'express';
import * as admin from 'firebase-admin';
import * as functions from 'firebase-functions';
import QuestionService from './service/QuestionServices';
import AnswerService from './service/AnswerServices';

admin.initializeApp(functions.config().firebase);

const app = express();
const questionService = new QuestionService();
const answerService = new AnswerService();
app.disable("x-powered-by");

app.post("/questions/create", async function CreateQuestion(req: express.Request, res: express.Response) {
    questionService.Create(req.body.question, req.body.type, req.body.answers).then(resQuestion => {
        res.status(200).send();
    });
});

app.get("/questions/all", async function GetAllQuestions(req: express.Request, res: express.Response) {
    questionService.GetAllQuestions().then(resQuestion => {
        res.status(200).send(resQuestion);
    });
});

app.get("/questions/:question", async function GetQuestion(req: express.Request, res: express.Response) {
    questionService.GetQuestion(req.param('question')).then(resQeustion => {
        res.status(200).send(resQeustion);
    });

});
开发者ID:zerozodix,项目名称:wedding,代码行数:31,代码来源:index.ts

示例10: initializeApp

import { initializeApp } from 'firebase-admin';

const app = initializeApp();

export default app;
开发者ID:partnercloudsupport,项目名称:postman,代码行数:5,代码来源:firebaseApp.ts

示例11: require

import * as admin from 'firebase-admin';
import * as cors from 'cors';
import * as compression from 'compression';
import * as express from 'express';
import * as functions from 'firebase-functions';
import * as crypto from 'crypto';
import notifyWatch from './transforms/notifyWatch';
import transcriptHandler from './endpoints/transcriptHandler';
import evaluationsHandler from './endpoints/evaluationsHandler';

const serviceAccount = require('../service-account.json');

admin.initializeApp(
  Object.assign({}, functions.config().firebase, {
    credential: admin.credential.cert(serviceAccount),
  }),
);

const app = express();

app.use(cors());
app.use(compression());

// Parse authentication headers if available.
app.use((req, res, next) => {
  const authorization = req.get('authorization');
  if (authorization) {
    const credentials = new Buffer(authorization.split(' ').pop(), 'base64')
      .toString('ascii')
      .split(':');
    req['username'] = credentials[0];
开发者ID:kevmo314,项目名称:canigraduate.uchicago.edu,代码行数:31,代码来源:index.ts

示例12:

import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';

admin.initializeApp(functions.config().firebase);
const db = admin.firestore();



admin.initializeApp({
  credential: admin.credential.applicationDefault(),
  // storageBucket: "gin-manga.appspot.com",
  // databaseURL: 'https://<DATABASE_NAME>.firebaseio.com'
  projectId: 'gin-manga'
});



const firestore = admin.firestore();


const mangahere = firestore.collection('manga_here');






// // Start writing Firebase Functions
// // https://firebase.google.com/docs/functions/typescript
//
export const helloWorld = functions.https.onRequest((request, response) => {
开发者ID:pikax,项目名称:gincloud,代码行数:31,代码来源:index.ts

示例13: base62Encode

import * as admin from 'firebase-admin';
import * as functions from 'firebase-functions';

import {Meta} from './types';

admin.initializeApp();
const db = admin.firestore();

// Base 62 Helper functions
// These allow us to easily increment our "nextUrl" metadata so we can quickly
// create new links in the first available slot. The actual integer value of
// these base62 fields starts 1, but it's never directly used (only
// incremented). What matters is that the URLs will make use of all combinations
// of [0-9A-Za-z]+
const b62 = [
  ...[...Array(10)].map((_, i) => String.fromCharCode('0'.charCodeAt(0) + i)),
  ...[...Array(26)].map((_, i) => String.fromCharCode('A'.charCodeAt(0) + i)),
  ...[...Array(26)].map((_, i) => String.fromCharCode('a'.charCodeAt(0) + i)),
];

// Converts a number to a base62 string
function base62Encode(num: number): string {
  let result = '';
  let value = num - 1;
  while (value >= 0) {
    result = b62[value % 62] + result;
    value = Math.floor((value - 62) / 62);
  }
  return result;
}
开发者ID:brikr,项目名称:bthles,代码行数:30,代码来源:index.ts

示例14: require

import firebaseAdmin, { firestore } from 'firebase-admin';
import { WhereFilterOp } from '@google-cloud/firestore';

// Import .js libs
const container = require('auto-node').Container;

// Import project .ts files
import Category from '../models/category';
import Lockable from '../models/lockable';
import SitePool from '../models/sitepool';
import IService from '../models/iservice';
import ISetting from '../models/isetting';

// Import credential
firebaseAdmin.initializeApp({
    credential: firebaseAdmin.credential.cert('../../Aperture-Test-Manager-V2-8e1d10e8342c.json')
});

const db = firebaseAdmin.firestore();

// [Firestore Specific Helpers]

/**
 * Whether to retrieve the Firestore entity by name or id.
 */
export enum RetrieveBy {
    ID,
    NAME
};

/**
开发者ID:alexHayes08,项目名称:ApertureTestManager,代码行数:31,代码来源:firestore-service.ts

示例15: require

import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';

let serviceAccount;

try {
  serviceAccount = require('../serviceAccountKey.json');
} catch (e) { }

if (serviceAccount) {
  admin.initializeApp({
    credential: admin.credential.cert(serviceAccount),
    databaseURL: 'https://' + serviceAccount['project_id'] + '.firebaseio.com',
    storageBucket: serviceAccount['project_id'] + '.appspot.com'
  });
} else {
  admin.initializeApp(functions.config().firebase);
}

export { github } from './github';
export { linkedin } from './linkedin';
export { ssr } from './ssr';
开发者ID:MichaelSolati,项目名称:ng-portfolio,代码行数:22,代码来源:index.ts


注:本文中的firebase-admin.initializeApp函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。