-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from returns-modernization/RETURNS-544-update-c…
…loud-function-to-persist-data-in-datastore Returns 544 update cloud function to persist data in datastore
- Loading branch information
Showing
13 changed files
with
80 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
PORT=3000 | ||
LOCAL_RUN=true | ||
CREDENTIAL_PATH=../../../firestore-credentials.json | ||
DATABASE_URL=https://sassy-go.firebaseio.com | ||
CREDENTIAL_PATH=firestore-credentials.json | ||
PROJECT_ID=ingka-isx-return-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,10 @@ | ||
const dotenv = require('dotenv'); | ||
const admin = require('firebase-admin'); | ||
var logger = require('../util/logger'); | ||
const { Datastore } = require('@google-cloud/datastore'); | ||
dotenv.config(); | ||
|
||
try { | ||
var serviceAccount = require(process.env.CREDENTIAL_PATH); | ||
admin.initializeApp({ | ||
credential: admin.credential.cert(serviceAccount), | ||
databaseURL: process.env.DATABASE_URL | ||
}) | ||
} catch (err) { | ||
logger.error("error occured while intializing app with firestore:", err); | ||
} | ||
const db = admin.firestore(); | ||
|
||
module.exports = db | ||
module.exports = (() => { | ||
return new Datastore({ | ||
projectId: process.env.PROJECT_ID, | ||
keyFilename: process.env.CREDENTIAL_PATH | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
var constants = {}; | ||
constants.EVENT_NAME = "raw-sac"; | ||
constants.PERIST_EVENT_SUCESS_MSG = "A new resource have been created in the database"; | ||
constants.PATTERN="-"; | ||
const constants = {}; | ||
constants.ENTITY_KIND_NAME = "raw-sac"; | ||
constants.PERIST_EVENT_SUCCESS_MSG = "A new resource have been created in the database"; | ||
constants.PERIST_EVENT_FAILURE_MSG = "Error while inserting entirty in cloud datastore"; | ||
constants.PATTERN = "-"; | ||
|
||
|
||
module.exports = constants; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,16 +11,14 @@ | |
"url": "[email protected]:returns-modernization/raw-storage-abstraction.git" | ||
}, | ||
"dependencies": { | ||
"@firebase/testing": "^0.14.2", | ||
"@google-cloud/datastore": "^4.5.2", | ||
"@google-cloud/logging-winston": "^3.0.0", | ||
"body-parser": "^1.19.0", | ||
"chai": "^4.2.0", | ||
"chai-http": "^4.3.0", | ||
"dotenv": "^8.2.0", | ||
"express": "^4.17.1", | ||
"express-validator": "^6.2.0", | ||
"firebase-admin": "^8.6.1", | ||
"firebase-functions": "^3.3.0", | ||
"http-status-codes": "^1.3.2", | ||
"log4js": "^5.3.0", | ||
"logger": "0.0.1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters