當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript firebase-functions.config函數代碼示例

本文整理匯總了TypeScript中firebase-functions.config函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript config函數的具體用法?TypeScript config怎麽用?TypeScript config使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了config函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

  .https.onCall(async (data) => {

    const transporter = nodemailer.createTransport({
      host: 'mail.sfwinterbach.com',
      port: 465,
      secure: true,
      auth: {
        user: functions.config().mailer.email,
        pass: functions.config().mailer.password
      }
    });

    const fromName = 'Kontakt';
    const fromEmail = 'kontaktformular@sfwinterbach.com';
    const to = data.to;
    const text = data.text;

    const mailOptions = {
      from: fromName + ' <' + fromEmail + '>',
      to: to,
      subject: 'Anfrage auf ' + transporter.host,
      text: text,
      html: text,
    };

    const info = await transporter.sendMail(mailOptions);
    console.log('Message sent: %s', info.messageId);
    console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));
    console.log(info);
    return info;
  });
開發者ID:Meistercoach83,項目名稱:sfw,代碼行數:31,代碼來源:send-contact-form-to-email.ts

示例2: sendEmail

 static sendEmail(mailOptions) {
   const email = encodeURIComponent(functions.config().smtp.email);
   const password = encodeURIComponent(functions.config().smtp.password);
   const mailTransport = nodemailer.createTransport(
     `smtps://${email}:${password}@authsmtp.uchicago.edu`,
   );
   return new Promise(resolve => mailTransport.sendMail(mailOptions, resolve));
 }
開發者ID:kevmo314,項目名稱:canigraduate.uchicago.edu,代碼行數:8,代碼來源:Config.ts

示例3: Promise

    return new Promise((resolve, reject) =>{
        let id, key;
        try{
            id = functions.config().mailjet.id;
            key = functions.config().mailjet.key;
        }catch(e){
            id = process.env.mailjetid;
            key = process.env.mailjetkey;
        }

        mailjet.connect(id, key)
            .post("send", {'version': 'v3.1'})
            .request(requestBody)
            
            .then((result) => {
                console.log(result.body);
                resolve(result.body);
            })
            .catch((err) => {
                console.log(err);
                reject(err);
            });
    });
開發者ID:sensorium-app,項目名稱:sensorium-backEnd,代碼行數:23,代碼來源:userNotifications.ts

示例4: env

export function env(key: string, fallback?: any, envPath?: string) {
  dotenv.config({ path: envPath ? path.resolve(process.cwd(), envPath) : path.resolve(process.cwd(), '..', '.env') });
  let response: any = false;
  try {
    response = resolve(functions.config(), key.toLowerCase().replace(/_/g, '.'));
    if (!response) {
      response = process.env[key];
    }
  } catch (error) {
    response = process.env[key];
  }

  return response ? response : fallback;
};
開發者ID:MadnessLabs,項目名稱:MadnessEnjineer,代碼行數:14,代碼來源:Env.ts

示例5:

 *
 * For golden images uploaded to /goldens, read the data from images files and write the data to
 * Firebase database under location /screenshot/goldens
 * Screenshot tests can only read restricted database data with no credentials, and they cannot
 * access.
 * Google Cloud Storage. Therefore we copy the image data to database to make it available to
 * screenshot tests.
 *
 * The JWT is stored in the data path, so every write to database needs a valid JWT to be copied to
 * database/storage.
 * All invalid data will be removed.
 * The JWT has 3 parts: header, payload and signature. These three parts are joint by '/' in path.
 */

// Initialize the admin app
firebaseAdmin.initializeApp(firebaseFunctions.config().firebase);

/** The valid data types database accepts */
const dataTypes = ['result', 'sha', 'travis'];

/** The Json Web Token format. The token is stored in data path. */
const jwtFormat = '{jwtHeader}/{jwtPayload}/{jwtSignature}';

/** The temporary folder name for screenshot data that needs to be validated via JWT. */
const tempFolder = '/untrustedInbox';


/** Untrusted report data for a PR */
const reportPath = `${tempFolder}/screenshot/reports/{prNumber}/${jwtFormat}/`;
/** Untrusted image data for a PR */
const imagePath = `${tempFolder}/screenshot/images/{prNumber}/${jwtFormat}/`;
開發者ID:clydin,項目名稱:material2,代碼行數:31,代碼來源:screenshot-functions.ts

