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

Added firebase example #153

Merged
merged 35 commits into from
Jul 30, 2023
Merged

Conversation

Saim-Khan1
Copy link
Contributor

Description

Added a quick Firebase example, based on #150, which initialises the firebase admin, downloads images stored in Firebase Cloud Storage to add to the pass (and deletes these once complete) and serves the pass directly as the response.

Check relevant checkboxes

  • I've run tests (through npm test) and they passed
  • I generated a working Apple Wallet Pass after the change
  • Provided examples keep working after the change
  • This improvement is or might be a breaking change

Copy link
Owner

@alexandercerutti alexandercerutti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your contribution. This is wonderful, also I have several doubts although I'd rather have it in Typescript (but I guess I could convert it later).

What I noticed missing is a README.md file that explains how to use this example. If you want to write it, I can do it, but I need first to understand how everything in here works.

What I care about the most is that we are able to run it successfully both locally and on a cloud function, so it's code must be suitable for both envs.

examples/firebase/package.json Outdated Show resolved Hide resolved
examples/firebase/package.json Outdated Show resolved Hide resolved
examples/firebase/index.js Outdated Show resolved Hide resolved
examples/firebase/index.js Outdated Show resolved Hide resolved
examples/firebase/index.js Outdated Show resolved Hide resolved
examples/firebase/index.js Outdated Show resolved Hide resolved
examples/firebase/index.js Outdated Show resolved Hide resolved
examples/firebase/index.js Outdated Show resolved Hide resolved
@Saim-Khan1
Copy link
Contributor Author

Thank you very much for your contribution. This is wonderful, also I have several doubts although I'd rather have it in Typescript (but I guess I could convert it later).

What I noticed missing is a README.md file that explains how to use this example. If you want to write it, I can do it, but I need first to understand how everything in here works.

What I care about the most is that we are able to run it successfully both locally and on a cloud function, so it's code must be suitable for both envs.

Sure, makes sense. Yes if you wouldn't mind writing a README for it that would be amazing, I'll try my best to explain everything. As I mentioned earlier, I am an iOS developer primarily and not too familiar with the backend side of things, so I more than likely haven't done certain things properly, and would love some help navigating some of these things so I can learn from it myself as well :)

@alexandercerutti
Copy link
Owner

Yeah, no problem at all! Help me however you can ;)

@alexandercerutti
Copy link
Owner

I've partially reviewed the code you made right now:

  1. Please note that if the model name, available at request.body.passType (which should be one of the models in the models folder, hence exampleBooking or examplePass), is checked against "boardingPass", it is never going to work. (not yet fixed).

  2. It is better to have the certificates paths referencing the root folder, where certificates folder should be (as per the other examples)

  3. A firebase.json is missing: I cannot run the function. I'm going to add one.

  4. You didn't have prettier installed, so I had to change all the code indentation.

Since I've pushed on your branch, be sure to pull first if you want to make more changes

@alexandercerutti
Copy link
Owner

Okay so, I was able to set up everything, deploy the function, and give the permission to be publicly accessed on the web (for future ref: https://cloud.google.com/functions/docs/securing/managing-access-iam?hl=it#console, with role allUsers to be inserted)

What I'm stuck on right now (I have to check better) is that the model as-is cannot be found on that path, because the model does not get uploaded.

Maybe we can copy the model folder on predeploy script so it gets deployed too (but then, we'd have a path mismatch between the emulator and deploying) or, otherwise, set it up on the bucket. WDYT @Saim-Khan1?

@alexandercerutti
Copy link
Owner

Okay, I was able to overcome this block.
I think that the example is now ready! I'm going to merge it. If you have any doubts or questions, do not hesitate to ask them in a new discussion!

Thank you very much for your contribution @Saim-Khan1!

@alexandercerutti alexandercerutti merged commit 3b8fc5d into alexandercerutti:master Jul 30, 2023
1 check passed
@Saim-Khan1
Copy link
Contributor Author

Hi @alexandercerutti, I was taking a little break, really sorry I missed all of this! Just having a quick read-through, looks like you managed to work through everything which is great, again really sorry I couldn't be of more help 😅
Great point about storing the models in cloud storage and the pricing tradeoff and things, I hadn't thought of that myself. I am yet to go through and have a look at how you went about doing things but I'm sure this will all be super useful in improving the backend for my app as well, so thank you so much again for all your help! I'll have a look through and let you know if I have any questions :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants