Skip to content

Commit

Permalink
Read environmental variables from .env file
Browse files Browse the repository at this point in the history
  • Loading branch information
Irenej Bozovicar committed Jan 8, 2024
1 parent 15aafea commit 119376a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion functions/firebase-adminsdk-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// Load environment variables from .env file
require('dotenv').config();
const path = require('path');
const dotenv = require('dotenv');

// Specify the path to your .env file
const envPath = path.resolve(__dirname, '../.env');
dotenv.config({ path: envPath });

const serviceAccount = {
"type": "service_account",
Expand Down
2 changes: 1 addition & 1 deletion functions/firebase.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const admin = require('firebase-admin');
const serviceAccount = require('./firebase-admin');
const serviceAccount = require('./firebase-adminsdk-config');

admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
Expand Down
2 changes: 1 addition & 1 deletion functions/importData.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const admin = require('firebase-admin');
const serviceAccount = require('./firebase-admin.json');
const serviceAccount = require('./firebase-adminsdk-config');
const readline = require('readline');
const fs = require('fs');

Expand Down

0 comments on commit 119376a

Please sign in to comment.