{"id":20911192,"url":"https://github.com/codeforgeek/aws-lambda-todo-rest-api","last_synced_at":"2025-05-13T07:32:07.564Z","repository":{"id":81956416,"uuid":"103843896","full_name":"codeforgeek/aws-lambda-todo-rest-api","owner":"codeforgeek","description":null,"archived":false,"fork":false,"pushed_at":"2017-09-17T16:30:14.000Z","size":4,"stargazers_count":2,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T19:59:59.234Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeforgeek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-17T16:29:51.000Z","updated_at":"2020-08-26T22:20:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"ecce5ab2-8f46-4b2e-b596-9270954ef8ee","html_url":"https://github.com/codeforgeek/aws-lambda-todo-rest-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeforgeek%2Faws-lambda-todo-rest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeforgeek%2Faws-lambda-todo-rest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeforgeek%2Faws-lambda-todo-rest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeforgeek%2Faws-lambda-todo-rest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeforgeek","download_url":"https://codeload.github.com/codeforgeek/aws-lambda-todo-rest-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253894872,"owners_count":21980414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T14:19:42.211Z","updated_at":"2025-05-13T07:32:07.559Z","avatar_url":"https://github.com/codeforgeek.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\ntitle: AWS Serverless REST API example in NodeJS\ndescription: This example demonstrates how to setup a RESTful Web Service allowing you to create, list, get, update and delete Todos. DynamoDB is used to store the data. \nlayout: Doc\n--\u003e\n# Serverless REST API\n\nThis example demonstrates how to setup a [RESTful Web Services](https://en.wikipedia.org/wiki/Representational_state_transfer#Applied_to_web_services) allowing you to create, list, get, update and delete Todos. DynamoDB is used to store the data. This is just an example and of course you could use any data storage as a backend.\n\n## Structure\n\nThis service has a separate directory for all the todo operations. For each operation exactly one file exists e.g. `todos/delete.js`. In each of these files there is exactly one function which is directly attached to `module.exports`.\n\nThe idea behind the `todos` directory is that in case you want to create a service containing multiple resources e.g. users, notes, comments you could do so in the same service. While this is certainly possible you might consider creating a separate service for each resource. It depends on the use-case and your preference.\n\n## Use-cases\n\n- API for a Web Application\n- API for a Mobile Application\n\n## Setup\n\n```bash\nnpm install\n```\n\n## Deploy\n\nIn order to deploy the endpoint simply run\n\n```bash\nserverless deploy\n```\n\nThe expected result should be similar to:\n\n```bash\nServerless: Packaging service…\nServerless: Uploading CloudFormation file to S3…\nServerless: Uploading service .zip file to S3…\nServerless: Updating Stack…\nServerless: Checking Stack update progress…\nServerless: Stack update finished…\n\nService Information\nservice: serverless-rest-api-with-dynamodb\nstage: dev\nregion: us-east-1\napi keys:\n  None\nendpoints:\n  POST - https://45wf34z5yf.execute-api.us-east-1.amazonaws.com/dev/todos\n  GET - https://45wf34z5yf.execute-api.us-east-1.amazonaws.com/dev/todos\n  GET - https://45wf34z5yf.execute-api.us-east-1.amazonaws.com/dev/todos/{id}\n  PUT - https://45wf34z5yf.execute-api.us-east-1.amazonaws.com/dev/todos/{id}\n  DELETE - https://45wf34z5yf.execute-api.us-east-1.amazonaws.com/dev/todos/{id}\nfunctions:\n  serverless-rest-api-with-dynamodb-dev-update: arn:aws:lambda:us-east-1:488110005556:function:serverless-rest-api-with-dynamodb-dev-update\n  serverless-rest-api-with-dynamodb-dev-get: arn:aws:lambda:us-east-1:488110005556:function:serverless-rest-api-with-dynamodb-dev-get\n  serverless-rest-api-with-dynamodb-dev-list: arn:aws:lambda:us-east-1:488110005556:function:serverless-rest-api-with-dynamodb-dev-list\n  serverless-rest-api-with-dynamodb-dev-create: arn:aws:lambda:us-east-1:488110005556:function:serverless-rest-api-with-dynamodb-dev-create\n  serverless-rest-api-with-dynamodb-dev-delete: arn:aws:lambda:us-east-1:488110005556:function:serverless-rest-api-with-dynamodb-dev-delete\n```\n\n## Usage\n\nYou can create, retrieve, update, or delete todos with the following commands:\n\n### Create a Todo\n\n```bash\ncurl -X POST https://XXXXXXX.execute-api.us-east-1.amazonaws.com/dev/todos --data '{ \"text\": \"Learn Serverless\" }'\n```\n\nExample Result:\n```bash\n{\"text\":\"Learn Serverless\",\"id\":\"ee6490d0-aa81-11e6-9ede-afdfa051af86\",\"createdAt\":1479138570824,\"checked\":false,\"updatedAt\":1479138570824}%\n```\n\n### List all Todos\n\n```bash\ncurl https://XXXXXXX.execute-api.us-east-1.amazonaws.com/dev/todos\n```\n\nExample output:\n```bash\n[{\"text\":\"Deploy my first service\",\"id\":\"ac90fe80-aa83-11e6-9ede-afdfa051af86\",\"checked\":true,\"updatedAt\":1479139961304},{\"text\":\"Learn Serverless\",\"id\":\"20679390-aa85-11e6-9ede-afdfa051af86\",\"createdAt\":1479139943241,\"checked\":false,\"updatedAt\":1479139943241}]%\n```\n\n### Get one Todo\n\n```bash\n# Replace the \u003cid\u003e part with a real id from your todos table\ncurl https://XXXXXXX.execute-api.us-east-1.amazonaws.com/dev/todos/\u003cid\u003e\n```\n\nExample Result:\n```bash\n{\"text\":\"Learn Serverless\",\"id\":\"ee6490d0-aa81-11e6-9ede-afdfa051af86\",\"createdAt\":1479138570824,\"checked\":false,\"updatedAt\":1479138570824}%\n```\n\n### Update a Todo\n\n```bash\n# Replace the \u003cid\u003e part with a real id from your todos table\ncurl -X PUT https://XXXXXXX.execute-api.us-east-1.amazonaws.com/dev/todos/\u003cid\u003e --data '{ \"text\": \"Learn Serverless\", \"checked\": true }'\n```\n\nExample Result:\n```bash\n{\"text\":\"Learn Serverless\",\"id\":\"ee6490d0-aa81-11e6-9ede-afdfa051af86\",\"createdAt\":1479138570824,\"checked\":true,\"updatedAt\":1479138570824}%\n```\n\n### Delete a Todo\n\n```bash\n# Replace the \u003cid\u003e part with a real id from your todos table\ncurl -X DELETE https://XXXXXXX.execute-api.us-east-1.amazonaws.com/dev/todos/\u003cid\u003e\n```\n\nNo output\n\n## Scaling\n\n### AWS Lambda\n\nBy default, AWS Lambda limits the total concurrent executions across all functions within a given region to 100. The default limit is a safety limit that protects you from costs due to potential runaway or recursive functions during initial development and testing. To increase this limit above the default, follow the steps in [To request a limit increase for concurrent executions](http://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html#increase-concurrent-executions-limit).\n\n### DynamoDB\n\nWhen you create a table, you specify how much provisioned throughput capacity you want to reserve for reads and writes. DynamoDB will reserve the necessary resources to meet your throughput needs while ensuring consistent, low-latency performance. You can change the provisioned throughput and increasing or decreasing capacity as needed.\n\nThis is can be done via settings in the `serverless.yml`.\n\n```yaml\n  ProvisionedThroughput:\n    ReadCapacityUnits: 1\n    WriteCapacityUnits: 1\n```\n\nIn case you expect a lot of traffic fluctuation we recommend to checkout this guide on how to auto scale DynamoDB [https://aws.amazon.com/blogs/aws/auto-scale-dynamodb-with-dynamic-dynamodb/](https://aws.amazon.com/blogs/aws/auto-scale-dynamodb-with-dynamic-dynamodb/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeforgeek%2Faws-lambda-todo-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeforgeek%2Faws-lambda-todo-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeforgeek%2Faws-lambda-todo-rest-api/lists"}