Skip to content
This repository was archived by the owner on Mar 2, 2021. It is now read-only.

Commit e6d4e36

Browse files
committed
Refactor Firebase admin to where it's needed
1 parent 4b0409e commit e6d4e36

File tree

2 files changed

+2
-25
lines changed

2 files changed

+2
-25
lines changed

src/app.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,18 @@
11
const express = require('express')
22
const bodyParser = require('body-parser')
33
const cors = require('cors')
4-
const admin = require('firebase-admin')
54
const functions = require('firebase-functions')
65

76
const config = require('./config')
87
const billings = require('./billings')
98
const embed = require('./embed')
109
const oembed = require('./oembed')
1110

12-
1311
/* Start Express server */
1412
const app = express()
1513
app.use(cors())
1614
app.use(bodyParser.json())
1715

18-
19-
/*
20-
If we want to run the server outside of firebase's function servers
21-
we'll need a service account, to have the right authorization
22-
to connect as admin to our firebase instance.
23-
24-
const serviceAccount = require("./serviceAccountKey.json")
25-
admin.initializeApp({
26-
credential: admin.credential.cert(serviceAccount),
27-
databaseURL: "https://radio4000-staging.firebaseio.com"
28-
});
29-
*/
30-
31-
/*
32-
When used on firebase servers, we just need to pull the config
33-
and run the server that way:
34-
$ firebase serve --only functions
35-
source: https://firebase.google.com/docs/functions/local-emulator
36-
*/
37-
38-
admin.initializeApp(functions.config().firebase)
39-
40-
4116
/* Routes */
4217
app.get('/', function (req, res) {
4318
res.json({

src/billings/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const stripe = require('stripe')
55
const config = require('../config')
66
const noEndpoint = require('../utils/no-endpoint')
77

8+
admin.initializeApp(functions.config().firebase)
9+
810
const billings = express.Router()
911

1012
let stripePrivateKey = functions.config().stripe.private_key

0 commit comments

Comments
 (0)