cat-a-logs 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +13 -0
- package/README.md +57 -0
- package/bin/catalogExe.js +4 -0
- package/client/App.js +1 -0
- package/client/App.tsx +0 -0
- package/client/css/input.css +3 -0
- package/client/index.js +261 -0
- package/client/index.ts +291 -0
- package/client/template.html +18 -0
- package/jest.config.mjs +26 -0
- package/lambda-nodejs22.x/README.TOOLKIT.md +38 -0
- package/lambda-nodejs22.x/README.md +127 -0
- package/lambda-nodejs22.x/events/event.json +62 -0
- package/lambda-nodejs22.x/hello-world/app.mjs +82 -0
- package/lambda-nodejs22.x/hello-world/package.json +25 -0
- package/lambda-nodejs22.x/samconfig.toml +31 -0
- package/lambda-nodejs22.x/template.yaml +41 -0
- package/package.json +69 -0
- package/postcss.config.js +7 -0
- package/server/server.ts +4 -0
- package/tailwind.config.js +12 -0
- package/tsconfig.json +113 -0
- package/webpack.config.js +79 -0
package/jest.config.mjs
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
// Changed from module.export to export default to support ES vs CommonJS
|
2
|
+
// Also renamed file from .js to .mjs
|
3
|
+
// export default {
|
4
|
+
export default {
|
5
|
+
preset: 'ts-jest/presets/default-esm',
|
6
|
+
testEnvironment: 'node',
|
7
|
+
transform: {
|
8
|
+
'^.+\\.ts?$': ['ts-jest', { isolatedModules: true }], // changed to work for ts files
|
9
|
+
},
|
10
|
+
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
|
11
|
+
collectCoverage: true,
|
12
|
+
collectCoverageFrom: ['src/**/*.{ts,js}', '!src/**/*.d.ts'],
|
13
|
+
coverageDirectory: 'coverage',
|
14
|
+
testMatch: [
|
15
|
+
'**/__tests__/**/*.[jt]s?(x)', // Matches .js, .jsx, .ts, and .tsx files in __tests__
|
16
|
+
'**/?(*.)+(spec|test).[tj]s?(x)', // Matches .spec or .test in .js, .jsx, .ts, and .tsx files
|
17
|
+
],
|
18
|
+
// Following required for compatibility with ES vs CommonJS
|
19
|
+
extensionsToTreatAsEsm: ['.ts'],
|
20
|
+
// below is commented out to get rid of deprecated waring of jest
|
21
|
+
// globals: {
|
22
|
+
// 'ts-jest': {
|
23
|
+
// useESM: true,
|
24
|
+
// },
|
25
|
+
// },
|
26
|
+
};
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Developing AWS SAM Applications with the AWS Toolkit For Visual Studio Code
|
2
|
+
|
3
|
+
This project contains source code and supporting files for a serverless application that you can locally run, debug, and deploy to AWS with the AWS Toolkit For Visual Studio Code.
|
4
|
+
|
5
|
+
A "SAM" (serverless application model) project is a project that contains a template.yaml file which is understood by AWS tooling (such as SAM CLI, and the AWS Toolkit For Visual Studio Code).
|
6
|
+
|
7
|
+
## Writing and Debugging Serverless Applications
|
8
|
+
|
9
|
+
The code for this application will differ based on the runtime, but the path to a handler can be found in the [`template.yaml`](./template.yaml) file through a resource's `CodeUri` and `Handler` fields.
|
10
|
+
|
11
|
+
AWS Toolkit For Visual Studio Code supports local debugging for serverless applications through VS Code's debugger. Since this application was created by the AWS Toolkit, launch configurations for all included handlers have been generated and can be found in the menu next to the Run button:
|
12
|
+
|
13
|
+
* lambda-nodejs22.x:HelloWorldFunction (nodejs22.x)
|
14
|
+
* API lambda-nodejs22.x:HelloWorldFunction (nodejs22.x)
|
15
|
+
|
16
|
+
You can debug the Lambda handlers locally by adding a breakpoint to the source file, then running the launch configuration. This works by using Docker on your local machine.
|
17
|
+
|
18
|
+
Invocation parameters, including payloads and request parameters, can be edited either by the `Local Invoke and Debug Configuration` command (through the Command Palette or CodeLens) or by editing the `launch.json` file.
|
19
|
+
|
20
|
+
AWS Lambda functions not defined in the [`template.yaml`](./template.yaml) file can be invoked and debugged by creating a launch configuration through the CodeLens over the function declaration, or with the `Add Local Invoke and Debug Configuration` command.
|
21
|
+
|
22
|
+
## Deploying Serverless Applications
|
23
|
+
|
24
|
+
You can deploy a serverless application by invoking the `AWS: Deploy SAM application` command through the Command Palette or by right-clicking the Lambda node in the AWS Explorer and entering the deployment region, a valid S3 bucket from the region, and the name of a CloudFormation stack to deploy to. You can monitor your deployment's progress through the `AWS Toolkit` Output Channel.
|
25
|
+
|
26
|
+
## Interacting With Deployed Serverless Applications
|
27
|
+
|
28
|
+
A successfully-deployed serverless application can be found in the AWS Explorer under region and CloudFormation node that the serverless application was deployed to.
|
29
|
+
|
30
|
+
In the AWS Explorer, you can invoke _remote_ AWS Lambda Functions by right-clicking the Lambda node and selecting "Invoke on AWS".
|
31
|
+
|
32
|
+
Similarly, if the Function declaration contained an API Gateway event, the API Gateway API can be found in the API Gateway node under the region node the serverless application was deployed to, and can be invoked via right-clicking the API node and selecting "Invoke on AWS".
|
33
|
+
|
34
|
+
## Resources
|
35
|
+
|
36
|
+
General information about this SAM project can be found in the [`README.md`](./README.md) file in this folder.
|
37
|
+
|
38
|
+
More information about using the AWS Toolkit For Visual Studio Code with serverless applications can be found [in the AWS documentation](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/serverless-apps.html) .
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# lambda-nodejs22.x
|
2
|
+
|
3
|
+
This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders.
|
4
|
+
|
5
|
+
- hello-world - Code for the application's Lambda function.
|
6
|
+
- events - Invocation events that you can use to invoke the function.
|
7
|
+
- hello-world/tests - Unit tests for the application code.
|
8
|
+
- template.yaml - A template that defines the application's AWS resources.
|
9
|
+
|
10
|
+
The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code.
|
11
|
+
|
12
|
+
If you prefer to use an integrated development environment (IDE) to build and test your application, you can use the AWS Toolkit.
|
13
|
+
The AWS Toolkit is an open source plug-in for popular IDEs that uses the SAM CLI to build and deploy serverless applications on AWS. The AWS Toolkit also adds a simplified step-through debugging experience for Lambda function code. See the following links to get started.
|
14
|
+
|
15
|
+
* [CLion](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
|
16
|
+
* [GoLand](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
|
17
|
+
* [IntelliJ](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
|
18
|
+
* [WebStorm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
|
19
|
+
* [Rider](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
|
20
|
+
* [PhpStorm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
|
21
|
+
* [PyCharm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
|
22
|
+
* [RubyMine](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
|
23
|
+
* [DataGrip](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
|
24
|
+
* [VS Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/welcome.html)
|
25
|
+
* [Visual Studio](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/welcome.html)
|
26
|
+
|
27
|
+
## Deploy the sample application
|
28
|
+
|
29
|
+
The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API.
|
30
|
+
|
31
|
+
To use the SAM CLI, you need the following tools.
|
32
|
+
|
33
|
+
* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
|
34
|
+
* Node.js - [Install Node.js 22](https://nodejs.org/en/), including the NPM package management tool.
|
35
|
+
* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community)
|
36
|
+
|
37
|
+
To build and deploy your application for the first time, run the following in your shell:
|
38
|
+
|
39
|
+
```bash
|
40
|
+
sam build
|
41
|
+
sam deploy --guided
|
42
|
+
```
|
43
|
+
|
44
|
+
The first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts:
|
45
|
+
|
46
|
+
* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name.
|
47
|
+
* **AWS Region**: The AWS region you want to deploy your app to.
|
48
|
+
* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes.
|
49
|
+
* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modifies IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command.
|
50
|
+
* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application.
|
51
|
+
|
52
|
+
You can find your API Gateway Endpoint URL in the output values displayed after deployment.
|
53
|
+
|
54
|
+
## Use the SAM CLI to build and test locally
|
55
|
+
|
56
|
+
Build your application with the `sam build` command.
|
57
|
+
|
58
|
+
```bash
|
59
|
+
lambda-nodejs22.x$ sam build
|
60
|
+
```
|
61
|
+
|
62
|
+
The SAM CLI installs dependencies defined in `hello-world/package.json`, creates a deployment package, and saves it in the `.aws-sam/build` folder.
|
63
|
+
|
64
|
+
Test a single function by invoking it directly with a test event. An event is a JSON document that represents the input that the function receives from the event source. Test events are included in the `events` folder in this project.
|
65
|
+
|
66
|
+
Run functions locally and invoke them with the `sam local invoke` command.
|
67
|
+
|
68
|
+
```bash
|
69
|
+
lambda-nodejs22.x$ sam local invoke HelloWorldFunction --event events/event.json
|
70
|
+
```
|
71
|
+
|
72
|
+
The SAM CLI can also emulate your application's API. Use the `sam local start-api` to run the API locally on port 3000.
|
73
|
+
|
74
|
+
```bash
|
75
|
+
lambda-nodejs22.x$ sam local start-api
|
76
|
+
lambda-nodejs22.x$ curl http://localhost:3000/
|
77
|
+
```
|
78
|
+
|
79
|
+
The SAM CLI reads the application template to determine the API's routes and the functions that they invoke. The `Events` property on each function's definition includes the route and method for each path.
|
80
|
+
|
81
|
+
```yaml
|
82
|
+
Events:
|
83
|
+
HelloWorld:
|
84
|
+
Type: Api
|
85
|
+
Properties:
|
86
|
+
Path: /hello
|
87
|
+
Method: get
|
88
|
+
```
|
89
|
+
|
90
|
+
## Add a resource to your application
|
91
|
+
The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types.
|
92
|
+
|
93
|
+
## Fetch, tail, and filter Lambda function logs
|
94
|
+
|
95
|
+
To simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug.
|
96
|
+
|
97
|
+
`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM.
|
98
|
+
|
99
|
+
```bash
|
100
|
+
lambda-nodejs22.x$ sam logs -n HelloWorldFunction --stack-name lambda-nodejs22.x --tail
|
101
|
+
```
|
102
|
+
|
103
|
+
You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html).
|
104
|
+
|
105
|
+
## Unit tests
|
106
|
+
|
107
|
+
Tests are defined in the `hello-world/tests` folder in this project. Use NPM to install the [Mocha test framework](https://mochajs.org/) and run unit tests.
|
108
|
+
|
109
|
+
```bash
|
110
|
+
lambda-nodejs22.x$ cd hello-world
|
111
|
+
hello-world$ npm install
|
112
|
+
hello-world$ npm run test
|
113
|
+
```
|
114
|
+
|
115
|
+
## Cleanup
|
116
|
+
|
117
|
+
To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following:
|
118
|
+
|
119
|
+
```bash
|
120
|
+
sam delete --stack-name lambda-nodejs22.x
|
121
|
+
```
|
122
|
+
|
123
|
+
## Resources
|
124
|
+
|
125
|
+
See the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for an introduction to SAM specification, the SAM CLI, and serverless application concepts.
|
126
|
+
|
127
|
+
Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: [AWS Serverless Application Repository main page](https://aws.amazon.com/serverless/serverlessrepo/)
|
@@ -0,0 +1,62 @@
|
|
1
|
+
{
|
2
|
+
"body": "{\"message\": \"hello world\"}",
|
3
|
+
"resource": "/{proxy+}",
|
4
|
+
"path": "/path/to/resource",
|
5
|
+
"httpMethod": "POST",
|
6
|
+
"isBase64Encoded": false,
|
7
|
+
"queryStringParameters": {
|
8
|
+
"foo": "bar"
|
9
|
+
},
|
10
|
+
"pathParameters": {
|
11
|
+
"proxy": "/path/to/resource"
|
12
|
+
},
|
13
|
+
"stageVariables": {
|
14
|
+
"baz": "qux"
|
15
|
+
},
|
16
|
+
"headers": {
|
17
|
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
18
|
+
"Accept-Encoding": "gzip, deflate, sdch",
|
19
|
+
"Accept-Language": "en-US,en;q=0.8",
|
20
|
+
"Cache-Control": "max-age=0",
|
21
|
+
"CloudFront-Forwarded-Proto": "https",
|
22
|
+
"CloudFront-Is-Desktop-Viewer": "true",
|
23
|
+
"CloudFront-Is-Mobile-Viewer": "false",
|
24
|
+
"CloudFront-Is-SmartTV-Viewer": "false",
|
25
|
+
"CloudFront-Is-Tablet-Viewer": "false",
|
26
|
+
"CloudFront-Viewer-Country": "US",
|
27
|
+
"Host": "1234567890.execute-api.us-east-1.amazonaws.com",
|
28
|
+
"Upgrade-Insecure-Requests": "1",
|
29
|
+
"User-Agent": "Custom User Agent String",
|
30
|
+
"Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)",
|
31
|
+
"X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==",
|
32
|
+
"X-Forwarded-For": "127.0.0.1, 127.0.0.2",
|
33
|
+
"X-Forwarded-Port": "443",
|
34
|
+
"X-Forwarded-Proto": "https"
|
35
|
+
},
|
36
|
+
"requestContext": {
|
37
|
+
"accountId": "123456789012",
|
38
|
+
"resourceId": "123456",
|
39
|
+
"stage": "prod",
|
40
|
+
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
|
41
|
+
"requestTime": "09/Apr/2015:12:34:56 +0000",
|
42
|
+
"requestTimeEpoch": 1428582896000,
|
43
|
+
"identity": {
|
44
|
+
"cognitoIdentityPoolId": null,
|
45
|
+
"accountId": null,
|
46
|
+
"cognitoIdentityId": null,
|
47
|
+
"caller": null,
|
48
|
+
"accessKey": null,
|
49
|
+
"sourceIp": "127.0.0.1",
|
50
|
+
"cognitoAuthenticationType": null,
|
51
|
+
"cognitoAuthenticationProvider": null,
|
52
|
+
"userArn": null,
|
53
|
+
"userAgent": "Custom User Agent String",
|
54
|
+
"user": null
|
55
|
+
},
|
56
|
+
"path": "/prod/path/to/resource",
|
57
|
+
"resourcePath": "/{proxy+}",
|
58
|
+
"httpMethod": "POST",
|
59
|
+
"apiId": "1234567890",
|
60
|
+
"protocol": "HTTP/1.1"
|
61
|
+
}
|
62
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* Event doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format
|
4
|
+
* @param {Object} event - API Gateway Lambda Proxy Input Format
|
5
|
+
*
|
6
|
+
* Context doc: https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html
|
7
|
+
* @param {Object} context
|
8
|
+
*
|
9
|
+
* Return doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html
|
10
|
+
* @returns {Object} object - API Gateway Lambda Proxy Output Format
|
11
|
+
*
|
12
|
+
*/
|
13
|
+
|
14
|
+
import { Logger } from '@aws-lambda-powertools/logger';
|
15
|
+
const logger = new Logger({ serviceName: 'serverlessAirline' });
|
16
|
+
import Ajv from 'ajv';
|
17
|
+
import {cache, catalog} from "cats-a-logs/index.js";
|
18
|
+
|
19
|
+
export const lambdaHandler = async (event, context) => {
|
20
|
+
const response = {
|
21
|
+
statusCode: 200,
|
22
|
+
body: JSON.stringify({
|
23
|
+
message: 'hello world',
|
24
|
+
}),
|
25
|
+
};
|
26
|
+
let kilos = Math.ceil(Math.random()*70);
|
27
|
+
let pounds =Math.ceil(Math.random()*35);
|
28
|
+
let grams = Math.ceil(Math.random()*20);
|
29
|
+
catalog(pounds, 'poundsTest', 'lambda-junction-metrics2', 'None', {
|
30
|
+
functionVersion: '$LATEST',
|
31
|
+
testDimension: 'berp',
|
32
|
+
});
|
33
|
+
catalog(grams, 'randomTest', 'lambda-junction-metrics2', 'Count', {
|
34
|
+
testDimension: 'berp',
|
35
|
+
functionVersion: '$LATEST',
|
36
|
+
});
|
37
|
+
// catalog(kilos, 'level', 'lambda-junction-metrics2');
|
38
|
+
catalog(
|
39
|
+
kilos,
|
40
|
+
'Weight',
|
41
|
+
'lambda-junction-metrics2',
|
42
|
+
'None',
|
43
|
+
{ functionVersion: '$LATEST', testDimension: 'berp' },
|
44
|
+
60,
|
45
|
+
true
|
46
|
+
);
|
47
|
+
|
48
|
+
//catalog(pounds, "testLogger2" , "lambda-function-metrics", Milliseconds, {'functionVersion': $LATEST, 'testDimension': derp});
|
49
|
+
|
50
|
+
//catalog(trackedVariable: var, metricName: string , metricNamespace: string, metricUnitLabel: string, CustomerDefinedDimension(s): Object {DimensionName: DimensionValue: String, ...}, ...);
|
51
|
+
|
52
|
+
// logger.info('testEMF using logger.info', {
|
53
|
+
// testguy: "hi",
|
54
|
+
// kilos: 54,
|
55
|
+
// testLogger2: 34,
|
56
|
+
// functionVersion: "$LATEST",
|
57
|
+
// testDimension: "derp",
|
58
|
+
// _aws: {
|
59
|
+
// Timestamp: Date.now(),
|
60
|
+
// CloudWatchMetrics: [
|
61
|
+
// {
|
62
|
+
// Namespace: "lambda-function-metrics",
|
63
|
+
// Dimensions: [["functionVersion", "testDimension"]],
|
64
|
+
// Metrics: [
|
65
|
+
// {
|
66
|
+
// Name: "kilos",
|
67
|
+
// Unit: "Kilograms",
|
68
|
+
// StorageResolution: 60
|
69
|
+
// },
|
70
|
+
// {
|
71
|
+
// Name: "testLogger2",
|
72
|
+
// Unit: "Milliseconds",
|
73
|
+
// StorageResolution: 60
|
74
|
+
// }
|
75
|
+
// ]
|
76
|
+
// }
|
77
|
+
// ]
|
78
|
+
// },
|
79
|
+
// });
|
80
|
+
|
81
|
+
return response;
|
82
|
+
};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"name": "hello_world",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "hello world sample for NodeJS",
|
5
|
+
"main": "app.js",
|
6
|
+
"repository": "https://github.com/awslabs/aws-sam-cli/tree/develop/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs",
|
7
|
+
"author": "SAM CLI",
|
8
|
+
"license": "MIT",
|
9
|
+
"dependencies": {
|
10
|
+
"axios": ">=1.6.0",
|
11
|
+
"@aws-lambda-powertools/logger": "^2.11.0",
|
12
|
+
"@aws-lambda-powertools/metrics": "^2.11.0",
|
13
|
+
"lambda-log": "^3.1.0",
|
14
|
+
"ajv": "^8.17.1",
|
15
|
+
"cats-a-logs": "^1.0.1"
|
16
|
+
},
|
17
|
+
"scripts": {
|
18
|
+
"test": "mocha tests/unit/"
|
19
|
+
},
|
20
|
+
"devDependencies": {
|
21
|
+
"chai": "^4.3.6",
|
22
|
+
"mocha": "^10.2.0"
|
23
|
+
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
version = 0.1
|
2
|
+
|
3
|
+
[default.global.parameters]
|
4
|
+
stack_name = "catalog-dev-v1"
|
5
|
+
region = "us-east-2"
|
6
|
+
|
7
|
+
[default.build.parameters]
|
8
|
+
cached = true
|
9
|
+
parallel = true
|
10
|
+
|
11
|
+
[default.validate.parameters]
|
12
|
+
lint = true
|
13
|
+
|
14
|
+
[default.deploy.parameters]
|
15
|
+
capabilities = "CAPABILITY_IAM"
|
16
|
+
confirm_changeset = true
|
17
|
+
resolve_s3 = true
|
18
|
+
|
19
|
+
[default.package.parameters]
|
20
|
+
resolve_s3 = true
|
21
|
+
|
22
|
+
[default.sync.parameters]
|
23
|
+
watch = true
|
24
|
+
template_file = "/Users/clara/code/codesmith/cat-a-log/lambda-nodejs22.x/template.yaml"
|
25
|
+
dependency_layer = false
|
26
|
+
|
27
|
+
[default.local_start_api.parameters]
|
28
|
+
warm_containers = "EAGER"
|
29
|
+
|
30
|
+
[default.local_start_lambda.parameters]
|
31
|
+
warm_containers = "EAGER"
|
@@ -0,0 +1,41 @@
|
|
1
|
+
AWSTemplateFormatVersion: '2010-09-09'
|
2
|
+
Transform: AWS::Serverless-2016-10-31
|
3
|
+
Description: >
|
4
|
+
lambda-nodejs22.x
|
5
|
+
|
6
|
+
Sample SAM Template for lambda-nodejs22.x
|
7
|
+
|
8
|
+
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
|
9
|
+
Globals:
|
10
|
+
Function:
|
11
|
+
Timeout: 3
|
12
|
+
|
13
|
+
Resources:
|
14
|
+
HelloWorldFunction:
|
15
|
+
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
|
16
|
+
Properties:
|
17
|
+
CodeUri: hello-world/
|
18
|
+
Handler: app.lambdaHandler
|
19
|
+
Runtime: nodejs22.x
|
20
|
+
Architectures:
|
21
|
+
- x86_64
|
22
|
+
Events:
|
23
|
+
HelloWorld:
|
24
|
+
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
|
25
|
+
Properties:
|
26
|
+
Path: /hello
|
27
|
+
Method: get
|
28
|
+
|
29
|
+
Outputs:
|
30
|
+
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
|
31
|
+
# Find out more about other implicit resources you can reference within SAM
|
32
|
+
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
|
33
|
+
HelloWorldApi:
|
34
|
+
Description: "API Gateway endpoint URL for Prod stage for Hello World function"
|
35
|
+
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
|
36
|
+
HelloWorldFunction:
|
37
|
+
Description: "Hello World Lambda Function ARN"
|
38
|
+
Value: !GetAtt HelloWorldFunction.Arn
|
39
|
+
HelloWorldFunctionIamRole:
|
40
|
+
Description: "Implicit IAM Role created for Hello World function"
|
41
|
+
Value: !GetAtt HelloWorldFunctionRole.Arn
|
package/package.json
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
{
|
2
|
+
"name": "cat-a-logs",
|
3
|
+
"version": "2.0.0",
|
4
|
+
"description": "Create & send structured logs to AWS Cloudwatch logs",
|
5
|
+
"main": "index.js",
|
6
|
+
"exports":{
|
7
|
+
"./index.js": "./client/index.js"
|
8
|
+
},
|
9
|
+
"scripts": {
|
10
|
+
"test": "jest",
|
11
|
+
"server": "nodemon ./server/server.js",
|
12
|
+
"start": "webpack serve",
|
13
|
+
"dev": "concurrently \"cross-env NODE_ENV=development webpack-dev-server --open --hot --progress --color \" \"nodemon ./server/server.js\""
|
14
|
+
},
|
15
|
+
"keywords": [],
|
16
|
+
"author": "Clara, Curran, Harris, Jacob, Brian",
|
17
|
+
"license": "ISC",
|
18
|
+
"type": "module",
|
19
|
+
"devDependencies": {
|
20
|
+
"@babel/core": "^7.25.7",
|
21
|
+
"@babel/plugin-transform-runtime": "^7.25.7",
|
22
|
+
"@babel/preset-env": "^7.25.8",
|
23
|
+
"@babel/preset-react": "^7.25.7",
|
24
|
+
"@babel/runtime": "^7.25.7",
|
25
|
+
"@types/jest": "^29.5.14",
|
26
|
+
"babel-eslint": "^10.1.0",
|
27
|
+
"babel-loader": "^9.2.1",
|
28
|
+
"concurrently": "^9.0.1",
|
29
|
+
"cross-env": "^7.0.3",
|
30
|
+
"css-loader": "^7.1.2",
|
31
|
+
"html-webpack-plugin": "^5.6.0",
|
32
|
+
"jest": "^29.7.0",
|
33
|
+
"node-mocks-http": "^1.16.1",
|
34
|
+
"nodemon": "^3.1.7",
|
35
|
+
"postcss": "^8.4.49",
|
36
|
+
"postcss-loader": "^8.1.1",
|
37
|
+
"postcss-preset-env": "^10.1.1",
|
38
|
+
"sass": "^1.80.5",
|
39
|
+
"sass-loader": "^16.0.2",
|
40
|
+
"style-loader": "^4.0.0",
|
41
|
+
"tailwindcss": "^3.4.15",
|
42
|
+
"ts-jest": "^29.2.5",
|
43
|
+
"ts-loader": "^9.5.1",
|
44
|
+
"typescript": "^5.7.3",
|
45
|
+
"webpack": "^5.95.0",
|
46
|
+
"webpack-cli": "^5.1.4",
|
47
|
+
"webpack-dev-server": "^5.1.0"
|
48
|
+
},
|
49
|
+
"dependencies": {
|
50
|
+
"@aws-lambda-powertools/logger": "^2.11.0",
|
51
|
+
"@aws-lambda-powertools/metrics": "^2.11.0",
|
52
|
+
"@aws-sdk/client-rds": "^3.709.0",
|
53
|
+
"@testing-library/jest-dom": "^6.6.2",
|
54
|
+
"@testing-library/react": "^16.0.1",
|
55
|
+
"@testing-library/user-event": "^14.5.2",
|
56
|
+
"ajv": "^8.17.1",
|
57
|
+
"bcrypt": "^5.1.1",
|
58
|
+
"cookie-parser": "^1.4.7",
|
59
|
+
"cors": "^2.8.5",
|
60
|
+
"dotenv": "^16.4.7",
|
61
|
+
"express": "^4.21.1",
|
62
|
+
"express-session": "^1.18.1",
|
63
|
+
"jest-environment-jsdom": "^29.7.0",
|
64
|
+
"lambda-log": "^3.1.0",
|
65
|
+
"react": "^18.3.1",
|
66
|
+
"react-dom": "^18.3.1",
|
67
|
+
"react-router-dom": "^6.27.0"
|
68
|
+
}
|
69
|
+
}
|
package/server/server.ts
ADDED