Skip to content

Commit d645624

Browse files
committed
Custom Firebase set up with common code
1 parent 3ee6463 commit d645624

24 files changed

+6113
-202
lines changed

.prettierrc app/.prettierrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"printWidth": 100,
3-
"tailwindConfig": "./app/tailwind.config.js",
3+
"tailwindConfig": "./tailwind.config.js",
44
"plugins": ["prettier-plugin-tailwindcss"]
55
}

app/tsconfig.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@
2121
"useDefineForClassFields": false,
2222
"lib": ["ES2022", "dom"],
2323
"paths": {
24-
"@app-shared/*": ["./src/app/shared/*"]
24+
"@app-shared/*": ["./src/app/shared/*"],
25+
"@common": ["../firebase/common/index"]
2526
}
2627
},
28+
"references": [
29+
{
30+
"path": "../firebase/common"
31+
}
32+
],
2733
"angularCompilerOptions": {
2834
"enableI18nLegacyMessageIdFormat": false,
2935
"strictInjectionParameters": true,

firebase/.eslintrc.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
es6: true,
5+
node: true,
6+
},
7+
extends: ["eslint:recommended", "prettier"],
8+
parser: "@typescript-eslint/parser",
9+
ignorePatterns: [
10+
"*.d.ts",
11+
"/dist/**",
12+
"/functions/lib/**/*", // Ignore built files.
13+
],
14+
plugins: ["@typescript-eslint", "import"],
15+
overrides: [
16+
{
17+
files: ["*.ts"],
18+
extends: [
19+
"eslint:recommended",
20+
"plugin:import/errors",
21+
"plugin:import/warnings",
22+
"plugin:import/typescript",
23+
"plugin:@typescript-eslint/strict-type-checked",
24+
"plugin:@typescript-eslint/stylistic-type-checked",
25+
"prettier",
26+
],
27+
parserOptions: {
28+
project: ["tsconfig.json", "tsconfig.dev.json", "common/tsconfig.json"],
29+
sourceType: "module",
30+
},
31+
rules: {
32+
"import/no-unresolved": "off",
33+
"@typescript-eslint/consistent-type-definitions": "off",
34+
},
35+
},
36+
],
37+
};

firebase/.firebaserc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"projects": {
3-
"default": "angular-and-firebase-template"
3+
"live": "angular-and-firebase-template"
44
}
55
}

firebase/.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,8 @@ node_modules/
6464

6565
# dotenv environment variables file
6666
.env
67+
68+
dist
69+
70+
service-account*
71+

firebase/.prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"printWidth": 100
3+
}

firebase/common/.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Compiled JavaScript files
2+
*.js
3+
*.js.map
4+
5+
# TypeScript v1 declaration files
6+
typings/
7+
8+
*.d.ts

firebase/common/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export type Test = {
2+
foo: string;
3+
};

firebase/common/tsconfig.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"forceConsistentCasingInFileNames": true,
5+
"strict": true,
6+
"noImplicitOverride": true,
7+
"noPropertyAccessFromIndexSignature": true,
8+
"noImplicitReturns": true,
9+
"noFallthroughCasesInSwitch": true,
10+
"noUnusedLocals": true,
11+
"sourceMap": true,
12+
"module": "commonjs",
13+
"target": "es2017"
14+
}
15+
}

firebase/database.rules.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
".read": false,
44
".write": false
55
}
6-
}
6+
}

firebase/dist/app/browser/index.html

-89
This file was deleted.

firebase/firebase.json

+15-12
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,30 @@
88
},
99
"functions": [
1010
{
11-
"source": "functions",
1211
"codebase": "default",
12+
"source": ".",
13+
"predeploy": ["yarn lint", "yarn functions:build"],
1314
"ignore": [
1415
"node_modules",
1516
".git",
17+
"**/.*",
18+
".vscode",
19+
"*.log",
20+
"dist",
21+
"local",
22+
"firebase.json",
23+
"*.rules",
24+
"firestore.indexes.json",
25+
"remoteconfig.template.json",
26+
"functions/src",
1627
"firebase-debug.log",
1728
"firebase-debug.*.log"
18-
],
19-
"predeploy": [
20-
"npm --prefix \"$RESOURCE_DIR\" run lint",
21-
"npm --prefix \"$RESOURCE_DIR\" run build"
2229
]
2330
}
2431
],
2532
"hosting": {
26-
"public": "dist/app/browser",
27-
"ignore": [
28-
"firebase.json",
29-
"**/.*",
30-
"**/node_modules/**"
31-
],
33+
"public": "dist/app",
34+
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
3235
"rewrites": [
3336
{
3437
"source": "**",
@@ -53,7 +56,7 @@
5356
"port": 9000
5457
},
5558
"hosting": {
56-
"port": 5000
59+
"port": 6001
5760
},
5861
"pubsub": {
5962
"port": 8085

firebase/firestore.rules

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
service cloud.firestore {
22
match /databases/{database}/documents {
33
match /{document=**} {
4-
// This rule allows anyone with your database reference to view, edit,
5-
// and delete all data in your database. It is useful for getting
6-
// started, but it is configured to expire after 30 days because it
7-
// leaves your app open to attackers. At that time, all client
8-
// requests to your database will be denied.
9-
//
10-
// Make sure to write security rules for your app before that time, or
11-
// else all client requests to your database will be denied until you
12-
// update your rules.
13-
allow read, write: if request.time < timestamp.date(2024, 1, 12);
4+
allow read, write: if false;
145
}
156
}
167
}

firebase/functions/.eslintrc.js

-32
This file was deleted.

firebase/functions/.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ lib/**/*.js.map
55
# TypeScript v1 declaration files
66
typings/
77

8-
# Node.js dependency directory
9-
node_modules/
8+
*.d.ts

firebase/functions/package.json

-31
This file was deleted.

firebase/functions/src/index.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
* See a full list of supported triggers at https://firebase.google.com/docs/functions
88
*/
99

10-
import {onRequest} from "firebase-functions/v2/https";
11-
import * as logger from "firebase-functions/logger";
10+
// import {onRequest} from "firebase-functions/v2/https";
11+
// import * as logger from "firebase-functions/logger";
12+
13+
import { Test } from '../../common';
1214

1315
// Start writing functions
1416
// https://firebase.google.com/docs/functions/typescript
@@ -17,3 +19,5 @@ import * as logger from "firebase-functions/logger";
1719
// logger.info("Hello logs!", {structuredData: true});
1820
// response.send("Hello from Firebase!");
1921
// });
22+
23+
export const test: Test = { foo: 'bar' };

firebase/functions/tsconfig.dev.json

-5
This file was deleted.

firebase/functions/tsconfig.json

-15
This file was deleted.

firebase/local/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore everything in this directory
2+
*
3+
# Except this file
4+
!.gitignore

0 commit comments

Comments
 (0)