Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update node-rest-api-with-serverless-lambda-and-dynamodb.md #495

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ This will create a directory `candidate-service` with the following structure.

```bash
.
├── .npmignore
├── .gitignore
├── handler.js
└── serverless.yml
```
Expand Down Expand Up @@ -116,7 +116,7 @@ Let's go over the YAML configuration:
3. Next, we defined configuration of the cloud provider. As we are using AWS so we defined AWS corresponding configuration.
4. Finally, we defined `candidateSubmission` function. In the configuration shown above, we declared that when the HTTP POST request is made to `/candidates` then `api/candidate.submit` handler should be invoked. We also specified memory we want to allocate to the function.

Now, create a new directory `api` inside the `candidate-service` directory. Move the `handler.js` to the `api` directory. Rename `handler.js` to `candidate.js` and rename `handle` to `submit`.
Now, create a new directory `api` inside the `candidate-service` directory. Move the `handler.js` to the `api` directory. Rename `handler.js` to `candidate.js` and rename `hello` to `submit`.

```javascript
'use strict';
Expand All @@ -142,16 +142,19 @@ $ sls deploy
```

```bash
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
.....
Serverless: Stack create finished...
Serverless: Packaging service...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading service .zip file to S3 (524 B)...
Serverless: Uploading artifacts...
Serverless: Uploading service .zip file to S3 (422 B)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
....................................
...............................
Serverless: Stack update finished...
Service Information
service: candidate
Expand All @@ -162,7 +165,7 @@ api keys:
endpoints:
POST - https://05ccffiraa.execute-api.us-east-1.amazonaws.com/dev/candidates
functions:
candidate-dev-candidateSubmission
candidateSubmission: candidate-dev-candidateSubmission
```

Now, POST operation of your service is available. You can use tools like cURL to make a POST request.
Expand Down