示例6: config

import {verify} from 'jsonwebtoken';
import {config} from 'firebase-functions';

/** The JWT secret. This is used to validate JWT. */
const jwtSecret = config().secret.jwt;

/** The repo slug. This is used to validate the JWT is sent from correct repo. */
const repoSlug = config().repo.slug;

export function verifyToken(token: string): boolean {
  try {
    // The returned value of the verify method can be either a string or a object. Reading
    // properties without explicitly treating the result as `any` will lead to a TypeScript error.
    const tokenPayload = verify(token, jwtSecret, {issuer: 'Travis CI, GmbH'}) as any;

    if (tokenPayload.slug !== repoSlug) {
      console.log(`JWT slugs are not matching. Expected ${repoSlug}`);
    }

    return true;
  } catch (e) {
    return false;
  }
}
開發者ID:Chintuz,項目名稱:material2,代碼行數:24,代碼來源:verify-token.ts

示例7: initializeApp

import { Agent } from 'https'
import axios from 'axios'
import { initializeApp, firestore } from 'firebase-admin'
import { config, https } from 'firebase-functions'

initializeApp(config().firebase)

const db = firestore()
const countRef = db.collection('irwtfy').doc('count')
const agent = new Agent({ keepAlive: true })

export const randomEntry = https.onRequest(async (request, response) => {
  const doc = await countRef.get()
  const data = doc.data()
  let count: number
  if (data && data.count && parseInt(data.count) % 1 === 0) {
    count = parseInt(data.count)
  } else {
    const countResponse = await axios.get('https://www.blogger.com/feeds/6752139154038265086/posts/default', {
      params: {
        'alt': 'json',
        'start-index': 1,
        'max-results': 1,
      },
      httpsAgent: agent,
    })
    count = countResponse.data.feed.openSearch$totalResults.$t
    await countRef.set({ count: count })
  }

  const resp = await axios.get('https://www.blogger.com/feeds/6752139154038265086/posts/default', {
開發者ID:vinc3m1,項目名稱:irandomlywrotethisforyou,代碼行數:31,代碼來源:index.ts

示例8: require

import * as admin from 'firebase-admin';
import * as functions from 'firebase-functions';
const moment = require('moment');
import { birthdayWishes } from './birthday-wishes';

moment.locale('de');

// Sengrid
const sgMail = require('@sendgrid/mail');
const SENDGRID_API_KEY = functions.config().sendgrid.key;
sgMail.setApiKey(SENDGRID_API_KEY);

const db = admin.firestore();

const birthdayReminder = functions
  .region('europe-west1')
  .runWith({ memory: '512MB', timeoutSeconds: 12 }).pubsub

  .schedule('0 5 * * *').onRun(async context => {

    try {

      const monthDay = moment().format('MM-DD');
      const mailArray: any = [];

      const recipients: {
        email: string,
        firstName: string,
        lastName: string,
        age: number
      }[] = [];
開發者ID:Meistercoach83,項目名稱:sfw,代碼行數:31,代碼來源:birthday-reminder.ts

示例9: require

import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
const moment = require('moment');
const { google } = require('googleapis');

const GOOGLE_API_KEY = functions.config().google.calendar.key;
const getCalendar = google.calendar({ version: 'v3', auth: GOOGLE_API_KEY });

const db = admin.firestore();

const getGoogleCalendars = functions
  .region('europe-west1')
  .runWith({ memory: '1GB', timeoutSeconds: 25 })
  .https.onRequest(async (req, res) => {

    res.set('Access-Control-Allow-Origin', '*');

    if (req.method === 'OPTIONS') {
      res.header('Access-Control-Allow-Headers', 'Authorization, content-type');
      res.header('Access-Control-Max-Age', '7200');
    }

    const timeMin = req.body.data && req.body.data.startDate ? req.body.data.startDate : moment().startOf('month').toISOString();
    const timeMax = req.body.data && req.body.data.endDate ? req.body.data.endDate : moment().endOf('month').toISOString();

    console.log(timeMin);
    console.log(timeMax);

    try {
      const eventList: any[] = [];
開發者ID:Meistercoach83,項目名稱:sfw,代碼行數:30,代碼來源:get-calendar.ts

示例10: 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


注:本文中的firebase-functions.config函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。