import * as CORS from 'cors' ; export const cors = CORS ( { origin : true } ) ; function corsMiddleware ( req , res , next ) { res . setHeader ( 'Access-Control-Allow-Origin' , '*' ) ; res . setHeader ( 'Access-Control-Allow-Methods' , 'GET, POST, OPTIONS, PUT, PATCH, DELETE' ) ; res . setHeader ( 'Access-Control-Allow-Headers' , 'X-Requested-With,content-type' ) ; res . setHeader ( 'Access-Control-Allow-Credentials' , true ) ; next ( ) ; } import * as express from 'express' ; export const app = express ( ) ; import { authenticateUser } from './helpers' ; app . use ( cors ) ; app . use ( corsMiddleware ) ; app . use ( authenticateUser ) ; import * as functions from 'firebase-functions' ; import * as admin from 'firebase-admin' ; const serviceAccount = require ( '../../credentials.json' ) ; admin . initializeApp ( { credential : admin . credential . cert ( serviceAccount ) , databaseURL : "https://stripe-elements.firebaseio.com" } ) ; export const db = admin . firestore ( ) ; export const auth = admin . auth ( ) ; import * as Stripe from 'stripe' ; export const stripeSecret = serviceAccount . stripe . secret ; export const stripePublishable = serviceAccount . stripe . publishable ; export const stripeClientId = serviceAccount . stripe . clientid ; export const stripe = new Stripe ( stripeSecret ) ;