-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@whook/example): add AWS build to @whook/example
- Loading branch information
Showing
19 changed files
with
2,683 additions
and
4,721 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,13 @@ | ||
#!/bin/bash | ||
set -e -o pipefail -u | ||
|
||
echo "Sending Signatures..." | ||
aws s3 cp \ | ||
--content-type text/plain --recursive \ | ||
--exclude "*.zip" --include "*.base64sha256" \ | ||
lambdas/$APP_ENV s3://diagrams-lambdas-release-$APP_ENV/; | ||
|
||
echo "Sending ZIP files..." | ||
aws s3 cp --recursive --exclude "*.base64sha256" \ | ||
--include "*.zip" lambdas/$APP_ENV \ | ||
s3://diagrams-lambdas-release-$APP_ENV/ |
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 @@ | ||
#!/bin/bash | ||
set -e -o pipefail -u | ||
|
||
APP_ENV=${APP_ENV:-local} | ||
FILES=$(ls "builds/$APP_ENV") | ||
|
||
rm -rf "lambdas/$APP_ENV" | ||
mkdir -p "lambdas/$APP_ENV" | ||
|
||
for f in $FILES | ||
do | ||
echo "Processing $f file..." | ||
zip -jr "lambdas/$APP_ENV/$f.zip" builds/$APP_ENV/$f/* | ||
openssl dgst -sha256 -binary "lambdas/$APP_ENV/$f.zip" | openssl enc -base64 | tr -d "\n" > "lambdas/$APP_ENV/$f.zip.base64sha256" | ||
done |
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,61 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`commands should work with config 1`] = ` | ||
{ | ||
"stderr": "⚡ - Loading configurations from /whook/packages/whook-example/dist/config/local/config.js". | ||
", | ||
"stdout": ""localhost" | ||
", | ||
} | ||
`; | ||
|
||
exports[`commands should work with env 1`] = ` | ||
{ | ||
"stderr": "⚡ - Loading configurations from /whook/packages/whook-example/dist/config/local/config.js". | ||
🔂 - Running with "test" node environment. | ||
🔂 - Running with "local" application environment. | ||
", | ||
"stdout": "test | ||
", | ||
} | ||
`; | ||
|
||
exports[`commands should work with ls 1`] = ` | ||
{ | ||
"stderr": "⚡ - Loading configurations from /whook/packages/whook-example/dist/config/local/config.js". | ||
", | ||
"stdout": " | ||
# Provided by "@whook/example": 2 commands | ||
- printEnv: A command printing every env values | ||
- terraformValues: A command printing lambdas informations for Terraform | ||
# Provided by "@whook/whook": 8 commands | ||
- config: A simple program that returns the queryed config value | ||
- create: A command helping to create new Whook files easily | ||
- env: A command printing env values | ||
- generateOpenAPISchema: Write openAPI schema to stdout | ||
- generateOpenAPITypes: Write openAPI types to stdout | ||
- handler: Runs the given server handler for testing purpose | ||
- inspect: A simple program that returns the result of the injected service | ||
- ls: Print available commands | ||
# Provided by "@whook/cors": none | ||
# Provided by "@whook/authorization": none | ||
# Provided by "@whook/aws-lambda": 7 commands | ||
- testConsumerLambda: A command for testing AWS consumer lambda | ||
- testCronLambda: A command for testing AWS cron lambda | ||
- testHTTPLambda: A command for testing AWS HTTP lambda | ||
- testKafkaConsumerLambda: A command for testing AWS lambda Kafka consumers | ||
- testS3Lambda: A command for testing AWS consumer lambda | ||
- testS3Lambda: A command for testing AWS consumer lambda | ||
- testTransformerLambda: A command for testing AWS lambda transformers | ||
", | ||
} | ||
`; |
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,57 @@ | ||
import { describe, beforeAll, test } from '@jest/globals'; | ||
import { exec } from 'child_process'; | ||
import { YError } from 'yerror'; | ||
|
||
describe('build should work', () => { | ||
let env = 'JWT_SECRET=test '; | ||
|
||
beforeAll(async () => { | ||
const { stdout } = await execCommand( | ||
`sed -e 's/^//' .env.${process.env.NODE_ENV} || echo ""`, | ||
); | ||
|
||
env += stdout.trim(); | ||
}); | ||
|
||
[ | ||
['getPing', '{}'], | ||
['getOpenAPI', '{}'], | ||
[ | ||
'getParameters', | ||
'{ "aHeader": "true", "pathParam1":"4", "pathParam2":"a,b,c,d" }', | ||
], | ||
['getTime', '{}'], | ||
['getDelay', '{ "duration": 1 }'], | ||
['putEcho', '{"body": { "echo": "YOLO!" }}'], | ||
].forEach(([operationId, parameters]) => { | ||
test(`with ${operationId} http lambdas`, async () => { | ||
await execCommand( | ||
`${env} npx whook testHTTPLambda --name ${operationId} --parameters '${parameters}'`, | ||
); | ||
}); | ||
}); | ||
|
||
test(`with cron lambdas`, async () => { | ||
await execCommand(`${env} npx whook testCronLambda --name handleMinutes`); | ||
}); | ||
|
||
test(`with consumer lambdas`, async () => { | ||
await execCommand( | ||
`${env} npx whook testConsumerLambda --name handleMessages --event '{ "Records": [{ "test": "test" }] }'`, | ||
); | ||
}); | ||
}); | ||
|
||
async function execCommand( | ||
command, | ||
): Promise<{ stdout: string; stderr: string }> { | ||
return new Promise((resolve, reject) => { | ||
exec(command, (err, stdout, stderr) => { | ||
if (err) { | ||
reject(YError.wrap(err, 'E_COMMAND_FAILURE', stdout, stderr)); | ||
return; | ||
} | ||
resolve({ stdout, stderr }); | ||
}); | ||
}); | ||
} |
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.