{"id":19042484,"url":"https://github.com/serverless/event-gateway-getting-started","last_synced_at":"2025-04-23T22:28:47.954Z","repository":{"id":65982475,"uuid":"128467324","full_name":"serverless/event-gateway-getting-started","owner":"serverless","description":"Walkthrough application for using the Event Gateway. -- https://www.serverless.com","archived":false,"fork":false,"pushed_at":"2018-08-04T17:29:26.000Z","size":52,"stargazers_count":50,"open_issues_count":0,"forks_count":8,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-04-18T07:51:32.344Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serverless.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-06T20:28:47.000Z","updated_at":"2024-12-05T19:10:20.000Z","dependencies_parsed_at":"2023-02-19T18:45:17.702Z","dependency_job_id":null,"html_url":"https://github.com/serverless/event-gateway-getting-started","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/serverless%2Fevent-gateway-getting-started","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fevent-gateway-getting-started/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fevent-gateway-getting-started/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fevent-gateway-getting-started/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serverless","download_url":"https://codeload.github.com/serverless/event-gateway-getting-started/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250525769,"owners_count":21445073,"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-08T22:37:59.464Z","updated_at":"2025-04-23T22:28:47.936Z","avatar_url":"https://github.com/serverless.png","language":"JavaScript","readme":"# Event Gateway REST API\n\nThis example shows a simple way to deploy a REST API via the Event Gateway and AWS Lambda. It uses the hosted version provided by Serverless, Inc. -- [Sign up here](https://dashboard.serverless.com)!\n\nThis service will deploy three functions:\n\n- `createUser`: an HTTP endpoint for creating and storing a User in a DynamoDB table;\n- `getUser`: an HTTP endpoint for retrieving a User from DynamoDB; and\n- `emailUser`: a function that is triggered by a `user.created` event and pretends to email the user with a welcome message.\n\nThe `createUser` function allows you to create a new User by sending a JSON payload to `/users`, and the `getUser` function lets you retrieve that User by making a GET request to `/users/{id}`.\n\nIn the `createUser` function, we're using the [Event Gateway SDK](https://github.com/serverless/event-gateway-sdk) to emit a custom event of `user.created` into the Event Gateway. You can then subscribe functions to react to this custom event. The `emailUser` function is subscribed to this event as an example -- imagine a Marketing department that wants to handle emails.\n\nLet's get started!\n\n## Quick-Start\n\nFollow this [guide](https://github.com/serverless/platform/blob/master/docs/getting-started.md) to get the Serverless Framework \u0026 Event Gateway set up.\n\nClone this repository, `cd` into it and run `npm i`\n\nMake sure you have created an Application in the [Serverless Dashboard](https://dashboard.serverless.com) and filled in your `tenant` and `app` in your `serverless.yml` file.\n\n```yaml\n# serverless.yml\n\ntenant: mytenant # Insert your tenant\napp: demos # Insert your app\nservice: v1-eg-rest-api # Come up with a service name\n```\n\nDeploy your service\n\n```bash\n$ serverless deploy\n```\n\nCreate a new user by hitting the createUser endpoint:\n\n```bash\n$ APP=\"\u003cappURL\u003e\"\n$ curl -X POST -H \"Content-Type: application/json\" https://${APP}/users \\\n    --data '{\n    \t\"id\": \"10\",\n    \t\"firstName\": \"Donald\",\n    \t\"lastName\": \"Duck\",\n    \t\"email\": \"donald.duck@disney.com\"\n    }'\n\n# {\"id\":10,\"firstName\":\"Donald\",\"lastName\":\"Duck\",\"email\":\"donald.duck@disney.com\"}\n```\n\nYou can now retrieve your user by using the getUser endpoint:\n\n```bash\n$ APP=\"\u003cappURL\u003e\"\n$ curl -X GET https://${APP}/users/10\n\n# {\"id\":\"10\",\"email\":\"donald.duck@disney.com\",\"firstName\":\"Donald\",\"lastName\":\"Duck\"}\n```\n\nIn your createUser code, it emits a `user.created` event to the Event Gateway, which triggers the `emailUser` function, which then emits a `email.sent` event. You can check the logs for the Event Gateway in the [Dashboard](https://dashboard.serverless.com), just navigate to your Service and click the \"logs\" tab.\n\n## Additional Resources:\n\n- [Serverless Platform Docs](https://github.com/serverless/platform)\n- [Event Gateway plugin](https://github.com/serverless/serverless-event-gateway-plugin) for the Serverless Framework\n- [Event Gateway SDK](https://github.com/serverless/event-gateway-sdk) for interacting with the Event Gateway in your application code\n","funding_links":[],"categories":["Projects"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Fevent-gateway-getting-started","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserverless%2Fevent-gateway-getting-started","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Fevent-gateway-getting-started/lists"}