-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sls-pack): support serverless-offline
Closes #13
- Loading branch information
1 parent
17ac68d
commit 2041d86
Showing
21 changed files
with
5,536 additions
and
2,057 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,6 @@ Thumbs.db | |
|
||
.nx/cache | ||
examples/complete/package-lock.json | ||
|
||
# logs | ||
*-logs.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Debug Examples", | ||
"type": "node", | ||
"request": "attach", | ||
"port": 9229, | ||
"sourceMaps": true, | ||
"outFiles": ["${workspaceFolder}/examples/**/*.js"] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Serverless-offline commands | ||
|
||
## By AWS Cli invoke: | ||
|
||
aws lambda invoke ./app3-logs.txt \ | ||
--endpoint-url http://localhost:3002 \ | ||
--function-name complete-example-dev-app3 | ||
|
||
## By aws sdk: | ||
|
||
node offline-invoke.mjs | ||
|
||
## By mocked Rest API | ||
|
||
curl http://localhost:3000/dev/helloApp3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Buffer } from 'node:buffer'; | ||
import aws from 'aws-sdk'; | ||
|
||
const { stringify } = JSON; | ||
|
||
const lambda = new aws.Lambda({ | ||
apiVersion: '2015-03-31', | ||
endpoint: 'http://localhost:3002', | ||
region: 'eu-west-1', | ||
}); | ||
|
||
export async function handler() { | ||
const clientContextData = stringify({ | ||
foo: 'foo', | ||
}); | ||
|
||
const payload = stringify({ | ||
isin: 'XX000A1G0AE8', | ||
}); | ||
|
||
const params = { | ||
ClientContext: Buffer.from(clientContextData).toString('base64'), | ||
// FunctionName is composed of: service name - stage - function name, e.g. | ||
FunctionName: 'complete-example-dev-app3', | ||
InvocationType: 'RequestResponse', | ||
Payload: payload, | ||
}; | ||
|
||
const response = await lambda.invoke(params).promise(); | ||
console.log(response); | ||
|
||
return { | ||
body: stringify(response), | ||
statusCode: 200, | ||
}; | ||
} | ||
|
||
handler(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.