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.
- Run
serverless install --url https://github.com/faunadb/serverless-crud
to install the service in your current working directory - Next up cd into the service with
cd serverless-crud
- Run
npm install
- Create a database via https://fauna.com/serverless-cloud-sign-up
- Get a server access key secret for your database and paste it into
package.json
andserverless.yml
in place ofMY_FAUNADB_SERVER_SECRET
- Run
npm run setup-schema
to set up the database. - 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