You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Uuid](https://github.com/uuidjs/uuid) (★ 8.7k) generate RFC-compliant UUIDs in JavaScript.
149
144
-[Glob](https://github.com/isaacs/node-glob) (★ 6.2k) glob functionality for Node.js.
150
-
-[Fs-extra](https://github.com/jprichardson/node-fs-extra) (★ 6.6k) Node.js: extra methods for the fs object like copy(), remove(), mkdirs().
145
+
-[Camelcase](https://github.com/sindresorhus/camelcase) (★ 423) convert a dash/dot/underscore/space separated string to camelCase.
151
146
-[Resize Image](https://github.com/firebase/extensions/tree/master/storage-resize-images) (★ 372) Firebase Extension to create resized versions of images uploaded to Cloud Storage.
152
147
148
+
### Unit Testing
149
+
150
+
-[Firebase-functions-test](https://github.com/firebase/firebase-functions-test) (★ 117) unit testing library for Cloud Functions for Firebase.
151
+
153
152
## Prerequisites
154
153
155
154
-[Firebase](https://firebase.google.com/) account in order to set up the serverless BaaS for the project.
156
-
-[Node.js](https://nodejs.org/) v12.15.0 or higher (React frontend) and v8.17.0 (Cloud Functions) (You can install them using [NVM](https://github.com/nvm-sh/nvm)).
155
+
-[Node.js](https://nodejs.org/) v12.15.0 or higher (React frontend) and v10.0.0 (Cloud Functions) (You can install them using [NVM](https://github.com/nvm-sh/nvm)).
You also need to be familiar with [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML), [CSS](https://developer.mozilla.org/en-US/docs/Web/CSS), [SASS](https://sass-lang.com/), [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) ([ES2015](http://babeljs.io/learn-es2015/)) and [React](https://reactjs.org/) with [React Hooks](https://reactjs.org/docs/hooks-intro.html).
@@ -166,15 +165,21 @@ You also need to be familiar with [HTML](https://developer.mozilla.org/en-US/doc
166
165
- In the **_Storage_** section set up your storage bucket with the default values provided by Firebase.
167
166
- Setup your sign-in providers in the **_Authentication_** section. On the **_Sign in method_** tab, enable **_Email/Password_** provider with the **_Email Link_** feature.
168
167
- Copy the config values you get from you Firebase dashboard's **_Web Setup_** option and enter them into a `.env` file with the same structure as the `.env.example` in the root directory of the repository.
168
+
- Setup the [image resize extension](https://firebase.google.com/products/extensions/storage-resize-images) in your Firebase project. For instructions go to the [File upload section](#file-upload)
169
169
170
170
### Setting up the Firebase project locally
171
171
172
172
First we need to install the Firebase cli tool and then initialize our new Firebase project.
173
173
174
174
Run the following commands in the root of the repository:
175
175
176
-
-`npm install -g firebase-tools`
177
-
-`firebase init`
176
+
```
177
+
npm install -g firebase-tools
178
+
```
179
+
180
+
```
181
+
firebase init
182
+
```
178
183
179
184
Select the firebase project you created in the previous step, when prompted select the services you want to setup and check **_Database_**, **_Functions_**, **_Hosting_** and **_Storage_**.
180
185
@@ -183,42 +188,41 @@ Select the firebase project you created in the previous step, when prompted sele
183
188
- Leave the default name for our rules `.json` file.
184
189
- Select **_No_** when prompted if you want to overwrite the file containing our rules.
185
190
186
-
**_Functions_**:
187
-
188
-
- For the language to be used in our functions select **_JavaScript_**.
189
-
- If we want to use ESLint as our linting tool select **_No_**.
190
-
- If we want to overwrite the `package.json`, `.gitignore` and `index.js` select **_No_**.
191
-
- Then select **_Yes_** so that we install our dependencies with npm.
192
-
193
191
**_Hosting_**:
194
192
195
193
- Set **build** as our public directory for our hosting files.
196
194
- Select **_Yes_** when asked if we want our hosting to be configured as a single page application.
197
195
198
-
Run the following commands in the `functions/` folder (Using Node v8.17.0):
196
+
**_Storage_**
199
197
200
-
-`npm run setup-firebase`
198
+
-For the file we should use for the Storage Rules select **storage.rules**.
201
199
202
-
You'll get prompted to enter the path to you service account key file. To generate it, go to your **_Firebase Dashboard_**, **_Project settings_** tab and then to **_Service accounts_** option, right there you can generate your private key (more info on this [here](https://firebase.google.com/docs/admin/setup#initialize-sdk)).
200
+
**_Functions_**:
203
201
204
-
You'll need to enter the **_email_** and **_password_** for the admin account of the admin dashboard. With this in place, you've successfully created your admin account for the dashboard.
202
+
- For the language to be used in our functions select **_TypeScript_**.
203
+
- If we want to use ESLint as our linting tool select **_No_**.
204
+
- If we want to overwrite the `package.json`, `.gitignore` and `index.js` select **_No_**.
205
+
- Then select **_Yes_** so that we install our dependencies with npm.
205
206
206
-
**_Storage_**
207
-
-For the file we should use for the Storage Rules select storage.rules.
207
+
Run the following command on the **functions/** folder (Using Node v10.0.0):
208
208
209
-
### Setting up the React frontend
209
+
```
210
+
npm run setup-firebase
211
+
```
210
212
211
-
Run the following commands in the root of the repository (Using Node v12.15.0 or higher ):
213
+
You'll get prompted to enter the path to you service account key file. To generate it, go to your **_Firebase Dashboard_**, **_Project settings_** tab and then to **_Service accounts_** option, right there you can generate your private key (more info on this [here](https://firebase.google.com/docs/admin/setup#initialize-sdk)).
212
214
213
-
-`npm run setup-admin-dashboard`
215
+
You'll need to enter the **_email_** and **_password_** for the admin account of the admin dashboard. With this in place, you've successfully created your admin account for the dashboard.
214
216
215
-
If you go to your dashboard you'll see all the Firebase services are now deployed, go to the **_Functons_** section and copy the Cloud Functions URL and paste it into the `REACT_APP_CLOUD_FUNCTIONS_REST_API` environment variable in your `.env` file.
217
+
### Setting up the React frontend
216
218
217
-
It should look like this:
219
+
Run the following commands in the root of the repository (Using Node v12.15.0 or higher):
218
220
219
-
`REACT_APP_CLOUD_FUNCTIONS_REST_API = '<CLOUD FUNCTION URL>/requestsApp'`
221
+
```
222
+
npm run setup-admin-dashboard
223
+
```
220
224
221
-
At this point we have a fully functional admin dashboard. You can start a local development server with the command `npm run start`, and for the deployed project you can go to the Firebase Dashboard within the **_Hosting_** tab find out the url of the hosted project.
225
+
If you go to your dashboardyou'll see all the Firebase services are now deployed.
222
226
223
227
## React frontend
224
228
@@ -304,34 +308,31 @@ Launches the test runner in the interactive watch mode.
304
308
305
309
### How to deploy
306
310
307
-
`npm run deploy`
311
+
```
312
+
npm run deploy
313
+
```
308
314
309
315
## Cloud functions
310
316
311
317
### Folder structure
312
318
313
319
```
314
320
functions/
315
-
├── auth/
316
-
│ ├── onCreate.function.js
317
-
| └── onDelete.function.js
318
-
├── db/
319
-
│ ├── users/
320
-
│ │ ├── onCreate.function.js
321
-
│ │ └── onModify.function.js
322
-
│ └── ... other database functions ...
323
-
├── storage/
324
-
│ ... storage functions ...
325
-
├── requests/
326
-
│ ├── middlewares/
327
-
│ │ └── auth.js
328
-
│ ├── routes/
329
-
│ │ ├── users.js
330
-
│ │ └── establishments.js
331
-
| └── app.function.js
332
-
├── index.js
333
-
├── production-key.json
334
-
└── staging-key.json
321
+
├── src/
322
+
│ ├── auth/
323
+
│ │ ├── onCreate.function.ts
324
+
| │ └── onDelete.function.ts
325
+
│ ├── db/
326
+
│ │ ├── users/
327
+
│ │ ├── onCreate.function.ts
328
+
│ │ ├── onModify.function.ts
329
+
│ │ └── ... other database functions ...
330
+
│ ├── storage/
331
+
│ │ ... storage functions ...
332
+
│ ├── https/
333
+
│ │ ├── createUser.function.ts
334
+
│ │ └── ... other https functions ...
335
+
│ └── index.ts
335
336
```
336
337
337
338
### Installing dependencies
@@ -578,9 +579,9 @@ const date = Date.now();
578
579
579
580
For file upload, we used the [Firebase Client](https://firebase.google.com/docs/storage/web/upload-files?authuser=1#upload_files) together with **Firebase Storage** for our storage needs. We store the users profile image in a subfolder named `/users`.
580
581
581
-
### Image Resize
582
+
### Image resize extension
582
583
583
-
We use [Resize Image](https://github.com/firebase/extensions/tree/master/storage-resize-images) for resizing every image uploaded to the storage.
584
+
We use [Resize Image extension](https://github.com/firebase/extensions/tree/master/storage-resize-images) for resizing every image uploaded to the storage.
584
585
Every image uploaded to the storage is resized to our size preference (`200pxx200px`).
585
586
586
587
**Setting your image resize**
@@ -591,7 +592,9 @@ If you want to install it from the cmd, you can execute:
0 commit comments