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


TypeScript firebase-functions.https类代码示例

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


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

示例1: getUsersDQ

import * as functions from 'firebase-functions';
import * as admin from "firebase-admin";
import { getUsersDQ } from "../getUsers";
import { getDaysCurrent } from "../util/getDaysCurrent";
import { getPeriodicityQuestion } from "./getPeriodicityQuestion";

export const activeQuestions = functions.https.onRequest((req, response) => {
  let isFlag = false;
  getUsersDQ().then((DQs:Array<any>) => {
    if(isFlag)
      return
    isFlag = true;
    for (const dq of DQs) {
      if (!dq)
        return;
      if(dq.answers) {
        for (let i = 0; i < dq.answers.length; i++)
          if(getDaysCurrent(dq,i) >= getPeriodicityQuestion(dq,i)) 
            admin.database().ref(`/${dq['uidCT']}/users/${dq['id']}/questions/${i}`).update({isActive: true})
      }
    }
    response.send("Questoes ativadas!");
  }).catch(() => console.log('Error para ativar as questĂľes'));
});
开发者ID:dekonunes,项目名称:ConneCT-App,代码行数:24,代码来源:index.ts

示例2: verifyAuthentication

import * as functions from 'firebase-functions';
import { playBilling, verifyAuthentication, contentManager } from '../shared'

const BASIC_PLAN_SKU = functions.config().app.basic_plan_sku;
const PREMIUM_PLAN_SKU = functions.config().app.premium_plan_sku;

/* This file contains implementation of functions related to content serving.
 * Each functions checks if the active user have access to the subscribed content,
 * and then returns the content to client app.
 */

/* Callable that serves basic content to the client
 */
export const content_basic = functions.https.onCall(async (data, context) => {
  verifyAuthentication(context);
  await verifySubscriptionOwnershipAsync(context, [BASIC_PLAN_SKU, PREMIUM_PLAN_SKU]);

  return contentManager.getBasicContent()
})

/* Callable that serves premium content to the client
 */
export const content_premium = functions.https.onCall(async (data, context) => {
  verifyAuthentication(context);
  await verifySubscriptionOwnershipAsync(context, [PREMIUM_PLAN_SKU]);

  return contentManager.getPremiumContent()
})

// Util function that verifies if current user owns at least one active purchases listed in skus
async function verifySubscriptionOwnershipAsync(context: functions.https.CallableContext, skus: Array<string>): Promise<void> {
  const purchaseList = await playBilling.users().queryCurrentSubscriptions(context.auth.uid)
开发者ID:StarshipVendingMachine,项目名称:android-play-billing,代码行数:32,代码来源:content.ts

示例3: require

const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./app/main');

const engine = ngExpressEngine({
  bootstrap: AppServerModuleNgFactory,
  providers: [
    provideModuleMap(LAZY_MODULE_MAP)
  ]
});

const document: string = fs.readFileSync(__dirname + '/app/index.html', 'utf8').toString();

const app = express();
app.get('**', (req, res) => {
  const url: string = req.path;
  engine(url, {
    req,
    res,
    url,
    document,
    bootstrap: AppServerModuleNgFactory,
    providers: [
      provideModuleMap(LAZY_MODULE_MAP)
    ]
  }, (err?: Error, html: string = 'oops') => {
    res.set('Cache-Control', 'public, max-age=3600, s-maxage=43200');
    res.send((err) ? err.message : html);
  });
});

export const ssr = functions.https.onRequest(app);
开发者ID:MichaelSolati,项目名称:ng-portfolio,代码行数:30,代码来源:ssr.ts

示例4: next

    });
});

// Create an error handler.
app.use((err, req, res, next) => {
  if (res.headersSent) {
    return next(err);
  }
  if (res.statusCode === 200) {
    res.statusMessage = err.message || err;
    res.status(400);
  }
  res.json({ error: err.message || err });
});

export const api = functions.https.onRequest(app);
export const grades = functions.pubsub.topic('grades').onPublish(event => {
  const { chicagoId, record } = event.data.json;
  const basis = [record['term'], record['course'], record['section']].join();
  const key = crypto
    .pbkdf2Sync(basis, chicagoId, 2000000, 20, 'sha512')
    .toString('base64')
    .replace(/=/g, '')
    .replace(/\+/g, '-')
    .replace(/\//g, '_');
  return admin
    .firestore()
    .collection('institutions')
    .doc('uchicago')
    .collection('grades')
    .doc(key)
开发者ID:kevmo314,项目名称:canigraduate.uchicago.edu,代码行数:31,代码来源:index.ts

示例5: WebhookClient

import * as functions from 'firebase-functions';
import { WebhookClient } from 'dialogflow-fulfillment';
import WelcomeIntent from './intents/welcome'

process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements

export const sampleFulfillment = functions.https.onRequest((request, response) => {
    const agent = new WebhookClient({ request, response });

    // Run the proper function handler based on the matched Dialogflow intent name
    const intentMap = new Map();
    intentMap.set(WelcomeIntent.name, WelcomeIntent.function);

    agent.handleRequest(intentMap);
});
开发者ID:ArtyMaury,项目名称:sample-dialogflow-fulfillment,代码行数:15,代码来源:index.ts

示例6: addEvent

    });
  });
}

