How to use the firebase-functions.https.onCall function in firebase-functions

To help you get started, we’ve selected a few firebase-functions 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 dpsthree / angular-performance-playground / functions / src / index.ts View on Github external
import * as faker from 'faker';
import * as _ from 'lodash';
import * as cors from 'cors';

const colorList = [
  '#1565c0',
  '#5e92f3',
  '#003c8f',
  '#e91e63',
  '#ff6090',
  '#b0003a'
];

cors({ origin: true });

export const graphEntities = https.onCall(async (data, context) => {
  if (data && data.count) {
    const count = data.count;
    if (count >= 0 && count <= 5000) {
      return await generatedData(count);
    } else {
      return await generatedData(500);
    }
  } else {
    return await generatedData(1000);
  }
});

// use faker to create count random people
// associate them with a color and add to list
function generatedData(count: number) {
  const entities = [];