From e4155174f0a0375b404109564cf5a7f5503ee4c3 Mon Sep 17 00:00:00 2001 From: Hibatullah Fawwaz Hana Date: Sun, 11 May 2025 12:48:20 +0700 Subject: [PATCH] fix: firebase admin version --- functions/.eslintrc.js | 16 +-- functions/package-lock.json | 154 +++++++++++---------- functions/package.json | 2 +- functions/src/config/firebase.ts | 5 +- functions/src/index.ts | 11 +- functions/src/routes/application.ts | 11 +- functions/src/server.ts | 26 ++-- functions/src/utils/fake_data_populator.ts | 54 ++++---- 8 files changed, 146 insertions(+), 133 deletions(-) diff --git a/functions/.eslintrc.js b/functions/.eslintrc.js index 2c7fffa..8ee0e98 100644 --- a/functions/.eslintrc.js +++ b/functions/.eslintrc.js @@ -23,20 +23,20 @@ module.exports = { "/lib/**/*", // Ignore built files. "/generated/**/*", // Ignore generated files. ], - plugins: [ - "@typescript-eslint", - "import", - ], + plugins: ["@typescript-eslint", "import"], rules: { - "quotes": ["error", "double", {"allowTemplateLiterals": true}], + indent: ["error", 2], + quotes: ["error", "double", { allowTemplateLiterals: true }], "import/no-unresolved": 0, - "indent": ["error", 2], "no-restricted-globals": ["error", "name", "length"], "prefer-arrow-callback": "error", "valid-jsdoc": "off", "max-len": "off", "new-cap": "off", - "linebreak-style": ["error", process.platform === "win32" ? "windows" : "unix"], - "@typescript-eslint/no-explicit-any": "off" + "linebreak-style": [ + "error", + process.platform === "win32" ? "windows" : "unix", + ], + "@typescript-eslint/no-explicit-any": "off", }, }; diff --git a/functions/package-lock.json b/functions/package-lock.json index 63a19c3..1d3e2e7 100644 --- a/functions/package-lock.json +++ b/functions/package-lock.json @@ -12,7 +12,7 @@ "cors": "^2.8.5", "dotenv": "^16.4.7", "express": "^4.21.2", - "firebase-admin": "^13.0.2", + "firebase-admin": "^12.7.0", "firebase-functions": "^6.3.2", "jsonwebtoken": "^9.0.2", "lodash": "^4.17.21", @@ -696,104 +696,88 @@ "license": "MIT" }, "node_modules/@firebase/app-check-interop-types": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/@firebase/app-check-interop-types/-/app-check-interop-types-0.3.3.tgz", - "integrity": "sha512-gAlxfPLT2j8bTI/qfe3ahl2I2YcBQ8cFIBdhAQA4I2f3TndcO+22YizyGYuttLHPQEpWkhmpFW60VCFEPg4g5A==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@firebase/app-check-interop-types/-/app-check-interop-types-0.3.2.tgz", + "integrity": "sha512-LMs47Vinv2HBMZi49C09dJxp0QT5LwDzFaVGf/+ITHe3BlIhUiLNttkATSXplc89A2lAaeTqjgqVkiRfUGyQiQ==", "license": "Apache-2.0" }, "node_modules/@firebase/app-types": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/@firebase/app-types/-/app-types-0.9.3.tgz", - "integrity": "sha512-kRVpIl4vVGJ4baogMDINbyrIOtOxqhkZQg4jTq3l8Lw6WSk0xfpEYzezFu+Kl4ve4fbPl79dvwRtaFqAC/ucCw==", + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/@firebase/app-types/-/app-types-0.9.2.tgz", + "integrity": "sha512-oMEZ1TDlBz479lmABwWsWjzHwheQKiAgnuKxE0pz0IXCVx7/rtlkx1fQ6GfgK24WCrxDKMplZrT50Kh04iMbXQ==", "license": "Apache-2.0" }, "node_modules/@firebase/auth-interop-types": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/@firebase/auth-interop-types/-/auth-interop-types-0.2.4.tgz", - "integrity": "sha512-JPgcXKCuO+CWqGDnigBtvo09HeBs5u/Ktc2GaFj2m01hLarbxthLNm7Fk8iOP1aqAtXV+fnnGj7U28xmk7IwVA==", + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@firebase/auth-interop-types/-/auth-interop-types-0.2.3.tgz", + "integrity": "sha512-Fc9wuJGgxoxQeavybiuwgyi+0rssr76b+nHpj+eGhXFYAdudMWyfBHvFL/I5fEHniUM/UQdFzi9VXJK2iZF7FQ==", "license": "Apache-2.0" }, "node_modules/@firebase/component": { - "version": "0.6.13", - "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.6.13.tgz", - "integrity": "sha512-I/Eg1NpAtZ8AAfq8mpdfXnuUpcLxIDdCDtTzWSh+FXnp/9eCKJ3SNbOCKrUCyhLzNa2SiPJYruei0sxVjaOTeg==", + "version": "0.6.9", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.6.9.tgz", + "integrity": "sha512-gm8EUEJE/fEac86AvHn8Z/QW8BvR56TBw3hMW0O838J/1mThYQXAIQBgUv75EqlCZfdawpWLrKt1uXvp9ciK3Q==", "license": "Apache-2.0", "dependencies": { - "@firebase/util": "1.11.0", + "@firebase/util": "1.10.0", "tslib": "^2.1.0" - }, - "engines": { - "node": ">=18.0.0" } }, "node_modules/@firebase/database": { - "version": "1.0.14", - "resolved": "https://registry.npmjs.org/@firebase/database/-/database-1.0.14.tgz", - "integrity": "sha512-9nxYtkHAG02/Nh2Ssms1T4BbWPPjiwohCvkHDUl4hNxnki1kPgsLo5xe9kXNzbacOStmVys+RUXvwzynQSKmUQ==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@firebase/database/-/database-1.0.8.tgz", + "integrity": "sha512-dzXALZeBI1U5TXt6619cv0+tgEhJiwlUtQ55WNZY7vGAjv7Q1QioV969iYwt1AQQ0ovHnEW0YW9TiBfefLvErg==", "license": "Apache-2.0", "dependencies": { - "@firebase/app-check-interop-types": "0.3.3", - "@firebase/auth-interop-types": "0.2.4", - "@firebase/component": "0.6.13", - "@firebase/logger": "0.4.4", - "@firebase/util": "1.11.0", + "@firebase/app-check-interop-types": "0.3.2", + "@firebase/auth-interop-types": "0.2.3", + "@firebase/component": "0.6.9", + "@firebase/logger": "0.4.2", + "@firebase/util": "1.10.0", "faye-websocket": "0.11.4", "tslib": "^2.1.0" - }, - "engines": { - "node": ">=18.0.0" } }, "node_modules/@firebase/database-compat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@firebase/database-compat/-/database-compat-2.0.5.tgz", - "integrity": "sha512-CNf1UbvWh6qIaSf4sn6sx2DTDz/em/D7QxULH1LTxxDQHr9+CeYGvlAqrKnk4ZH0P0eIHyQFQU7RwkUJI0B9gQ==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@firebase/database-compat/-/database-compat-1.0.8.tgz", + "integrity": "sha512-OpeWZoPE3sGIRPBKYnW9wLad25RaWbGyk7fFQe4xnJQKRzlynWeFBSRRAoLE2Old01WXwskUiucNqUUVlFsceg==", "license": "Apache-2.0", "dependencies": { - "@firebase/component": "0.6.13", - "@firebase/database": "1.0.14", - "@firebase/database-types": "1.0.10", - "@firebase/logger": "0.4.4", - "@firebase/util": "1.11.0", + "@firebase/component": "0.6.9", + "@firebase/database": "1.0.8", + "@firebase/database-types": "1.0.5", + "@firebase/logger": "0.4.2", + "@firebase/util": "1.10.0", "tslib": "^2.1.0" - }, - "engines": { - "node": ">=18.0.0" } }, "node_modules/@firebase/database-types": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/@firebase/database-types/-/database-types-1.0.10.tgz", - "integrity": "sha512-mH6RC1E9/Pv8jf1/p+M8YFTX+iu+iHDN89hecvyO7wHrI4R1V0TXjxOHvX3nLJN1sfh0CWG6CHZ0VlrSmK/cwg==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@firebase/database-types/-/database-types-1.0.5.tgz", + "integrity": "sha512-fTlqCNwFYyq/C6W7AJ5OCuq5CeZuBEsEwptnVxlNPkWCo5cTTyukzAHRSO/jaQcItz33FfYrrFk1SJofcu2AaQ==", "license": "Apache-2.0", "dependencies": { - "@firebase/app-types": "0.9.3", - "@firebase/util": "1.11.0" + "@firebase/app-types": "0.9.2", + "@firebase/util": "1.10.0" } }, "node_modules/@firebase/logger": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.4.4.tgz", - "integrity": "sha512-mH0PEh1zoXGnaR8gD1DeGeNZtWFKbnz9hDO91dIml3iou1gpOnLqXQ2dJfB71dj6dpmUjcQ6phY3ZZJbjErr9g==", + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.4.2.tgz", + "integrity": "sha512-Q1VuA5M1Gjqrwom6I6NUU4lQXdo9IAQieXlujeHZWvRt1b7qQ0KwBaNAjgxG27jgF9/mUwsNmO8ptBCGVYhB0A==", "license": "Apache-2.0", "dependencies": { "tslib": "^2.1.0" - }, - "engines": { - "node": ">=18.0.0" } }, "node_modules/@firebase/util": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.11.0.tgz", - "integrity": "sha512-PzSrhIr++KI6y4P6C/IdgBNMkEx0Ex6554/cYd0Hm+ovyFSJtJXqb/3OSIdnBoa2cpwZT1/GW56EmRc5qEc5fQ==", - "hasInstallScript": true, + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-1.10.0.tgz", + "integrity": "sha512-xKtx4A668icQqoANRxyDLBLz51TAbDP9KRfpbKGxiCAW346d0BeJe5vN6/hKxxmWwnZ0mautyv39JxviwwQMOQ==", "license": "Apache-2.0", "dependencies": { "tslib": "^2.1.0" - }, - "engines": { - "node": ">=18.0.0" } }, "node_modules/@google-cloud/firestore": { @@ -2228,6 +2212,7 @@ "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz", "integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==", "license": "MIT", + "optional": true, "engines": { "node": ">= 14" } @@ -2685,13 +2670,15 @@ "url": "https://feross.org/support" } ], - "license": "MIT" + "license": "MIT", + "optional": true }, "node_modules/bignumber.js": { "version": "9.1.2", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==", "license": "MIT", + "optional": true, "engines": { "node": "*" } @@ -4164,7 +4151,8 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "license": "MIT" + "license": "MIT", + "optional": true }, "node_modules/farmhash-modern": { "version": "1.1.0", @@ -4355,28 +4343,27 @@ } }, "node_modules/firebase-admin": { - "version": "13.2.0", - "resolved": "https://registry.npmjs.org/firebase-admin/-/firebase-admin-13.2.0.tgz", - "integrity": "sha512-qQBTKo0QWCDaWwISry989pr8YfZSSk00rNCKaucjOgltEm3cCYzEe4rODqBd1uUwma+Iu5jtAzg89Nfsjr3fGg==", + "version": "12.7.0", + "resolved": "https://registry.npmjs.org/firebase-admin/-/firebase-admin-12.7.0.tgz", + "integrity": "sha512-raFIrOyTqREbyXsNkSHyciQLfv8AUZazehPaQS1lZBSCDYW74FYXU0nQZa3qHI4K+hawohlDbywZ4+qce9YNxA==", "license": "Apache-2.0", "dependencies": { "@fastify/busboy": "^3.0.0", - "@firebase/database-compat": "^2.0.0", - "@firebase/database-types": "^1.0.6", - "@types/node": "^22.8.7", + "@firebase/database-compat": "1.0.8", + "@firebase/database-types": "1.0.5", + "@types/node": "^22.0.1", "farmhash-modern": "^1.1.0", - "google-auth-library": "^9.14.2", "jsonwebtoken": "^9.0.0", "jwks-rsa": "^3.1.0", "node-forge": "^1.3.1", - "uuid": "^11.0.2" + "uuid": "^10.0.0" }, "engines": { - "node": ">=18" + "node": ">=14" }, "optionalDependencies": { - "@google-cloud/firestore": "^7.11.0", - "@google-cloud/storage": "^7.14.0" + "@google-cloud/firestore": "^7.7.0", + "@google-cloud/storage": "^7.7.0" } }, "node_modules/firebase-functions": { @@ -4611,6 +4598,7 @@ "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-6.7.1.tgz", "integrity": "sha512-LDODD4TMYx7XXdpwxAVRAIAuB0bzv0s+ywFonY46k126qzQHT9ygyoa9tncmOiQmmDrik65UYsEkv3lbfqQ3yQ==", "license": "Apache-2.0", + "optional": true, "dependencies": { "extend": "^3.0.2", "https-proxy-agent": "^7.0.1", @@ -4631,6 +4619,7 @@ "https://github.com/sponsors/ctavan" ], "license": "MIT", + "optional": true, "bin": { "uuid": "dist/bin/uuid" } @@ -4640,6 +4629,7 @@ "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-6.1.1.tgz", "integrity": "sha512-a4tiq7E0/5fTjxPAaH4jpjkSv/uCaU2p5KC6HVGrvl0cDjA8iBZv4vv1gyzlmK0ZUKqwpOyQMKzZQe3lTit77A==", "license": "Apache-2.0", + "optional": true, "dependencies": { "gaxios": "^6.1.1", "google-logging-utils": "^0.0.2", @@ -4844,6 +4834,7 @@ "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-9.15.1.tgz", "integrity": "sha512-Jb6Z0+nvECVz+2lzSMt9u98UsoakXxA2HGHMCxh+so3n90XgYWkq5dur19JAJV7ONiJY22yBTyJB1TSkvPq9Ng==", "license": "Apache-2.0", + "optional": true, "dependencies": { "base64-js": "^1.3.0", "ecdsa-sig-formatter": "^1.0.11", @@ -4899,6 +4890,7 @@ "resolved": "https://registry.npmjs.org/google-logging-utils/-/google-logging-utils-0.0.2.tgz", "integrity": "sha512-NEgUnEcBiP5HrPzufUkBzJOD/Sxsco3rLNo1F1TNf7ieU8ryUzBhqba8r756CjLX7rn3fHl6iLEwPYuqpoKgQQ==", "license": "Apache-2.0", + "optional": true, "engines": { "node": ">=14" } @@ -4935,6 +4927,7 @@ "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-7.1.0.tgz", "integrity": "sha512-pCcEwRi+TKpMlxAQObHDQ56KawURgyAf6jtIY046fJ5tIv3zDe/LEIubckAO8fj6JnAxLdmWkUfNyulQ2iKdEw==", "license": "MIT", + "optional": true, "dependencies": { "gaxios": "^6.0.0", "jws": "^4.0.0" @@ -5114,6 +5107,7 @@ "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", "license": "MIT", + "optional": true, "dependencies": { "agent-base": "^7.1.2", "debug": "4" @@ -5569,6 +5563,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "devOptional": true, "license": "MIT", "engines": { "node": ">=8" @@ -6424,6 +6419,7 @@ "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", "license": "MIT", + "optional": true, "dependencies": { "bignumber.js": "^9.0.0" } @@ -6519,6 +6515,7 @@ "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.0.tgz", "integrity": "sha512-jrZ2Qx916EA+fq9cEAeCROWPTfCwi1IVHqT2tapuqLEVVDKFDENFw1oL+MwrTvH6msKxsd1YTDVw6uKEcsrLEA==", "license": "MIT", + "optional": true, "dependencies": { "buffer-equal-constant-time": "1.0.1", "ecdsa-sig-formatter": "1.0.11", @@ -6571,6 +6568,7 @@ "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.0.tgz", "integrity": "sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg==", "license": "MIT", + "optional": true, "dependencies": { "jwa": "^2.0.0", "safe-buffer": "^5.0.1" @@ -6962,6 +6960,7 @@ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", "license": "MIT", + "optional": true, "dependencies": { "whatwg-url": "^5.0.0" }, @@ -8633,7 +8632,8 @@ "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "license": "MIT" + "license": "MIT", + "optional": true }, "node_modules/ts-deepmerge": { "version": "2.0.7", @@ -8942,16 +8942,16 @@ } }, "node_modules/uuid": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", - "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==", "funding": [ "https://github.com/sponsors/broofa", "https://github.com/sponsors/ctavan" ], "license": "MIT", "bin": { - "uuid": "dist/esm/bin/uuid" + "uuid": "dist/bin/uuid" } }, "node_modules/v8-to-istanbul": { @@ -9003,7 +9003,8 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "license": "BSD-2-Clause" + "license": "BSD-2-Clause", + "optional": true }, "node_modules/websocket-driver": { "version": "0.7.4", @@ -9033,6 +9034,7 @@ "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "license": "MIT", + "optional": true, "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" diff --git a/functions/package.json b/functions/package.json index 80364ca..fe05944 100644 --- a/functions/package.json +++ b/functions/package.json @@ -22,7 +22,7 @@ "cors": "^2.8.5", "dotenv": "^16.4.7", "express": "^4.21.2", - "firebase-admin": "^13.0.2", + "firebase-admin": "^12.7.0", "firebase-functions": "^6.3.2", "jsonwebtoken": "^9.0.2", "lodash": "^4.17.21", diff --git a/functions/src/config/firebase.ts b/functions/src/config/firebase.ts index 31e2377..c4b779a 100644 --- a/functions/src/config/firebase.ts +++ b/functions/src/config/firebase.ts @@ -5,8 +5,9 @@ import * as dotenv from "dotenv"; dotenv.config(); admin.initializeApp({ + projectId: process.env.PROJECT_ID, credential: admin.credential.cert(serviceAccount as admin.ServiceAccount), - storageBucket: "garuda-hacks-6-0.firebasestorage.app", + storageBucket: process.env.STORAGE_BUCKET, }); const db = admin.firestore(); @@ -16,7 +17,7 @@ const auth = admin.auth(); * Populate Firestore with fake data if running in emulator * This is useful for testing the API locally * Comment out this block if you don't want to use fake data -*/ + */ // import { FakeDataPopulator } from "../utils/fake_data_populator"; // if (process.env.FIRESTORE_EMULATOR_HOST !== undefined) { // const populator = new FakeDataPopulator(db); diff --git a/functions/src/index.ts b/functions/src/index.ts index 303c804..fb872f4 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -1,7 +1,10 @@ import { onRequest } from "firebase-functions/v2/https"; import app from "./server"; -export const api = onRequest({ - cors: true, - maxInstances: 10 -}, app); +export const api = onRequest( + { + cors: true, + maxInstances: 10, + }, + app +); diff --git a/functions/src/routes/application.ts b/functions/src/routes/application.ts index 021dc00..fffa75d 100644 --- a/functions/src/routes/application.ts +++ b/functions/src/routes/application.ts @@ -4,7 +4,8 @@ import { getApplicationQuestion, getApplicationQuestions, patchApplication, - uploadFile, setApplicationStatusToSubmitted + uploadFile, + setApplicationStatusToSubmitted, } from "../controllers/application_controller"; const router = express.Router(); @@ -13,10 +14,10 @@ router.patch("/", patchApplication); router.post("/file-upload", uploadFile); -router.get("/questions", getApplicationQuestions) -router.get("/question", getApplicationQuestion) +router.get("/questions", getApplicationQuestions); +router.get("/question", getApplicationQuestion); -router.post("/status", setApplicationStatusToSubmitted) -router.get("/status", getApplicationStatus) +router.post("/status", setApplicationStatusToSubmitted); +router.get("/status", getApplicationStatus); export default router; diff --git a/functions/src/server.ts b/functions/src/server.ts index 59481b5..35e802a 100644 --- a/functions/src/server.ts +++ b/functions/src/server.ts @@ -1,10 +1,10 @@ -import express, {NextFunction, Request, Response} from "express"; -import cors, {CorsOptions} from "cors"; +import express, { NextFunction, Request, Response } from "express"; +import cors, { CorsOptions } from "cors"; import routes from "./routes"; import cookieParser from "cookie-parser"; import * as functions from "firebase-functions"; -import {csrfProtection} from "./middlewares/csrf_middleware"; -import {validateSessionCookie} from "./middlewares/auth_middleware"; +import { csrfProtection } from "./middlewares/csrf_middleware"; +import { validateSessionCookie } from "./middlewares/auth_middleware"; const app = express(); @@ -17,20 +17,20 @@ const corsOptions: CorsOptions = { "https://www.garudahacks.com", ], credentials: true, - allowedHeaders: ["Content-Type", "Authorization", "X-XSRF-TOKEN"] -} + allowedHeaders: ["Content-Type", "Authorization", "X-XSRF-TOKEN"], +}; // Middleware app.options("*", cors(corsOptions)); // preflight app.use(cors(corsOptions)); -app.use(cookieParser()) +app.use(cookieParser()); app.use(express.json()); // Auth validation app.use(validateSessionCookie); // CSRF protection as we use session cookie for authentication -app.use(csrfProtection) +app.use(csrfProtection); // Logging app.use((req: Request, res: Response, next: NextFunction) => { @@ -41,7 +41,7 @@ app.use((req: Request, res: Response, next: NextFunction) => { cookies: req.cookies, authorizationHeader: req.headers.authorization || "Not Present", sessionCookie: req.cookies.__session || "Not Present", - body: undefined + body: undefined, }; const contentType = req.headers["content-type"] || ""; @@ -50,7 +50,13 @@ app.use((req: Request, res: Response, next: NextFunction) => { } const timestamp = new Date().toISOString(); - functions.logger.info(`[${timestamp}] Incoming Request Details: ${JSON.stringify(logData, null, 2)}`); + functions.logger.info( + `[${timestamp}] Incoming Request Details: ${JSON.stringify( + logData, + null, + 2 + )}` + ); next(); }); diff --git a/functions/src/utils/fake_data_populator.ts b/functions/src/utils/fake_data_populator.ts index 6ee21f6..9cb62dd 100644 --- a/functions/src/utils/fake_data_populator.ts +++ b/functions/src/utils/fake_data_populator.ts @@ -1,7 +1,11 @@ -import {firestore} from "firebase-admin"; -import {FieldValue} from "firebase-admin/firestore"; -import {faker} from "@faker-js/faker"; -import {APPLICATION_STATES, Question, QUESTION_TYPE} from "../types/application_types"; +import { firestore } from "firebase-admin"; +import { FieldValue } from "firebase-admin/firestore"; +import { faker } from "@faker-js/faker"; +import { + APPLICATION_STATES, + Question, + QUESTION_TYPE, +} from "../types/application_types"; /** * Logs a message with a specific prefix. @@ -60,7 +64,7 @@ export class FakeDataPopulator { date_of_birth: faker.date.past(), education: "High School", school: faker.company.name(), - grade: faker.number.int({min: 9, max: 12}), + grade: faker.number.int({ min: 9, max: 12 }), year: faker.date.future().getFullYear(), gender_identity: "Man", status: "not applicable", @@ -91,9 +95,9 @@ export class FakeDataPopulator { text: "Name", type: QUESTION_TYPE.STRING, validation: { - required: true - } - } + required: true, + }, + }; await this.createQuestionDocument(q); // number example @@ -106,8 +110,8 @@ export class FakeDataPopulator { required: true, minValue: 16, maxValue: 45, - } - } + }, + }; await this.createQuestionDocument(q); // date example @@ -118,8 +122,8 @@ export class FakeDataPopulator { type: QUESTION_TYPE.DATE, validation: { required: true, - } - } + }, + }; await this.createQuestionDocument(q); // dropdown example @@ -131,11 +135,8 @@ export class FakeDataPopulator { validation: { required: true, }, - options: [ - "Undergraduate", - "High School" - ] - } + options: ["Undergraduate", "High School"], + }; await this.createQuestionDocument(q); // file example @@ -147,12 +148,11 @@ export class FakeDataPopulator { validation: { required: true, allowedTypes: "image/jpg,image/jpeg,image/png", - maxSize: 5 - } - } + maxSize: 5, + }, + }; await this.createQuestionDocument(q); - // string example q = { order: 1, @@ -160,9 +160,9 @@ export class FakeDataPopulator { text: "What's your motivation in joining GarudaHacks?", type: QUESTION_TYPE.TEXTAREA, validation: { - required: true - } - } + required: true, + }, + }; await this.createQuestionDocument(q); // string example @@ -172,9 +172,9 @@ export class FakeDataPopulator { text: "Do you have any limitation that we should be concern about?", type: QUESTION_TYPE.TEXTAREA, validation: { - required: true - } - } + required: true, + }, + }; await this.createQuestionDocument(q); }