knowledge
- Javascript
requeriments
- Nodejs installed
- Google account
- Postman installed
- firebase tools:
npm install -g firebase-tools
firebase setup
- create firebase project
- create firestore database (test mode)
project setup
mkdir firebase-crud-project firebase init select functions
select exisiting project javascript linting yes install dependencies
write hello world
npm run serve
in localhost: [<------domain---->]/[<-app id--->]/[<-zone-->]/app/[<-endpoint->] http://localhost:5000/fir-api-9a206/us-central1/app/create
in production: [<---zone + app id + cloudfunctions.net----->]/app/[<--endpoint-->] https://us-central1-fir-api-9a206.cloudfunctions.net/app/hello-world
firestore
to create CRUD with firestore. we need to use admin and access via service account. go to service accounts and generate a new "private key"
put this in index.js
const serviceAccount = require('./permissions.json') admin.initializeApp({ credential: admin.credential.cert(serviceAccount), databaseURL: "https://restapi-js.firebaseio.com" })
fix diferent version
nvm install 10 nvm use 10
Recomendations
- know more about express
- serverless
deploying
change to blaze plan (free kinda) firebase deploy