Skip to content
Serverless CRUD service using FaunaDB
Branch: master
Clone or download
Pull request Compare This branch is 6 commits ahead of pmuens:master.
Latest commit 9c2d19a Mar 30, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore ignore .serverless Oct 13, 2016
README.md link to python version Mar 29, 2017
handler.js add cors Oct 13, 2016
package.json use FaunaDB for REST storage Jan 28, 2017
schema.js
serverless.yml use FaunaDB for REST storage Jan 28, 2017
todos-create.js use FaunaDB for REST storage Jan 28, 2017
todos-delete.js use FaunaDB for REST storage Jan 28, 2017
todos-read-all.js
todos-read-one.js use FaunaDB for REST storage Jan 28, 2017
todos-update.js use FaunaDB for REST storage Jan 28, 2017

README.md

Serverless CRUD

Serverless service which provides a basic CRUD scaffold. This is written in JavaScript. Here is a version written in Python.

Installation

Make sure that you use Serverless v1. You can install it with npm install -g serverless. It will look for AWS keys in the normal environment variables.

  1. Run serverless install --url https://github.com/faunadb/serverless-crud to install the service in your current working directory
  2. Next up cd into the service with cd serverless-crud
  3. Run npm install
  4. Create a database via https://fauna.com/serverless-cloud-sign-up
  5. Get a server access key secret for your database and paste it into package.json and serverless.yml in place of MY_FAUNADB_SERVER_SECRET
  6. Run npm run setup-schema to set up the database.
  7. Deploy with serverless deploy

How to use

Simply perform requests against the exposed endpoints:

Create

curl -X POST https://XXXX.execute-api.region.amazonaws.com/dev/todos --data '{ "body" : "Learn Serverless" }'

Read all

curl https://XXXX.execute-api.region.amazonaws.com/dev/todos

Read one

curl https://XXXX.execute-api.region.amazonaws.com/dev/todos/<id>

Update

curl -X PUT https://XXXX.execute-api.region.amazonaws.com/dev/todos/<id> --data '{ "body" : "Understand Serverless" }'

DELETE

curl -X DELETE https://XXXX.execute-api.region.amazonaws.com/dev/todos/<id>

Browse your data in FaunaDB

Login to https://dashboard.fauna.com to see your database. Browse the records you've created using the all_todos index.

AWS services used

  • Lambda
  • API Gateway
You can’t perform that action at this time.