v1.1.0/setup emulators
This commit is contained in:
@@ -23,3 +23,6 @@ npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
*.cache
|
||||
*.log
|
||||
functions/lib/
|
||||
functions/src/backup.json
|
||||
|
||||
+16
-1
@@ -49,6 +49,21 @@
|
||||
"predeploy": [
|
||||
"npm --prefix \"$RESOURCE_DIR\" run lint",
|
||||
"npm --prefix \"$RESOURCE_DIR\" run build"
|
||||
]
|
||||
],
|
||||
"source": "functions"
|
||||
},
|
||||
"emulators": {
|
||||
"functions": {
|
||||
"port": 5001
|
||||
},
|
||||
"firestore": {
|
||||
"port": 8080
|
||||
},
|
||||
"hosting": {
|
||||
"port": 5000
|
||||
},
|
||||
"ui": {
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"scripts": {
|
||||
"lint": "eslint --ext .js,.ts .",
|
||||
"build": "tsc",
|
||||
"serve": "npm run build && firebase emulators:start --only functions",
|
||||
"serve": "npm run devenv && npm run build && $env:NODE_ENV=DEV && firebase emulators:start",
|
||||
"devenv": "SET NODE_ENV=dev",
|
||||
"shell": "npm run build && firebase functions:shell",
|
||||
"start": "npm run shell",
|
||||
"deploy": "firebase deploy --only functions",
|
||||
|
||||
@@ -37,6 +37,28 @@ const serializeGaId = (_gaid: string): string => {
|
||||
return "";
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV && process.env.NODE_ENV === "dev") {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const backup = require("./backup.json");
|
||||
const BackupResults : Record<string, Record<string,
|
||||
boolean | Record<string, unknown> | string>> =
|
||||
backup.results;
|
||||
|
||||
const BackupStats : Record<string,
|
||||
Record<string, unknown> |
|
||||
Record<string, number> |
|
||||
Record<string, Record<string, number> |
|
||||
Record<string, Record<string, Record<string, number>>>>> =
|
||||
backup.stats;
|
||||
|
||||
Object.keys(BackupResults).forEach((key : string) => {
|
||||
admin.firestore().collection("results").doc(key).set(BackupResults[key]);
|
||||
});
|
||||
Object.keys(BackupStats).forEach((key : string) => {
|
||||
admin.firestore().collection("stats").doc(key).set(BackupStats[key]);
|
||||
});
|
||||
}
|
||||
|
||||
export const saveResult = functions.https.onCall(
|
||||
async (data: SaveResultRequestData, context) => {
|
||||
if (!!data && !!context) {
|
||||
|
||||
Reference in New Issue
Block a user