Skip to content

Commit f541d4c

Browse files
authored
Merge pull request #41 from Moesif/update-readme
Update Readme.
2 parents dbb9fe4 + 09d9994 commit f541d4c

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

README.md

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ by [Moesif](https://moesif.com), the [API analytics](https://www.moesif.com/feat
77
[![Software License][ico-license]][link-license]
88
[![Source Code][ico-source]][link-source]
99

10-
With Moesif Node.js middleware for AWS Lambda, you can automatically log API calls
10+
With Moesif Node.js middleware for AWS Lambda, you can automatically log API calls
1111
and send them to [Moesif](https://www.moesif.com) for API analytics and monitoring.
12-
This middleware allows you to integrate Moesif's API analytics and
12+
This middleware allows you to integrate Moesif's API analytics and
1313
API monetization features into your Node.js applications with minimal configuration.
1414

1515
> If you're new to Moesif, see [our Getting Started](https://www.moesif.com/docs/) resources to quickly get up and running.
1616
1717
## Who This Middleware is For
1818

19-
We've designed Moesif Node.js middleware for AWS Lambda for APIs that you host
19+
We've designed Moesif Node.js middleware for AWS Lambda for APIs that you host
2020
on AWS Lambda using Amazon API Gateway or Application Load Balancer
21-
as a trigger. The middleware works with REST APIs, [GraphQL APIs](https://www.moesif.com/features/graphql-analytics)
21+
as a trigger. The middleware works with REST APIs, [GraphQL APIs](https://www.moesif.com/features/graphql-analytics)
2222
([such as with `apollo-server-lambda`](https://github.com/Moesif/moesif-aws-lambda-apollo-example)), and more.
2323

24-
If you're running a Node.js framework like Express.js on AWS Lambda and prefer to not have any
25-
AWS-specific dependencies, Moesif also has a <a href="https://www.moesif.com/docs/server-integration/nodejs/">Node.js middleware</a> available. The Node.js middleware supports all Node.js frameworks, including Express.js.
24+
If you're running a Node.js framework like Express.js on AWS Lambda and prefer to not have any
25+
AWS-specific dependencies, Moesif also has a <a href="https://www.moesif.com/docs/server-integration/nodejs/">Node.js middleware</a> available. The Node.js middleware supports all Node.js frameworks, including Express.js.
2626
However, the Node.js middleware doesn't capture Lambda-specific context like trade ID.
2727

2828
## Prerequisites
@@ -47,7 +47,7 @@ npm install --save moesif-aws-lambda
4747
```
4848

4949
## Configure the Middleware
50-
See the available [configuration options](#configuration-options) to learn how to configure the middleware for your use case.
50+
See the available [configuration options](#configuration-options) to learn how to configure the middleware for your use case.
5151

5252
## How to use
5353

@@ -99,7 +99,7 @@ const moesif = moesifImportWrapper.default;
9999
```
100100

101101
### 2. Enter Your Moesif Application ID
102-
The middleware expects your Moesif Application ID in [the `applicationId` key of the Moesif initialization options object](https://github.com/Moesif/moesif-aws-lambda-nodejs/blob/89c384621f8ae5fcee9166d798feb1e3115459ae/app.js#L13).
102+
The middleware expects your Moesif Application ID in [the `applicationId` key of the Moesif initialization options object](https://github.com/Moesif/moesif-aws-lambda-nodejs/blob/89c384621f8ae5fcee9166d798feb1e3115459ae/app.js#L13).
103103

104104
For instructions on how to obtain your Application ID, see [Get your Moesif Application ID](#get-your-moesif-application-id).
105105

@@ -343,10 +343,10 @@ options.getApiVersion = function (event, context) {
343343
</tr>
344344
</table>
345345

346-
A function that takes AWS lambda `event` and `context` objects as arguments and returns an object.
346+
A function that takes AWS lambda `event` and `context` objects as arguments and returns an object.
347347

348348
This function allows you
349-
to add custom metadata that Moesif can associate with the request. The metadata must be a simple JavaScript object that can be converted to JSON.
349+
to add custom metadata that Moesif can associate with the request. The metadata must be a simple JavaScript object that can be converted to JSON.
350350

351351
For example, you may want to save a virtual machine instance ID, a trace ID, or a tenant ID with the request.
352352

@@ -430,7 +430,7 @@ options.skip = function (event, context) {
430430
</table>
431431

432432
A function that takes the final Moesif event model, rather than the AWS lambda event or context objects, as an
433-
argument before the middleware sends the event model object to Moesif.
433+
argument before the middleware sends the event model object to Moesif.
434434

435435
With `maskContent`, you can make modifications to headers or body such as
436436
removing certain header or body fields.
@@ -807,7 +807,7 @@ var moesifMiddleware = moesif(options);
807807
// Campaign object is optional, but useful if you want to track ROI of acquisition channels
808808
// See https://www.moesif.com/docs/api#users for campaign schema
809809
//
810-
// Define the users.
810+
// Define the users.
811811
var user = {
812812
userId: '12345',
813813
companyId: '67890', // If set, associate user with a company object
@@ -935,6 +935,17 @@ For more information and examples, see the following:
935935
- __[Moesif, Middy, and Serverless Example](https://github.com/Moesif/moesif-middy-serverless-example)__: an example showcasing how to use this middleware with [Middy](https://middy.js.org/) and [Serverless Framework](https://serverless.com/).
936936

937937

938+
## Note about AWS Cold Start and Governance Rules
939+
940+
The `moesif-aws-lambda-nodejs` SDK fetches governance configuration from Moesif (for example, rules on which users or companies to block) and caches it in the Lambda execution environment’s memory.
941+
942+
For warm invocations (where the Lambda execution environment is already initialized), this in-memory cache works as expected.
943+
944+
On cold starts (when a new execution environment is initialized), there can be a short window before the configuration is fetched and the cache is populated. During this startup window, the SDK loads configuration asynchronously in the background, so governance decisions (like blocking) may not apply immediately.
945+
946+
In typical production APIs, regular traffic keeps functions warm, so the likelihood of requests slipping through this initial window is small.
947+
948+
In isolated tests or very low-traffic scenarios, the execution environment may be recycled and the cache cleared, recreating the short window until configuration is reloaded.
938949

939950
## How to Get Help
940951
If you face any issues using this middleware, try the [troubheshooting guidelines](#troubleshoot). For further assistance, reach out to our [support team](mailto:support@moesif.com).
@@ -952,4 +963,4 @@ Explore other integration options from Moesif:
952963

953964
[link-built-for]: https://aws.amazon.com/lambda/
954965
[link-license]: https://raw.githubusercontent.com/Moesif/moesif-aws-lambda-nodejs/master/LICENSE
955-
[link-source]: https://github.com/moesif/moesif-aws-lambda-nodejs
966+
[link-source]: https://github.com/moesif/moesif-aws-lambda-nodejs

0 commit comments

Comments
 (0)