v1.1.0/setup emulators
This commit is contained in:
@@ -23,3 +23,6 @@ npm-debug.log*
|
|||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
*.cache
|
*.cache
|
||||||
|
*.log
|
||||||
|
functions/lib/
|
||||||
|
functions/src/backup.json
|
||||||
|
|||||||
+20
-5
@@ -9,11 +9,11 @@
|
|||||||
"rewrites": [
|
"rewrites": [
|
||||||
{
|
{
|
||||||
"source": "/copyright",
|
"source": "/copyright",
|
||||||
"destination" : "/copyright.html"
|
"destination": "/copyright.html"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"source": "/privacy",
|
"source": "/privacy",
|
||||||
"destination" : "/privacy.html"
|
"destination": "/privacy.html"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"source": "/jj",
|
"source": "/jj",
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
"destination": "/index.html"
|
"destination": "/index.html"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"source": "/md",
|
"source": "/md",
|
||||||
"destination": "/index.html"
|
"destination": "/index.html"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
"destination": "/index.html"
|
"destination": "/index.html"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"source": "/md/**",
|
"source": "/md/**",
|
||||||
"destination": "/index.html"
|
"destination": "/index.html"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -49,6 +49,21 @@
|
|||||||
"predeploy": [
|
"predeploy": [
|
||||||
"npm --prefix \"$RESOURCE_DIR\" run lint",
|
"npm --prefix \"$RESOURCE_DIR\" run lint",
|
||||||
"npm --prefix \"$RESOURCE_DIR\" run build"
|
"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": {
|
"scripts": {
|
||||||
"lint": "eslint --ext .js,.ts .",
|
"lint": "eslint --ext .js,.ts .",
|
||||||
"build": "tsc",
|
"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",
|
"shell": "npm run build && firebase functions:shell",
|
||||||
"start": "npm run shell",
|
"start": "npm run shell",
|
||||||
"deploy": "firebase deploy --only functions",
|
"deploy": "firebase deploy --only functions",
|
||||||
|
|||||||
@@ -37,6 +37,28 @@ const serializeGaId = (_gaid: string): string => {
|
|||||||
return "";
|
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(
|
export const saveResult = functions.https.onCall(
|
||||||
async (data: SaveResultRequestData, context) => {
|
async (data: SaveResultRequestData, context) => {
|
||||||
if (!!data && !!context) {
|
if (!!data && !!context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user