当前位置: 首页>>代码示例>>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;未经允许,请勿转载。