Skip to content
Snippets Groups Projects
Commit ce29ff0e authored by James D'Alton's avatar James D'Alton
Browse files

attempted to get firebase connected... attempted...

parent 1ad6fe22
No related branches found
No related tags found
No related merge requests found
[debug] [2020-04-12T14:54:08.051Z] ----------------------------------------------------------------------
[debug] [2020-04-12T14:54:08.054Z] Command: /home/daltojam/.nvm/versions/node/v13.11.0/bin/node /home/daltojam/.nvm/versions/node/v13.11.0/bin/firebase emulators:start --only functions
[debug] [2020-04-12T14:54:08.054Z] CLI Version: 8.0.2
[debug] [2020-04-12T14:54:08.054Z] Platform: linux
[debug] [2020-04-12T14:54:08.054Z] Node Version: v13.11.0
[debug] [2020-04-12T14:54:08.068Z] Time: Sun Apr 12 2020 15:54:08 GMT+0100 (British Summer Time)
[debug] [2020-04-12T14:54:08.068Z] ----------------------------------------------------------------------
[debug] [2020-04-12T14:54:08.068Z]
[debug] [2020-04-12T14:54:08.102Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2020-04-12T14:54:08.103Z] > authorizing via signed-in user
[info] i emulators: Starting emulators: functions
[debug] [2020-04-12T14:54:08.162Z] [hub] writing locator at /tmp/hub-compforge-80112.json
[info] ✔ hub: emulator hub started at http://localhost:4400
[warn] ⚠ Your requested "node" version "8" doesn't match your global version "13"
[info] ✔ functions: functions emulator started at http://localhost:5001
[info] i functions: Watching "/mnt/a/workspaces/Automatically-Generated-Cyber-Security-Compliance-Engine/compforge/functions" for Cloud Functions...
[debug] [2020-04-12T14:54:08.237Z] [worker-pool] addWorker(~diagnostic~)
[debug] [2020-04-12T14:54:08.238Z] [worker-pool] Adding worker with key ~diagnostic~, total=1
[debug] [2020-04-12T14:54:08.238Z] [worker-pool] submitWork(triggerId=)
[debug] [2020-04-12T14:54:08.239Z] [worker-~diagnostic~-81d20310-ea47-478d-89eb-3a5ad90284d1]: Assigning socketPath: /tmp/fire_emu_646.sock
[debug] [2020-04-12T14:54:08.239Z] [worker-~diagnostic~-81d20310-ea47-478d-89eb-3a5ad90284d1]: BUSY
[debug] [2020-04-12T14:54:08.633Z] [runtime-status] [646] Functions runtime initialized. {"cwd":"/mnt/a/workspaces/Automatically-Generated-Cyber-Security-Compliance-Engine/compforge/functions","node_version":"13.11.0"}
[debug] [2020-04-12T14:54:08.635Z] [runtime-status] [646] Disabled runtime features: undefined
[debug] [2020-04-12T14:54:08.646Z] [runtime-status] [646] Resolved module firebase-admin {"declared":true,"installed":true,"version":"8.10.0","resolution":"/mnt/a/workspaces/Automatically-Generated-Cyber-Security-Compliance-Engine/compforge/functions/node_modules/firebase-admin/lib/index.js"}
[debug] [2020-04-12T14:54:08.653Z] [runtime-status] [646] Resolved module firebase-functions {"declared":true,"installed":true,"version":"3.6.0","resolution":"/mnt/a/workspaces/Automatically-Generated-Cyber-Security-Compliance-Engine/compforge/functions/node_modules/firebase-functions/lib/index.js"}
[debug] [2020-04-12T14:54:08.655Z] [runtime-status] [646] Outgoing network have been stubbed. [{"name":"http","status":"mocked"},{"name":"http","status":"mocked"},{"name":"https","status":"mocked"},{"name":"https","status":"mocked"},{"name":"net","status":"mocked"}]
[debug] [2020-04-12T14:54:09.110Z] [runtime-status] [646] Checked functions.config() {"config":{}}
[debug] [2020-04-12T14:54:09.111Z] [runtime-status] [646] Resolved module firebase-functions {"declared":true,"installed":true,"version":"3.6.0","resolution":"/mnt/a/workspaces/Automatically-Generated-Cyber-Security-Compliance-Engine/compforge/functions/node_modules/firebase-functions/lib/index.js"}
[debug] [2020-04-12T14:54:09.113Z] [runtime-status] [646] Resolved module firebase-admin {"declared":true,"installed":true,"version":"8.10.0","resolution":"/mnt/a/workspaces/Automatically-Generated-Cyber-Security-Compliance-Engine/compforge/functions/node_modules/firebase-admin/lib/index.js"}
[debug] [2020-04-12T14:54:09.114Z] [runtime-status] [646] Resolved module firebase-functions {"declared":true,"installed":true,"version":"3.6.0","resolution":"/mnt/a/workspaces/Automatically-Generated-Cyber-Security-Compliance-Engine/compforge/functions/node_modules/firebase-functions/lib/index.js"}
[debug] [2020-04-12T14:54:09.114Z] [runtime-status] [646] firebase-admin has been stubbed. {"adminResolution":{"declared":true,"installed":true,"version":"8.10.0","resolution":"/mnt/a/workspaces/Automatically-Generated-Cyber-Security-Compliance-Engine/compforge/functions/node_modules/firebase-admin/lib/index.js"}}
[debug] [2020-04-12T14:54:09.911Z] [runtime-status] [646] initializeApp(DEFAULT) {"databaseURL":"https://compforge-80112..firebaseio.com","storageBucket":"compforge-80112.appspot.com","projectId":"compforge-80112","credential":{"implicit":false,"projectId":"compforge-80112","privateKey":"-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC9jWflXn7wJe35\nPWkZ7lqkop7Rfat4NCulFbfcAg8xL+Lp/j8UAILuwVghXZPz+E07WUg6Vgt+EETZ\noEBOHN2sd9evd9RpleEnCwP4fB9nwOj2SSwtOuYzkgrnInb2S67WeeX3CkBIOCTc\nplf1hD2HcmdZPI1TM5oebHRWDLxZUOjUBPi9Xi7b6cYr5dqA7wlgHPXakmSskWKC\nH3+tD0xE8+AcHldWN+M7RNAmpj4k5iB7/8iwNnK8ReW7ZSjowMzvQHkHf3UsZbx1\nU/VZT1vBttdZQuFVKmVLzOqetKbJBfkrd6psJI3MKiZvwg6jn+soYVkMsWtRGjo0\nYuOM38CRAgMBAAECggEACZ2k68I6kQrxirNqc6PvcfrkcObtxgoqfSRQCI+LrwB5\ng8qPr19zxPImuwGU5fteiqBVvUzcZiOj5IDgRj4pYiyNsuNysX0GmB0TUV2Vl8U1\n5DmTzcMXRr41wqIxU/8EonF6YKkC2A8OEqn3HBe+adK8Sq77UeFUJA83Kx7YBrVR\nM1QwNmJBi9uKQK3B4/RqCtd6pUlNcvs9acsNA58X3dDUMtGfhWQC7lT6FlOhyKE4\nYmP3Uj6tUQkHzIrl8dh/a1kK9lTNp2pYI/Rsghq96VThJjujFcrFi9hbOCu0XbXl\ncQvE/ycKeFQcjMWmmKVle5igjfpdajFOiW4piLaISQKBgQD0oC4XLxDxFZfewQXj\nqOHL+33hemxcI3opoANLURUpu/TEopZ5O4wP2b7/bken9D4lVY9GLUpSTxLBiiFG\nXlfLR6WbOhYm/kT4jjmXta4XfvI+jyfFknshcaGzYv6bIgyOXGLhiVxrYkZ2tSRE\nojmudql0nme4W7paiexoGGyu2QKBgQDGXa3HTXMt7EZdU/Jt97lPC4x0tmTUM3Nr\ngktry+ZO2zf9p36ykY75P6sl2bkVW0kfyNiyAUCmZGoG7526HZLOrC4Hv7Q1nA6R\nxW3lSL/TQ/y496FJj/icifhQIaR3mFzEETzhOWe6qiP95OTQRJBu9REOw4PfP72V\n8DD44VB8eQKBgFu+k2qogT8ZrRqi49WNKhn5mS1uX6NyvsdLttCReVFsp5DztWGE\nXrQ3IvXjY0ZvSLtxykk0hTI3a75gUrh0e5LGrSp5b4NyS2W42Yq3XbJ8Ltgdknn7\nxOg3GMEReJGwBGuD5KXXgWzYr7qnlxGSkfWHlWgiXJ388Pgx0BL+TgyJAoGAdvbn\nqYeBdCEncgFOezT+JbG/Yp+giMLyjZ9urA906AYA5lb1XRJ+tGzCr8iLf4tnp3BE\nxTyLET9XdyFtbpkd2mTYlj0aTqxw8Gt/JOskYAd+IVAhooR9jSQRj70dbbwqpkvQ\nPyK2WvR+8V28/EqidGj0+e23wMPxZ2LNe/Vk18ECgYAWnB5tAr5W9YSfe/PUaWjZ\nyWYX5GeCZPbH+YsP+PCw4k9uIkNsvynzUl7ns5m6eE6oiA5WqEYdKAHZ+j5oCMkg\njkCQcagCZ+TVA8ISDoCDexvpCG3r4CE7LKIIZ/F07PxZ5ho76Gyy4FFzkNVTpK0t\nkmVMKyFKLx1mK8iEItlAQA==\n-----END PRIVATE KEY-----\n","clientEmail":"firebase-adminsdk-12dqh@compforge-80112.iam.gserviceaccount.com","httpClient":{"retry":{"maxRetries":4,"statusCodes":[503],"ioErrorCodes":["ECONNRESET","ETIMEDOUT"],"backOffFactor":0.5,"maxDelayInMillis":60000}}}}
[warn] ⚠ functions: The Cloud Firestore emulator is not running, so calls to Firestore will affect production.
[info] ✔ functions[app]: http function initialized (http://localhost:5001/compforge-80112/us-central1/app).
[info] ✔ emulators: All emulators started, it is now safe to connect.
[debug] [2020-04-12T14:54:12.678Z] [worker-~diagnostic~-81d20310-ea47-478d-89eb-3a5ad90284d1]: IDLE
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const express = require('express');
const cors = require('cors');
var serviceAccount = require("./permissions.json");
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
// exports.helloWorld = functions.https.onRequest((request, response) => {
// response.send("Hello from Firebase!");
// });
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://compforge-80112..firebaseio.com"
});
const database = admin.firestore();
const app = express();
app.use(cors({ origin: true }));
app.get('/hello-world', (req, res) => {
return res.status(200).send('Hello World!');
});
// create
app.post('/api/create', (req, res) => {
(async () => {
try {
await db.collection('items').doc('/' + req.body.id + '/')
.create({ item: req.body.item });
return res.status(200).send();
} catch (error) {
console.log(error);
return res.status(500).send(error);
}
})();
});
// read item
app.get('/api/read/:item_id', (req, res) => {
(async () => {
try {
const document = db.collection('items').doc(req.params.item_id);
let item = await document.get();
let response = item.data();
return res.status(200).send(response);
} catch (error) {
console.log(error);
return res.status(500).send(error);
}
})();
});
// update
app.put('/api/update/:item_id', (req, res) => {
(async () => {
try {
const document = db.collection('items').doc(req.params.item_id);
await document.update({
item: req.body.item
});
return res.status(200).send();
} catch (error) {
console.log(error);
return res.status(500).send(error);
}
})();
});
// delete
app.delete('/api/delete/:item_id', (req, res) => {
(async () => {
try {
const document = db.collection('items').doc(req.params.item_id);
await document.delete();
return res.status(200).send();
} catch (error) {
console.log(error);
return res.status(500).send(error);
}
})();
});
exports.app = functions.https.onRequest(app);
\ No newline at end of file
{
"_from": "cors@^2.8.5",
"_from": "cors",
"_id": "cors@2.8.5",
"_inBundle": false,
"_integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
"_location": "/cors",
"_phantomChildren": {},
"_requested": {
"type": "range",
"type": "tag",
"registry": true,
"raw": "cors@^2.8.5",
"raw": "cors",
"name": "cors",
"escapedName": "cors",
"rawSpec": "^2.8.5",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "^2.8.5"
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/",
"/firebase-functions"
],
"_resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
"_shasum": "eac11da51592dd86b9f06f6e7ac293b3df875d29",
"_spec": "cors@^2.8.5",
"_where": "/mnt/a/workspaces/Automatically-Generated-Cyber-Security-Compliance-Engine/compforge/functions/node_modules/firebase-functions",
"_spec": "cors",
"_where": "/mnt/a/workspaces/Automatically-Generated-Cyber-Security-Compliance-Engine/compforge/functions",
"author": {
"name": "Troy Goode",
"email": "troygoode@gmail.com",
......
{
"_from": "express@^4.17.1",
"_from": "express",
"_id": "express@4.17.1",
"_inBundle": false,
"_integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==",
"_location": "/express",
"_phantomChildren": {},
"_requested": {
"type": "range",
"type": "tag",
"registry": true,
"raw": "express@^4.17.1",
"raw": "express",
"name": "express",
"escapedName": "express",
"rawSpec": "^4.17.1",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "^4.17.1"
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/",
"/firebase-functions"
],
"_resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
"_shasum": "4491fc38605cf51f8629d39c2b5d026f98a4c134",
"_spec": "express@^4.17.1",
"_where": "/mnt/a/workspaces/Automatically-Generated-Cyber-Security-Compliance-Engine/compforge/functions/node_modules/firebase-functions",
"_spec": "express",
"_where": "/mnt/a/workspaces/Automatically-Generated-Cyber-Security-Compliance-Engine/compforge/functions",
"author": {
"name": "TJ Holowaychuk",
"email": "tj@vision-media.ca"
......
......@@ -13,6 +13,8 @@
"node": "8"
},
"dependencies": {
"cors": "^2.8.5",
"express": "^4.17.1",
"firebase-admin": "^8.9.0",
"firebase-functions": "^3.3.0"
},
......
{
"type": "service_account",
"project_id": "compforge-80112",
"private_key_id": "311e87bb9187846c219941f250d71bf10de0bbe7",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC9jWflXn7wJe35\nPWkZ7lqkop7Rfat4NCulFbfcAg8xL+Lp/j8UAILuwVghXZPz+E07WUg6Vgt+EETZ\noEBOHN2sd9evd9RpleEnCwP4fB9nwOj2SSwtOuYzkgrnInb2S67WeeX3CkBIOCTc\nplf1hD2HcmdZPI1TM5oebHRWDLxZUOjUBPi9Xi7b6cYr5dqA7wlgHPXakmSskWKC\nH3+tD0xE8+AcHldWN+M7RNAmpj4k5iB7/8iwNnK8ReW7ZSjowMzvQHkHf3UsZbx1\nU/VZT1vBttdZQuFVKmVLzOqetKbJBfkrd6psJI3MKiZvwg6jn+soYVkMsWtRGjo0\nYuOM38CRAgMBAAECggEACZ2k68I6kQrxirNqc6PvcfrkcObtxgoqfSRQCI+LrwB5\ng8qPr19zxPImuwGU5fteiqBVvUzcZiOj5IDgRj4pYiyNsuNysX0GmB0TUV2Vl8U1\n5DmTzcMXRr41wqIxU/8EonF6YKkC2A8OEqn3HBe+adK8Sq77UeFUJA83Kx7YBrVR\nM1QwNmJBi9uKQK3B4/RqCtd6pUlNcvs9acsNA58X3dDUMtGfhWQC7lT6FlOhyKE4\nYmP3Uj6tUQkHzIrl8dh/a1kK9lTNp2pYI/Rsghq96VThJjujFcrFi9hbOCu0XbXl\ncQvE/ycKeFQcjMWmmKVle5igjfpdajFOiW4piLaISQKBgQD0oC4XLxDxFZfewQXj\nqOHL+33hemxcI3opoANLURUpu/TEopZ5O4wP2b7/bken9D4lVY9GLUpSTxLBiiFG\nXlfLR6WbOhYm/kT4jjmXta4XfvI+jyfFknshcaGzYv6bIgyOXGLhiVxrYkZ2tSRE\nojmudql0nme4W7paiexoGGyu2QKBgQDGXa3HTXMt7EZdU/Jt97lPC4x0tmTUM3Nr\ngktry+ZO2zf9p36ykY75P6sl2bkVW0kfyNiyAUCmZGoG7526HZLOrC4Hv7Q1nA6R\nxW3lSL/TQ/y496FJj/icifhQIaR3mFzEETzhOWe6qiP95OTQRJBu9REOw4PfP72V\n8DD44VB8eQKBgFu+k2qogT8ZrRqi49WNKhn5mS1uX6NyvsdLttCReVFsp5DztWGE\nXrQ3IvXjY0ZvSLtxykk0hTI3a75gUrh0e5LGrSp5b4NyS2W42Yq3XbJ8Ltgdknn7\nxOg3GMEReJGwBGuD5KXXgWzYr7qnlxGSkfWHlWgiXJ388Pgx0BL+TgyJAoGAdvbn\nqYeBdCEncgFOezT+JbG/Yp+giMLyjZ9urA906AYA5lb1XRJ+tGzCr8iLf4tnp3BE\nxTyLET9XdyFtbpkd2mTYlj0aTqxw8Gt/JOskYAd+IVAhooR9jSQRj70dbbwqpkvQ\nPyK2WvR+8V28/EqidGj0+e23wMPxZ2LNe/Vk18ECgYAWnB5tAr5W9YSfe/PUaWjZ\nyWYX5GeCZPbH+YsP+PCw4k9uIkNsvynzUl7ns5m6eE6oiA5WqEYdKAHZ+j5oCMkg\njkCQcagCZ+TVA8ISDoCDexvpCG3r4CE7LKIIZ/F07PxZ5ho76Gyy4FFzkNVTpK0t\nkmVMKyFKLx1mK8iEItlAQA==\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-12dqh@compforge-80112.iam.gserviceaccount.com",
"client_id": "106306598588428638963",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-12dqh%40compforge-80112.iam.gserviceaccount.com"
}
import React from 'react';
import './App.css';
import firebase from './firebase'
import SignedIn from './pages/SignedIn'
import SignedOut from './pages/SignedOut'
......@@ -7,6 +8,12 @@ function App() {
// Get isSignedIn
// Hardcoded for now
// const [isSignedIn] = useState(true);
firebase.firestore().collection("forms").add({
name: "My first form",
author: "me"
})
return (
<div className="App">
<header className="App-header">
......
......@@ -19,7 +19,9 @@ const firebaseConfig = {
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.auth(); // For user authentication
firebase.firestore(); // Database
// firebase.auth(); // For user authentication
// firebase.firestore(); // Database
// firebase.functions(); // For data update triggers
// firebase.storage(); // For form objects
export default firebase;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment