Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boilerplate version #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .firebaserc

This file was deleted.

19 changes: 17 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
node_modules
/.pnp
.pnp.js
.firebase

# logs
/backend/local/*.log

# testing
/coverage
Expand All @@ -19,6 +21,19 @@
.env.test.local
.env.production.local

# logs
/backend/*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Compiled JavaScript files
/backend/**/lib/**/*.js
/backend/**/lib/**/*.js.map

# TypeScript v1 declaration files
typings/

# Node.js dependency directory
node_modules/

7 changes: 0 additions & 7 deletions README.md

This file was deleted.

29 changes: 29 additions & 0 deletions backend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"google",
"plugin:@typescript-eslint/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["tsconfig.json", "tsconfig.dev.json"],
sourceType: "module",
},
ignorePatterns: [
"/lib/**/*", // Ignore built files.
],
plugins: ["@typescript-eslint", "import"],
rules: {
"quotes": ["error", "double"],
"semi": ["error", "never"],
"import/no-unresolved": 0,
},
}
5 changes: 5 additions & 0 deletions backend/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "my-react-tutorial-189809"
}
}
14 changes: 14 additions & 0 deletions backend/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Local emulator suite for firebase ([documentation](https://firebase.google.com/docs/emulator-suite/))

![](https://firebase.google.com/docs/emulator-suite/images/emulator-suite-usecase.png)

# get ready

- login `npm run firebase login`
- install the firestore emulator: `npm run firebase setup:emulators:firestore` and the ui `npm run firebase setup:emulators:ui`
- `npm run dev` and point your browser to to http://localhost:4000
- `npm run shell` doc is https://firebase.google.com/docs/functions/local-emulator

# troubleshooting

- need java 11? [use homebrew and link your system to it](https://medium.com/@kirebyte/using-homebrew-to-install-java-jdk11-on-macos-2021-4a90aa276f1c)
7 changes: 7 additions & 0 deletions backend/database.rules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
/* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */
"rules": {
".read": false,
".write": false
}
}
48 changes: 48 additions & 0 deletions backend/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"database": {
"rules": "database.rules.json"
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"functions": [
{
"source": "./",
"codebase": "default",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
],
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
},
"emulators": {
"auth": {
"port": 9099
},
"functions": {
"port": 5001
},
"firestore": {
"port": 8080
},
"ui": {
"enabled": true
},
"singleProjectMode": true
}
}
4 changes: 4 additions & 0 deletions backend/firestore.indexes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"indexes": [],
"fieldOverrides": []
}
19 changes: 19 additions & 0 deletions backend/firestore.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
match /messages/{docId} { // sth is wrong in this logic :-\
allow read: if request.auth.id != null
allow create: if canCreateMessage();
}

function canCreateMessage() {
let isSignedIn = request.auth.uid != null;
// let isOwner = request.auth.uid == request.resource.data.uid;

return isSignedIn; // || isOwner;
}
}
}
Loading