exports.addEventToCalendar = functions.https.onRequest((request, response) => {
  const eventData = {
    eventName: request.body.eventName,
    description: request.body.description,
    startTime: request.body.startTime,
    endTime: request.body.endTime
  };
  const oAuth2Client = new OAuth2(
    googleCredentials.web.client_id,
    googleCredentials.web.client_secret,
    googleCredentials.web.redirect_uris[0]
  );

  oAuth2Client.setCredentials({
    refresh_token: googleCredentials.refresh_token
  });

  addEvent(eventData, oAuth2Client).then(data => {
    response.status(200).send(data);
    return;
  }).catch(err => {
    console.error('Error adding event: ' + err.message);
    response.status(500).send(ERROR_RESPONSE);
    return;
  });
});
开发者ID:Meistercoach83,项目名称:sfw,代码行数:30,代码来源:add-calendar-event.ts

示例7:

  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) => {
 response.send("Hello from Firebase!");
});


export const mangas = functions.https.onRequest(((req, resp) => {
  mangahere.mangas().then(resp.send)
    .catch(resp.send);
}));
开发者ID:pikax,项目名称:gincloud,代码行数:30,代码来源:index.ts

示例8: getOpenPullRequestsWithMergeableState

import {https} from 'firebase-functions';
import {getOpenPullRequestsWithMergeableState} from './github/github-graphql-queries';

/**
 * Firebase HTTP trigger that responds with a list of Pull Requests that have merge conflicts.
 */
export const pullRequestsWithConflicts = https.onRequest(async (_request, response) => {
  const pullRequests = (await getOpenPullRequestsWithMergeableState())
    .filter(pullRequest => pullRequest.mergeable === 'CONFLICTING');

  response.status(200).json(pullRequests);
});

开发者ID:GuzmanPI,项目名称:material2,代码行数:12,代码来源:pull-requests-with-conflicts.ts

示例9: code

const makeFriendshipByFriendCode = https.onCall(async (data, context) => {
  const heroId = context.auth.uid;
  const friendCode = data['friendCode'];

  if (typeof friendCode !== 'string') {
    throw new https.HttpsError('invalid-argument', `data.friendCode must be a string. (given: ${friendCode})`, { hero: heroId, friendCode });
  }

  const heroRef = firestore.collection('users').doc(heroId);

  let opponentRef: any;
  let heroFriendshipRef: any;
  let opponentFriendshipRef: any;
  let chatRef: any;



  await firestore.runTransaction(async (transaction) => {
    const friendCodeDoc = await firestore.collection('friendCodes').doc(friendCode).get();

    if (!friendCodeDoc.exists) {
      throw new https.HttpsError('not-found', `The friend code (${friendCode}) is not found.`, { hero: heroId, friendCode });
    }

    opponentRef = friendCodeDoc.data()['user'];

    if (!(opponentRef instanceof admin.firestore.DocumentReference)) {
      throw new https.HttpsError('internal', 'Something has gone wrong in the process.', { hero: heroId, friendCode });
    }

    if (heroRef.id == opponentRef.id) {
      throw new https.HttpsError('invalid-argument', `The friend code is pointing the requester himself.`, { hero: heroId, friendCode });
    }

    const otherFriendshipRefsWithSameOpponent = heroRef.collection('friendships').where('user', '==', opponentRef);
    const otherFriendshipDocsWithSameOpponent = (await transaction.get(otherFriendshipRefsWithSameOpponent)).docs;

    if (otherFriendshipDocsWithSameOpponent.length > 0) {
      throw new https.HttpsError('already-exists', `The user is already your friend.`, { hero: heroId, opponent: opponentRef.id, friendCode });
    }

    heroFriendshipRef = heroRef.collection('friendships').doc();
    opponentFriendshipRef = opponentRef.collection('friendships').doc();
    chatRef = firestore.collection('chats').doc();

    try {
      transaction
        .create(heroFriendshipRef, {
          user: opponentRef,
          chat: chatRef,
        })
        .create(opponentFriendshipRef, {
          user: heroRef,
          chat: chatRef,
        })
        .create(chatRef, {
          members: [heroRef, opponentRef],
          lastChatMessage: null,
          lastMessageCreatedAt: null,
        })
        .delete(friendCodeDoc.ref);
    } catch (err) {
      console.error(err);

      throw new https.HttpsError('internal', 'Something has gone wrong in the process.', { hero: heroId, friendCode });
    }
  });

  console.info(
    `The requester (id = ${heroRef.id}) and the user (id = ${opponentRef.id}) are now friends.
  friendship:
    The requester (id = ${heroRef.id}): ${heroFriendshipRef.id}
    The user (id = ${opponentRef.id}): ${opponentFriendshipRef.id}
  chat: ${chatRef.id}`
  );
});
开发者ID:partnercloudsupport,项目名称:postman,代码行数:76,代码来源:makeFriendshipByFriendCode.ts

示例10:

import * as functions from 'firebase-functions';

// // Start writing Firebase Functions
// // https://firebase.google.com/docs/functions/typescript
//
export const holaMundo = functions.https.onRequest((request, response) => {
  response.send('Hello from Firebase!');
});
开发者ID:geeksmarter,项目名称:andrews.codes,代码行数:8,代码来源:index.ts


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