Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
/ node-firebase-api Public archive

Good starting point for building RESTful API as Firebase Functions. Has CRUD endpoints that write to Firestore backend.

Notifications You must be signed in to change notification settings

34fame/node-firebase-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node Firebase API

Install

  1. Clone this repository

  2. Run npm or yarn

  3. Create a service account JSON file from the Firebase console. By default save it as /functions/service-account.json.

  4. You need to have firebase-tools installed npm i -g [email protected] (8.4.2 has problems)

  5. Run firebase init and select Functions and Emulators. Install the Function emulator.

Getting Started

  1. Launch locally using firebase serve

  2. Deploy using firebase deploy

Endpoints

A "collection" is any object collection (e.g. Users, Projects, etc.). The term collection is taken from Firestore terminology.

Get all items in a collection

GET /:collection

Get a collection item by ID

GET /:collection/:collectionId

Create a collection item

By default, there is no schema defined or required. The object can contain any valid JSON.

POST /:collection
Content-Type: application/json

{
   "name": "Something"
}

Update a collection item

PUT /:collection/:collectionId
Content-Type: application/json

{
   "archive": true
}

Delete a collection item

DELETE /:collection/:collectionId

Examples

Request

GET {{baseUrl}}/projects
Accept: application/json
Cache-Control: no-cache

Response

[
  {
    "id": "lpstt3v",
    "category": "34 Fame",
    "name": "Documentation Site",
    "icon": "fas fa-book",
    "status": "On-Hold"
  }
]

Request

POST {{baseUrl}}/projects
Accept: application/json
Content-Type: application/json
Cache-Control: no-cache

{
   "category": "34 Fame",
   "name": "Documentation Site",
   "icon": "fas fa-book",
   "status": "On-Hold"
}

Response

{
  "id": "lpstt3v",
  "category": "34 Fame",
  "name": "Documentation Site",
  "icon": "fas fa-book",
  "status": "On-Hold"
}

Request

PUT {{baseUrl}}/projects/lpstt3v
Accept: application/json
Content-Type: application/json
Cache-Control: no-cache

{
   "status": "Open"
}

Response

{
  "id": "lpstt3v",
  "category": "34 Fame",
  "name": "Documentation Site",
  "icon": "fas fa-book",
  "status": "Open"
}

DELETE {{baseUrl}}/projects/lpstt3v
Accept: */*
Cache-Control: no-cache

About

Good starting point for building RESTful API as Firebase Functions. Has CRUD endpoints that write to Firestore backend.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published