nonono-pwa-firebase
v0.1.79
Published
## Get Up and Running
Downloads
1
Readme
xinjs app boilerplate
Get Up and Running
You will need nodejs and bun. Exactly version should not be important, but if you run into problems maybe upgrade?
You'll also need to install the firebase admin (globally).
- Create a folder (e.g.
nonono
) - Create your secrets file and put it in a subfolder as
secrets/firebase-secrets.json
- Firebase Console
- Project Overview (gear, top-leftish)
- Service Accounts (tab)
- Generate New Private Key (button at bottom)
- Find that file, rename it "firebase-secrets" and stick it in
/secrets
- You'll need to run
firebase login
(and possibly preceded byfirebase logout
) see this question on Stack Overflow
- Clone the repo into the
nonono
folder (name doesn't matter, butnonono-pwa-firebase
is the default) So, now you have anonono
directory with two subfolders,secrets
andnonono-pwa-firebase
(or whatever) And thesecrets
folder contains a json file namedfirebase-secrets.json
and the other folder is a clone of the project repo which, notably, contains a./functions
subfolder. OK? - inside the the project folder (
nonono-pwa-firebase
or whatever)npm install
- (inside
./functions
)npm install
// this is a separate project with its own dependencies bun install
// bun stores its own highly optimized binary dependency tree- in one terminal
npm run emulators
// ctrl-c then reset emulators to stop them later - in a second terminal
npm run dev
// ctrl-c to kill this later
You may also need to run this command:
firebase functions:secrets:access --project <PROJECT_ID> <NAME_OF_SCECRET>
E.g.
firebase functions:secrets:access --project 171481538073 stripe-nonono-test
After doing this, be sure to restart your emulators.
Troubleshooting
- If you can't do step 2, don't panic, you probably need to be added to the project by a project admin.
- If you can't install
bun
, what can I say? stop using Windows or use the Linux subsystem or something.- If you have another problem then complain to someone and make sure it gets fixed and documented :D
The site should load on http://localhost:1234
By default, the app will use emulated services on
localhost
unless you add #prod to the url and reload (in which case it will use production). You can skip step 5 if you want to use prod
FireBase Emulators
To emulate services locally, in a separate terminal:
- npm run reset-emulators (if you've been runing them earlier)
- npm run emulators
If you're running locally and try to log in using a phone number, the confirmation code will be displayed in the terminal running the emulators.
Installing / Upgrading firebase-tools
Apparently the npm package is deprecated so to sort issues with zany bugs in
firebase-tools
you need to do this.
If necessary:
npm uninstall -g firebase-tools
Then:
curl -sL https://firebase.tools | bash
firebase-config.ts
../secrets/...admin
- Firebase > Project Settings > Sevice accounts
- Generate new private key
- Move resulting file to ../secrets directory outside the project root
Note that the project id in the deploy command must match that in the credentials JSON
You will need to go to the App Engine console to create an App Engine instance if you haven't already.
firebase emulator firestore.rules bug
It looks like the way to really fix this is:
- completely uninstall firebase-tools, e.g.
sudo npm uninstall -g firebase-tools
orcurl -sL firebase.tools | uninstall=true bash
- reinstall it
rm -rf ~/.cache/firebase
(this forces new emulator binaries to be downloaded)
Also note, this may entail upgrading Java.
Useful Document Links
TODO
- cloud function example
- non-trivial service example
- utility functions for saving and recovering binaries in storage
- type-checking