Skip to content

An example that demonstrates building REST services with firestore in native mode and hapi

Notifications You must be signed in to change notification settings

medial-io/firestore-native-hapi-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Building REST services with firestore in native mode and Hapi

The example assumes you have the google cloud cli interface installed and configured.

Firebase emulator is used enable local development. You'll need Docker to start the emulator

Install

npm ci

Build your docker image

docker build . -t firestore:1.11.4

Run

Run the firestore emulator docker image

docker run -ti --rm -p 8080:8080 -d --name firestore firestore:1.11.4

Start the hapi server:

export FIRESTORE_LOCAL=true; npm start

You'll see a output that looks like this:

> node index.js

Server running on http://localhost:9080
Documentation at: http://localhost:9080/documentation

Explore

Use the swagger docs endpoint (http://localhost:9080/documentation) to explore the example

POST /examples

POST json payload

{
  "hello": "world"
}

Inserts the document into the database with uuid id

GET /examples

Returns an array of all the examples inserted thus far

Deploy to Google Cloud

Please make sure your google project is configured to use Firestore in native mode.

gcloud app deploy

Considerations

Please read this comparison of Firestore in native mode vs datastore mode

About

An example that demonstrates building REST services with firestore in native mode and hapi

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published