You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aws-node-express-api/README.md
+8-17Lines changed: 8 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,27 +16,19 @@ This template demonstrates how to develop and deploy a simple Node Express API s
16
16
17
17
## Anatomy of the template
18
18
19
-
This template configures a single function, `api`, which is responsible for handling all incoming requests thanks to configured `http` events. To learn more about `http` event configuration options, please refer to [http event docs](https://www.serverless.com/framework/docs/providers/aws/events/apigateway/). As the events are configured in a way to accept all incoming requests, `express` framework is responsible for routing and handling requests internally. Implementation takes advantage of `serverless-http` package, which allows you to wrap existing `express` applications. To learn more about `serverless-http`, please refer to corresponding [GitHub repository](https://github.com/dougmoscrop/serverless-http).
19
+
This template configures a single function, `api`, which is responsible for handling all incoming requests thanks to the `httpApi` event. To learn more about `httpApi` event configuration options, please refer to [httpApi event docs](https://www.serverless.com/framework/docs/providers/aws/events/http-api/). As the event is configured in a way to accept all incoming requests, `express` framework is responsible for routing and handling requests internally. Implementation takes advantage of `serverless-http` package, which allows you to wrap existing `express` applications. To learn more about `serverless-http`, please refer to corresponding [GitHub repository](https://github.com/dougmoscrop/serverless-http).
20
20
21
21
## Usage
22
22
23
23
### Deployment
24
24
25
-
This example is made to work with the Serverless Framework dashboard, which includes advanced features such as CI/CD, monitoring, metrics, etc.
26
-
27
-
In order to deploy with dashboard, you need to first login with:
28
-
29
-
```
30
-
serverless login
31
-
```
32
-
33
-
install dependencies with:
25
+
Install dependencies with:
34
26
35
27
```
36
28
npm install
37
29
```
38
30
39
-
and then perform deployment with:
31
+
and then deploy with:
40
32
41
33
```
42
34
serverless deploy
@@ -68,22 +60,21 @@ resources: 12
68
60
api keys:
69
61
None
70
62
endpoints:
71
-
ANY - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev/
72
-
ANY - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev/{proxy+}
63
+
ANY - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/
73
64
functions:
74
65
api: aws-node-express-api-dev-api
75
66
layers:
76
67
None
77
68
```
78
69
79
-
_Note_: In current form, after deployment, your API is public and can be invoked by anyone. For production deployments, you might want to configure an authorizer. For details on how to do that, refer to [http event docs](https://www.serverless.com/framework/docs/providers/aws/events/apigateway/).
70
+
_Note_: In current form, after deployment, your API is public and can be invoked by anyone. For production deployments, you might want to configure an authorizer. For details on how to do that, refer to [`httpApi` event docs](https://www.serverless.com/framework/docs/providers/aws/events/http-api/).
80
71
81
72
### Invocation
82
73
83
74
After successful deployment, you can call the created application via HTTP:
Copy file name to clipboardExpand all lines: aws-node-express-dynamodb-api/README.md
+8-17Lines changed: 8 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,27 +17,19 @@ This template demonstrates how to develop and deploy a simple Node Express API s
17
17
18
18
## Anatomy of the template
19
19
20
-
This template configures a single function, `api`, in `serverless.yml`which is responsible for handling all incoming requests thanks to configured `http` events. To learn more about `http` event configuration options, please refer to [http event docs](https://www.serverless.com/framework/docs/providers/aws/events/apigateway/). As the events are configured in a way to accept all incoming requests, `express` framework is responsible for routing and handling requests internally. Implementation takes advantage of `serverless-http` package, which allows you to wrap existing `express` applications. To learn more about `serverless-http`, please refer to corresponding [GitHub repository](https://github.com/dougmoscrop/serverless-http). Additionally, it also handles provisioning of a DynamoDB database that is used for storing data about users. The `express` application exposes two endpoints, `POST /users` and `GET /user/{userId}`, which allow to create and retrieve users.
20
+
This template configures a single function, `api`, which is responsible for handling all incoming requests thanks to the `httpApi` event. To learn more about `httpApi` event configuration options, please refer to [httpApi event docs](https://www.serverless.com/framework/docs/providers/aws/events/http-api/). As the event is configured in a way to accept all incoming requests, `express` framework is responsible for routing and handling requests internally. Implementation takes advantage of `serverless-http` package, which allows you to wrap existing `express` applications. To learn more about `serverless-http`, please refer to corresponding [GitHub repository](https://github.com/dougmoscrop/serverless-http). Additionally, it also handles provisioning of a DynamoDB database that is used for storing data about users. The `express` application exposes two endpoints, `POST /users` and `GET /user/{userId}`, which allow to create and retrieve users.
21
21
22
22
## Usage
23
23
24
24
### Deployment
25
25
26
-
This example is made to work with the Serverless Framework dashboard, which includes advanced features such as CI/CD, monitoring, metrics, etc.
27
-
28
-
In order to deploy with dashboard, you need to first login with:
29
-
30
-
```
31
-
serverless login
32
-
```
33
-
34
-
install dependencies with:
26
+
Install dependencies with:
35
27
36
28
```
37
29
npm install
38
30
```
39
31
40
-
and then perform deployment with:
32
+
and then deploy with:
41
33
42
34
```
43
35
serverless deploy
@@ -69,22 +61,21 @@ resources: 13
69
61
api keys:
70
62
None
71
63
endpoints:
72
-
ANY - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev/
73
-
ANY - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev/{proxy+}
64
+
ANY - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/
74
65
functions:
75
66
api: aws-node-express-dynamodb-api-dev-api
76
67
layers:
77
68
None
78
69
```
79
70
80
-
_Note_: In current form, after deployment, your API is public and can be invoked by anyone. For production deployments, you might want to configure an authorizer. For details on how to do that, refer to [http event docs](https://www.serverless.com/framework/docs/providers/aws/events/apigateway/). Additionally, in current configuration, DynamoDB Table will be removed when running `serverless remove`. To retain DynamoDB Table even after removal of the stack, add `DeletionPolicy: Retain` to its resource definition.
71
+
_Note_: In current form, after deployment, your API is public and can be invoked by anyone. For production deployments, you might want to configure an authorizer. For details on how to do that, refer to [`httpApi` event docs](https://www.serverless.com/framework/docs/providers/aws/events/http-api/). Additionally, in current configuration, the DynamoDB table will be removed when running `serverless remove`. To retain the DynamoDB table even after removal of the stack, add `DeletionPolicy: Retain` to its resource definition.
81
72
82
73
### Invocation
83
74
84
75
After successful deployment, you can create a new user by calling the corresponding endpoint:
@@ -113,7 +104,7 @@ If you try to retrieve user that does not exist, you should receive the followin
113
104
114
105
### Local development
115
106
116
-
It is also possible to emulate DynamodB, API Gateway and Lambda locally by using `serverless-dynamodb-local` and `serverless-offline` plugins. In order to do that, execute the following commands:
107
+
It is also possible to emulate DynamoDB, API Gateway and Lambda locally using the `serverless-dynamodb-local` and `serverless-offline` plugins. In order to do that, run:
title: 'AWS Serverless HTTP API with DynamoDB and offline support example in NodeJS'
3
+
description: 'This example demonstrates how to run a service locally, using the ''serverless-offline'' plugin. It provides an HTTP API to manage Todos stored in DynamoDB.'
[{"text":"Deploy my first service","id":"ac90feaa11e6-9ede-afdfa051af86","checked":true,"updatedAt":1479139961304},{"text":"Learn Serverless","id":"206793aa11e6-9ede-afdfa051af86","createdAt":1479139943241,"checked":false,"updatedAt":1479139943241}]%
65
+
```
66
+
67
+
### Get one Todo
68
+
69
+
```bash
70
+
# Replace the <id> part with a real id from your todos table
0 commit comments