From 9c8902ca4da3ea6e9603971d425a077d24585e7f Mon Sep 17 00:00:00 2001 From: Nicolas Froidure Date: Sat, 28 Mar 2020 15:05:40 +0100 Subject: [PATCH] feat(@whook/example): add AWS build to @whook/example --- .../__snapshots__/createWhook.test.ts.snap | 8 +- .../src/services/createWhook.test.ts | 22 +- packages/whook-example/README.md | 84 +++- packages/whook-example/package.json | 58 +-- .../src/__snapshots__/cli.test.ts.snap | 17 +- .../src/__snapshots__/index.test.ts.snap | 143 ++++++- packages/whook-example/src/build.test.ts | 45 ++ packages/whook-example/src/build.ts | 13 +- .../src/commands/terraformValues.ts | 303 +++++++++++++ .../whook-example/src/config/common/config.ts | 70 ++- .../src/handlers/handleMessages.ts | 41 ++ .../src/handlers/handleMinutes.ts | 42 ++ packages/whook-example/src/index.ts | 7 +- .../services/__snapshots__/API.test.ts.snap | 41 ++ .../terraform/.terraform.lock.hcl | 76 ++++ .../whook-example/terraform/api_gateway.tf | 79 ++++ .../whook-example/terraform/api_lambdas.tf | 13 + .../whook-example/terraform/api_responses.tf | 399 ++++++++++++++++++ .../terraform/consumer_lambdas.tf | 49 +++ .../whook-example/terraform/cron_lambdas.tf | 29 ++ packages/whook-example/terraform/lambdas.tf | 110 +++++ packages/whook-example/terraform/main.tf | 5 + packages/whook-example/terraform/outputs.tf | 11 + packages/whook-example/terraform/versions.tf | 28 ++ 24 files changed, 1645 insertions(+), 48 deletions(-) create mode 100644 packages/whook-example/src/build.test.ts create mode 100644 packages/whook-example/src/commands/terraformValues.ts create mode 100644 packages/whook-example/src/handlers/handleMessages.ts create mode 100644 packages/whook-example/src/handlers/handleMinutes.ts create mode 100755 packages/whook-example/terraform/.terraform.lock.hcl create mode 100644 packages/whook-example/terraform/api_gateway.tf create mode 100644 packages/whook-example/terraform/api_lambdas.tf create mode 100644 packages/whook-example/terraform/api_responses.tf create mode 100644 packages/whook-example/terraform/consumer_lambdas.tf create mode 100644 packages/whook-example/terraform/cron_lambdas.tf create mode 100644 packages/whook-example/terraform/lambdas.tf create mode 100644 packages/whook-example/terraform/main.tf create mode 100644 packages/whook-example/terraform/outputs.tf create mode 100644 packages/whook-example/terraform/versions.tf diff --git a/packages/whook-create/src/services/__snapshots__/createWhook.test.ts.snap b/packages/whook-create/src/services/__snapshots__/createWhook.test.ts.snap index ace2c881..9ff21c89 100644 --- a/packages/whook-create/src/services/__snapshots__/createWhook.test.ts.snap +++ b/packages/whook-create/src/services/__snapshots__/createWhook.test.ts.snap @@ -66,7 +66,7 @@ Wayne Campbell ], Array [ "/home/whoiam/projects/yolo/package.json", - "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=12.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"apitypes\\":\\"npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts\\",\\"build\\":\\"npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"watch\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^9.0.0\\",\\"http-auth-utils\\":\\"^3.0.0\\",\\"jwt-service\\":\\"^7.1.0\\",\\"knifecycle\\":\\"^11.1.0\\",\\"strict-qs\\":\\"^6.1.3\\",\\"type-fest\\":\\"^0.21.2\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.2\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.12.1\\",\\"@babel/core\\":\\"^7.12.3\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.12.1\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.12.1\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.12.1\\",\\"@babel/preset-typescript\\":\\"^7.12.1\\",\\"@babel/register\\":\\"^7.12.1\\",\\"@types/jest\\":\\"^26.0.15\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.8.1\\",\\"@typescript-eslint/parser\\":\\"^4.8.1\\",\\"axios\\":\\"^0.21.1\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-plugin-knifecycle\\":\\"^5.0.0\\",\\"chokidar\\":\\"^3.4.3\\",\\"eslint\\":\\"^7.13.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.4\\",\\"jest\\":\\"^26.6.3\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.1.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.0\\",\\"typescript\\":\\"^4.0.5\\"},\\"eslintConfig\\":{\\"extends\\":[\\"eslint:recommended\\",\\"plugin:@typescript-eslint/eslint-recommended\\",\\"plugin:@typescript-eslint/recommended\\"],\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12.19.0\\"}}]],\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]]},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":false}]]}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", + "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=12.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"apitypes\\":\\"npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts\\",\\"build\\":\\"npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"NODE_ENV=test npm run build && npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"watch\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/aws-lambda\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^9.0.0\\",\\"http-auth-utils\\":\\"^3.0.0\\",\\"jwt-service\\":\\"^7.1.0\\",\\"knifecycle\\":\\"^11.1.0\\",\\"strict-qs\\":\\"^6.1.3\\",\\"type-fest\\":\\"^0.21.2\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.2\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.12.1\\",\\"@babel/core\\":\\"^7.12.3\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.12.1\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.12.1\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.12.1\\",\\"@babel/preset-typescript\\":\\"^7.12.1\\",\\"@babel/register\\":\\"^7.12.1\\",\\"@types/jest\\":\\"^26.0.15\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.8.1\\",\\"@typescript-eslint/parser\\":\\"^4.8.1\\",\\"axios\\":\\"^0.21.1\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-loader\\":\\"^8.1.0\\",\\"babel-plugin-knifecycle\\":\\"^5.0.0\\",\\"chokidar\\":\\"^3.4.3\\",\\"eslint\\":\\"^7.13.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.4\\",\\"jest\\":\\"^26.6.3\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.1.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.0\\",\\"typescript\\":\\"^4.0.5\\",\\"webpack\\":\\"4.44.2\\"},\\"eslintConfig\\":{\\"extends\\":[\\"eslint:recommended\\",\\"plugin:@typescript-eslint/eslint-recommended\\",\\"plugin:@typescript-eslint/recommended\\"],\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12.19.0\\"}}]],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]],\\"comments\\":true},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":false}]],\\"comments\\":false}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", ], Array [ "/home/whoiam/projects/yolo/LICENSE", @@ -191,7 +191,7 @@ Wayne Campbell ], Array [ "/home/whoiam/projects/yolo/package.json", - "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=12.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"apitypes\\":\\"npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts\\",\\"build\\":\\"npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"watch\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^9.0.0\\",\\"http-auth-utils\\":\\"^3.0.0\\",\\"jwt-service\\":\\"^7.1.0\\",\\"knifecycle\\":\\"^11.1.0\\",\\"strict-qs\\":\\"^6.1.3\\",\\"type-fest\\":\\"^0.21.2\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.2\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.12.1\\",\\"@babel/core\\":\\"^7.12.3\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.12.1\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.12.1\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.12.1\\",\\"@babel/preset-typescript\\":\\"^7.12.1\\",\\"@babel/register\\":\\"^7.12.1\\",\\"@types/jest\\":\\"^26.0.15\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.8.1\\",\\"@typescript-eslint/parser\\":\\"^4.8.1\\",\\"axios\\":\\"^0.21.1\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-plugin-knifecycle\\":\\"^5.0.0\\",\\"chokidar\\":\\"^3.4.3\\",\\"eslint\\":\\"^7.13.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.4\\",\\"jest\\":\\"^26.6.3\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.1.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.0\\",\\"typescript\\":\\"^4.0.5\\"},\\"eslintConfig\\":{\\"extends\\":[\\"eslint:recommended\\",\\"plugin:@typescript-eslint/eslint-recommended\\",\\"plugin:@typescript-eslint/recommended\\"],\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12.19.0\\"}}]],\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]]},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":false}]]}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", + "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=12.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"apitypes\\":\\"npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts\\",\\"build\\":\\"npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"NODE_ENV=test npm run build && npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"watch\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/aws-lambda\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^9.0.0\\",\\"http-auth-utils\\":\\"^3.0.0\\",\\"jwt-service\\":\\"^7.1.0\\",\\"knifecycle\\":\\"^11.1.0\\",\\"strict-qs\\":\\"^6.1.3\\",\\"type-fest\\":\\"^0.21.2\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.2\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.12.1\\",\\"@babel/core\\":\\"^7.12.3\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.12.1\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.12.1\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.12.1\\",\\"@babel/preset-typescript\\":\\"^7.12.1\\",\\"@babel/register\\":\\"^7.12.1\\",\\"@types/jest\\":\\"^26.0.15\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.8.1\\",\\"@typescript-eslint/parser\\":\\"^4.8.1\\",\\"axios\\":\\"^0.21.1\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-loader\\":\\"^8.1.0\\",\\"babel-plugin-knifecycle\\":\\"^5.0.0\\",\\"chokidar\\":\\"^3.4.3\\",\\"eslint\\":\\"^7.13.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.4\\",\\"jest\\":\\"^26.6.3\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.1.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.0\\",\\"typescript\\":\\"^4.0.5\\",\\"webpack\\":\\"4.44.2\\"},\\"eslintConfig\\":{\\"extends\\":[\\"eslint:recommended\\",\\"plugin:@typescript-eslint/eslint-recommended\\",\\"plugin:@typescript-eslint/recommended\\"],\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12.19.0\\"}}]],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]],\\"comments\\":true},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":false}]],\\"comments\\":false}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", ], Array [ "/home/whoiam/projects/yolo/LICENSE", @@ -348,7 +348,7 @@ Wayne Campbell ], Array [ "/home/whoiam/projects/yolo/package.json", - "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=12.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"apitypes\\":\\"npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts\\",\\"build\\":\\"npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"watch\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^9.0.0\\",\\"http-auth-utils\\":\\"^3.0.0\\",\\"jwt-service\\":\\"^7.1.0\\",\\"knifecycle\\":\\"^11.1.0\\",\\"strict-qs\\":\\"^6.1.3\\",\\"type-fest\\":\\"^0.21.2\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.2\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.12.1\\",\\"@babel/core\\":\\"^7.12.3\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.12.1\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.12.1\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.12.1\\",\\"@babel/preset-typescript\\":\\"^7.12.1\\",\\"@babel/register\\":\\"^7.12.1\\",\\"@types/jest\\":\\"^26.0.15\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.8.1\\",\\"@typescript-eslint/parser\\":\\"^4.8.1\\",\\"axios\\":\\"^0.21.1\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-plugin-knifecycle\\":\\"^5.0.0\\",\\"chokidar\\":\\"^3.4.3\\",\\"eslint\\":\\"^7.13.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.4\\",\\"jest\\":\\"^26.6.3\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.1.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.0\\",\\"typescript\\":\\"^4.0.5\\"},\\"eslintConfig\\":{\\"extends\\":[\\"eslint:recommended\\",\\"plugin:@typescript-eslint/eslint-recommended\\",\\"plugin:@typescript-eslint/recommended\\"],\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12.19.0\\"}}]],\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]]},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":false}]]}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", + "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=12.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"apitypes\\":\\"npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts\\",\\"build\\":\\"npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"NODE_ENV=test npm run build && npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"watch\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/aws-lambda\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^9.0.0\\",\\"http-auth-utils\\":\\"^3.0.0\\",\\"jwt-service\\":\\"^7.1.0\\",\\"knifecycle\\":\\"^11.1.0\\",\\"strict-qs\\":\\"^6.1.3\\",\\"type-fest\\":\\"^0.21.2\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.2\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.12.1\\",\\"@babel/core\\":\\"^7.12.3\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.12.1\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.12.1\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.12.1\\",\\"@babel/preset-typescript\\":\\"^7.12.1\\",\\"@babel/register\\":\\"^7.12.1\\",\\"@types/jest\\":\\"^26.0.15\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.8.1\\",\\"@typescript-eslint/parser\\":\\"^4.8.1\\",\\"axios\\":\\"^0.21.1\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-loader\\":\\"^8.1.0\\",\\"babel-plugin-knifecycle\\":\\"^5.0.0\\",\\"chokidar\\":\\"^3.4.3\\",\\"eslint\\":\\"^7.13.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.4\\",\\"jest\\":\\"^26.6.3\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.1.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.0\\",\\"typescript\\":\\"^4.0.5\\",\\"webpack\\":\\"4.44.2\\"},\\"eslintConfig\\":{\\"extends\\":[\\"eslint:recommended\\",\\"plugin:@typescript-eslint/eslint-recommended\\",\\"plugin:@typescript-eslint/recommended\\"],\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12.19.0\\"}}]],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]],\\"comments\\":true},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":false}]],\\"comments\\":false}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", ], Array [ "/home/whoiam/projects/yolo/LICENSE", @@ -493,7 +493,7 @@ Wayne Campbell ], Array [ "/home/whoiam/projects/yolo/package.json", - "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=12.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"apitypes\\":\\"npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts\\",\\"build\\":\\"npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"watch\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^9.0.0\\",\\"http-auth-utils\\":\\"^3.0.0\\",\\"jwt-service\\":\\"^7.1.0\\",\\"knifecycle\\":\\"^11.1.0\\",\\"strict-qs\\":\\"^6.1.3\\",\\"type-fest\\":\\"^0.21.2\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.2\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.12.1\\",\\"@babel/core\\":\\"^7.12.3\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.12.1\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.12.1\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.12.1\\",\\"@babel/preset-typescript\\":\\"^7.12.1\\",\\"@babel/register\\":\\"^7.12.1\\",\\"@types/jest\\":\\"^26.0.15\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.8.1\\",\\"@typescript-eslint/parser\\":\\"^4.8.1\\",\\"axios\\":\\"^0.21.1\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-plugin-knifecycle\\":\\"^5.0.0\\",\\"chokidar\\":\\"^3.4.3\\",\\"eslint\\":\\"^7.13.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.4\\",\\"jest\\":\\"^26.6.3\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.1.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.0\\",\\"typescript\\":\\"^4.0.5\\"},\\"eslintConfig\\":{\\"extends\\":[\\"eslint:recommended\\",\\"plugin:@typescript-eslint/eslint-recommended\\",\\"plugin:@typescript-eslint/recommended\\"],\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12.19.0\\"}}]],\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]]},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":false}]]}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", + "{\\"name\\":\\"super-project\\",\\"description\\":\\"A new Whook project\\",\\"version\\":\\"0.0.0\\",\\"license\\":\\"SEE LICENSE\\",\\"engines\\":{\\"node\\":\\">=12.19.0\\"},\\"main\\":\\"dist/index\\",\\"module\\":\\"dist/index.mjs\\",\\"types\\":\\"dist/index.d.ts\\",\\"private\\":true,\\"keywords\\":[\\"whook\\"],\\"author\\":{\\"name\\":\\"Wayne Campbell\\",\\"email\\":\\"wayne@warner.com\\"},\\"scripts\\":{\\"apitypes\\":\\"npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts\\",\\"build\\":\\"npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build\\",\\"compile\\":\\"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\\",\\"compile:cjs\\":\\"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"compile:mjs\\":\\"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\\",\\"cover\\":\\"npm run jest -- --coverage\\",\\"debug\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\\",\\"dev\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\\",\\"jest\\":\\"NODE_ENV=test jest\\",\\"lint\\":\\"eslint 'src/**/*.ts'\\",\\"prettier\\":\\"prettier --write 'src/**/*.ts'\\",\\"start\\":\\"NODE_ENV=\${NODE_ENV:-development} node bin/start\\",\\"test\\":\\"NODE_ENV=test npm run build && npm run jest\\",\\"types\\":\\"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\\",\\"watch\\":\\"NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch\\",\\"whook\\":\\"NODE_ENV=\${NODE_ENV:-development} whook\\",\\"whook-dev\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/aws-lambda\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^9.0.0\\",\\"http-auth-utils\\":\\"^3.0.0\\",\\"jwt-service\\":\\"^7.1.0\\",\\"knifecycle\\":\\"^11.1.0\\",\\"strict-qs\\":\\"^6.1.3\\",\\"type-fest\\":\\"^0.21.2\\",\\"yerror\\":\\"^5.0.0\\",\\"yhttperror\\":\\"^5.0.2\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.12.1\\",\\"@babel/core\\":\\"^7.12.3\\",\\"@babel/node\\":\\"^7.2.2\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.12.1\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.12.1\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.12.1\\",\\"@babel/preset-typescript\\":\\"^7.12.1\\",\\"@babel/register\\":\\"^7.12.1\\",\\"@types/jest\\":\\"^26.0.15\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.8.1\\",\\"@typescript-eslint/parser\\":\\"^4.8.1\\",\\"axios\\":\\"^0.21.1\\",\\"babel-eslint\\":\\"^10.1.0\\",\\"babel-loader\\":\\"^8.1.0\\",\\"babel-plugin-knifecycle\\":\\"^5.0.0\\",\\"chokidar\\":\\"^3.4.3\\",\\"eslint\\":\\"^7.13.0\\",\\"eslint-plugin-prettier\\":\\"^3.1.4\\",\\"jest\\":\\"^26.6.3\\",\\"openapi-schema-validator\\":\\"^3.0.3\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.1.2\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.0\\",\\"typescript\\":\\"^4.0.5\\",\\"webpack\\":\\"4.44.2\\"},\\"eslintConfig\\":{\\"extends\\":[\\"eslint:recommended\\",\\"plugin:@typescript-eslint/eslint-recommended\\",\\"plugin:@typescript-eslint/recommended\\"],\\"parserOptions\\":{\\"ecmaVersion\\":2018,\\"sourceType\\":\\"module\\",\\"modules\\":true},\\"env\\":{\\"es6\\":true,\\"node\\":true,\\"jest\\":true,\\"mocha\\":true},\\"plugins\\":[\\"prettier\\"],\\"rules\\":{\\"prettier/prettier\\":\\"error\\"},\\"parser\\":\\"@typescript-eslint/parser\\",\\"ignorePatterns\\":[\\"*.d.ts\\"]},\\"prettier\\":{\\"semi\\":true,\\"printWidth\\":80,\\"singleQuote\\":true,\\"trailingComma\\":\\"all\\",\\"proseWrap\\":\\"always\\"},\\"babel\\":{\\"plugins\\":[\\"@babel/proposal-class-properties\\",\\"@babel/plugin-proposal-object-rest-spread\\",\\"babel-plugin-knifecycle\\"],\\"presets\\":[\\"@babel/typescript\\",[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12.19.0\\"}}]],\\"env\\":{\\"cjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"10\\"},\\"modules\\":\\"commonjs\\"}]],\\"comments\\":true},\\"mjs\\":{\\"presets\\":[[\\"@babel/env\\",{\\"targets\\":{\\"node\\":\\"12\\"},\\"modules\\":false}]],\\"comments\\":false}},\\"sourceMaps\\":true},\\"jest\\":{\\"coverageReporters\\":[\\"lcov\\",\\"html\\"],\\"testPathIgnorePatterns\\":[\\"/node_modules/\\"],\\"roots\\":[\\"/src\\"],\\"testEnvironment\\":\\"node\\"}}", ], Array [ "/home/whoiam/projects/yolo/LICENSE", diff --git a/packages/whook-create/src/services/createWhook.test.ts b/packages/whook-create/src/services/createWhook.test.ts index 634d0b5a..485c38d5 100644 --- a/packages/whook-create/src/services/createWhook.test.ts +++ b/packages/whook-create/src/services/createWhook.test.ts @@ -12,6 +12,7 @@ describe('initCreateWhook', () => { dependencies: { ..._packageJSON.dependencies, '@whook/authorization': '', + '@whook/aws-lambda': '', '@whook/cli': '', '@whook/cors': '', '@whook/http-router': '', @@ -138,6 +139,7 @@ Mr Bean "babel": Object { "env": Object { "cjs": Object { + "comments": true, "presets": Array [ Array [ "@babel/env", @@ -151,6 +153,7 @@ Mr Bean ], }, "mjs": Object { + "comments": false, "presets": Array [ Array [ "@babel/env", @@ -184,6 +187,7 @@ Mr Bean }, "dependencies": Object { "@whook/authorization": "", + "@whook/aws-lambda": "", "@whook/cli": "", "@whook/cors": "", "@whook/http-router": "", @@ -216,6 +220,7 @@ Mr Bean "@typescript-eslint/parser": "^4.8.1", "axios": "^0.21.1", "babel-eslint": "^10.1.0", + "babel-loader": "^8.1.0", "babel-plugin-knifecycle": "^5.0.0", "chokidar": "^3.4.3", "eslint": "^7.13.0", @@ -227,6 +232,7 @@ Mr Bean "rimraf": "^3.0.2", "schema2dts": "^2.0.0", "typescript": "^4.0.5", + "webpack": "4.44.2", }, "engines": Object { "node": ">=12.19.0", @@ -308,7 +314,7 @@ Mr Bean "lint": "eslint 'src/**/*.ts'", "prettier": "prettier --write 'src/**/*.ts'", "start": "NODE_ENV=\${NODE_ENV:-development} node bin/start", - "test": "npm run jest", + "test": "NODE_ENV=test npm run build && npm run jest", "types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist", "watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch", "whook": "NODE_ENV=\${NODE_ENV:-development} whook", @@ -393,6 +399,7 @@ Mr Bean "babel": Object { "env": Object { "cjs": Object { + "comments": true, "presets": Array [ Array [ "@babel/env", @@ -406,6 +413,7 @@ Mr Bean ], }, "mjs": Object { + "comments": false, "presets": Array [ Array [ "@babel/env", @@ -439,6 +447,7 @@ Mr Bean }, "dependencies": Object { "@whook/authorization": "", + "@whook/aws-lambda": "", "@whook/cli": "", "@whook/cors": "", "@whook/http-router": "", @@ -471,6 +480,7 @@ Mr Bean "@typescript-eslint/parser": "^4.8.1", "axios": "^0.21.1", "babel-eslint": "^10.1.0", + "babel-loader": "^8.1.0", "babel-plugin-knifecycle": "^5.0.0", "chokidar": "^3.4.3", "eslint": "^7.13.0", @@ -482,6 +492,7 @@ Mr Bean "rimraf": "^3.0.2", "schema2dts": "^2.0.0", "typescript": "^4.0.5", + "webpack": "4.44.2", }, "engines": Object { "node": ">=12.19.0", @@ -563,7 +574,7 @@ Mr Bean "lint": "eslint 'src/**/*.ts'", "prettier": "prettier --write 'src/**/*.ts'", "start": "NODE_ENV=\${NODE_ENV:-development} node bin/start", - "test": "npm run jest", + "test": "NODE_ENV=test npm run build && npm run jest", "types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist", "watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch", "whook": "NODE_ENV=\${NODE_ENV:-development} whook", @@ -633,6 +644,7 @@ Mr Bean "babel": Object { "env": Object { "cjs": Object { + "comments": true, "presets": Array [ Array [ "@babel/env", @@ -646,6 +658,7 @@ Mr Bean ], }, "mjs": Object { + "comments": false, "presets": Array [ Array [ "@babel/env", @@ -679,6 +692,7 @@ Mr Bean }, "dependencies": Object { "@whook/authorization": "", + "@whook/aws-lambda": "", "@whook/cli": "", "@whook/cors": "", "@whook/http-router": "", @@ -711,6 +725,7 @@ Mr Bean "@typescript-eslint/parser": "^4.8.1", "axios": "^0.21.1", "babel-eslint": "^10.1.0", + "babel-loader": "^8.1.0", "babel-plugin-knifecycle": "^5.0.0", "chokidar": "^3.4.3", "eslint": "^7.13.0", @@ -722,6 +737,7 @@ Mr Bean "rimraf": "^3.0.2", "schema2dts": "^2.0.0", "typescript": "^4.0.5", + "webpack": "4.44.2", }, "engines": Object { "node": ">=12.19.0", @@ -803,7 +819,7 @@ Mr Bean "lint": "eslint 'src/**/*.ts'", "prettier": "prettier --write 'src/**/*.ts'", "start": "NODE_ENV=\${NODE_ENV:-development} node bin/start", - "test": "npm run jest", + "test": "NODE_ENV=test npm run build && npm run jest", "types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist", "watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch", "whook": "NODE_ENV=\${NODE_ENV:-development} whook", diff --git a/packages/whook-example/README.md b/packages/whook-example/README.md index 263eb170..6be139f8 100644 --- a/packages/whook-example/README.md +++ b/packages/whook-example/README.md @@ -13,12 +13,13 @@ [//]: # (::contents:start) -This is a basic [Whook](https://github.com/nfroidure/whook) - server demonstrating the various usages of the Whook framework to build - REST APIs. +This is a basic [Whook](https://github.com/nfroidure/whook) server demonstrating +the various usages of the Whook framework to build REST APIs. ## Usage + To run the server in production: + ```sh npm it NODE_ENV=production npm start @@ -27,6 +28,7 @@ NODE_ENV=production npm start ## Dev Start the server in development: + ```sh # Simple dev mode npm run dev @@ -36,36 +38,112 @@ npm run watch ``` Create a new endpoint / service / provider or command: + ```sh npx whook create ``` List available commands: + ```sh npx whook ls ``` +## Deploying with AWS Lambda + +First install Terraform: + +```sh +wget https://releases.hashicorp.com/terraform/0.14.0/terraform_0.14.0_linux_amd64.zip +mkdir .bin +unzip -d .bin terraform_0.14.0_linux_amd64.zip +rm terraform_0.14.0_linux_amd64.zip +``` + +Then initialize the Terraform configuration: + +```sh +cd ./terraform +../.bin/terraform init; +``` + +Create a new workspace: + +```sh +../.bin/terraform workspace new staging +``` + +Build the lambdas: + +```sh +NODE_ENV=staging npm run build +``` + +Build the commands Terraform depends on: + +```sh +npm run compile +``` + +Plan the deployment: + +```sh +../.bin/terraform plan -out=terraform.plan +``` + +Apply changes: + +```sh +../.bin/terraform apply terraform.plan +``` + +Finally retrieve the API URL and add and enjoy! + +```sh +../.bin/terraform output api_url +curl "$(.bin/terraform output api_url)staging/v3/ping" +# {"pong":"pong"} +``` + Generate API types: + ```sh npm run apitypes ``` ## Debug + Execute a handler in isolation: + ```sh npx whook handler --name putEcho --parameters '{"body": { "echo": "YOLO!" }}' ``` Debug `whook` internals: + ```sh DEBUG=whook npm run dev ``` Debug `knifecycle` internals (dependency injection issues): + ```sh DEBUG=knifecycle npm run dev ``` +Debug built lambdas: + +```sh +## HTTP +NODE_ENV=staging npx whook testHTTPLambda --name putEcho \ + --parameters '{ "body": { "echo": "Hey!" } }' +## Cron +NODE_ENV=staging npx whook testCronLambda --name handleMinutes +## Consumer +NODE_ENV=staging npx whook testConsumerLambda --name handleMessages \ + --event '{ "Records": [{ "test": "test" }] }' +``` + [//]: # (::contents:end) # Authors diff --git a/packages/whook-example/package.json b/packages/whook-example/package.json index 4667efc3..d3e3ea78 100644 --- a/packages/whook-example/package.json +++ b/packages/whook-example/package.json @@ -32,7 +32,12 @@ "testsFiles": "'src/**/*.test.ts'", "distFiles": "'dist/**/*.js'", "ignore": [ - "dist" + "dist", + "builds", + ".bin", + ".terraform", + "*.plan", + "*.tfstate.d" ], "bundleFiles": [ "bin", @@ -56,7 +61,7 @@ "metapak": "metapak", "prettier": "prettier --write 'src/**/*.ts'", "start": "NODE_ENV=${NODE_ENV:-development} node bin/start", - "test": "npm run jest", + "test": "NODE_ENV=test npm run build && npm run jest", "types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist", "watch": "NODE_ENV=${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch", "whook": "NODE_ENV=${NODE_ENV:-development} whook", @@ -78,6 +83,7 @@ "homepage": "https://github.com/nfroidure/whook", "dependencies": { "@whook/authorization": "^8.0.2", + "@whook/aws-lambda": "^8.0.2", "@whook/cli": "^8.0.2", "@whook/cors": "^8.0.2", "@whook/http-router": "^8.0.2", @@ -109,6 +115,7 @@ "@typescript-eslint/parser": "^4.8.1", "axios": "^0.21.1", "babel-eslint": "^10.1.0", + "babel-loader": "^8.1.0", "babel-plugin-knifecycle": "^5.0.0", "chokidar": "^3.4.3", "eslint": "^7.13.0", @@ -121,7 +128,8 @@ "prettier": "^2.1.2", "rimraf": "^3.0.2", "schema2dts": "^2.0.0", - "typescript": "^4.0.5" + "typescript": "^4.0.5", + "webpack": "4.44.2" }, "contributors": [], "engines": { @@ -170,7 +178,25 @@ "trailingComma": "all", "proseWrap": "always" }, + "jest": { + "coverageReporters": [ + "lcov", + "html" + ], + "testPathIgnorePatterns": [ + "/node_modules/" + ], + "roots": [ + "/src" + ], + "testEnvironment": "node" + }, "babel": { + "plugins": [ + "@babel/proposal-class-properties", + "@babel/plugin-proposal-object-rest-spread", + "babel-plugin-knifecycle" + ], "presets": [ "@babel/typescript", [ @@ -182,11 +208,6 @@ } ] ], - "plugins": [ - "@babel/proposal-class-properties", - "@babel/plugin-proposal-object-rest-spread", - "babel-plugin-knifecycle" - ], "env": { "cjs": { "presets": [ @@ -199,7 +220,8 @@ "modules": "commonjs" } ] - ] + ], + "comments": true }, "mjs": { "presets": [ @@ -212,22 +234,10 @@ "modules": false } ] - ] + ], + "comments": false } }, "sourceMaps": true - }, - "jest": { - "coverageReporters": [ - "lcov", - "html" - ], - "testPathIgnorePatterns": [ - "/node_modules/" - ], - "roots": [ - "/src" - ], - "testEnvironment": "node" } -} +} \ No newline at end of file diff --git a/packages/whook-example/src/__snapshots__/cli.test.ts.snap b/packages/whook-example/src/__snapshots__/cli.test.ts.snap index c3204d66..28f02731 100644 --- a/packages/whook-example/src/__snapshots__/cli.test.ts.snap +++ b/packages/whook-example/src/__snapshots__/cli.test.ts.snap @@ -28,10 +28,21 @@ Object { ", "stdout": " -# Provided by \\"@whook/example\\": 3 commands +# Provided by \\"@whook/example\\": 4 commands - generateOpenAPISchema: Write openAPI schema to stdout - generateOpenAPITypes: Write openAPI types to stdout - printEnv: A command printing every env values +- terraformValues: A command printing lambdas informations for Terraform + + +# 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 # Provided by \\"@whook/cli\\": 6 commands @@ -43,10 +54,10 @@ Object { - ls: Print available commands -# Provided by \\"@whook/whook\\": none +# Provided by \\"@whook/cors\\": none -# Provided by \\"@whook/cors\\": none +# Provided by \\"@whook/whook\\": none ", } `; diff --git a/packages/whook-example/src/__snapshots__/index.test.ts.snap b/packages/whook-example/src/__snapshots__/index.test.ts.snap index 74dbed33..8798d375 100644 --- a/packages/whook-example/src/__snapshots__/index.test.ts.snap +++ b/packages/whook-example/src/__snapshots__/index.test.ts.snap @@ -152,6 +152,9 @@ Object { Array [ "❤️ - Initializing the APM service.", ], + Array [ + "➰ - Plugin \\"@whook/aws-lambda\\" resolved to \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist\\".", + ], Array [ "➰ - Plugin \\"@whook/cli\\" resolved to \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist\\".", ], @@ -218,6 +221,12 @@ Object { Array [ "💿 - Loading \\"getTimeWrapped\\" initializer from \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/getTime.ts\\".", ], + Array [ + "💿 - Loading \\"handleMessagesWrapped\\" initializer from \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/handleMessages.ts\\".", + ], + Array [ + "💿 - Loading \\"handleMinutesWrapped\\" initializer from \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/handleMinutes.ts\\".", + ], Array [ "💿 - Loading \\"jwtToken\\" initializer from \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/jwtToken.ts\\".", ], @@ -266,6 +275,12 @@ Object { Array [ "💿 - Service \\"getTimeWrapped\\" found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/getTime.ts\\".", ], + Array [ + "💿 - Service \\"handleMessagesWrapped\\" found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/handleMessages.ts\\".", + ], + Array [ + "💿 - Service \\"handleMinutesWrapped\\" found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/handleMinutes.ts\\".", + ], Array [ "💿 - Service \\"jwtToken\\" found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/jwtToken.ts\\".", ], @@ -296,6 +311,12 @@ Object { Array [ "🔐 - Initializing the authorization wrapper for \\"getTime\\".", ], + Array [ + "🔐 - Initializing the authorization wrapper for \\"handleMessages\\".", + ], + Array [ + "🔐 - Initializing the authorization wrapper for \\"handleMinutes\\".", + ], Array [ "🔐 - Initializing the authorization wrapper for \\"optionsWithCORS\\".", ], @@ -314,12 +335,21 @@ Object { Array [ "🚫 - Could not load \\".env.test\\" file.", ], + Array [ + "🚫 - Service \\"BASE_URL\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/BASE_URL\\".", + ], Array [ "🚫 - Service \\"BASE_URL\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/BASE_URL\\".", ], + Array [ + "🚫 - Service \\"BASE_URL\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cors/dist/services/BASE_URL\\".", + ], Array [ "🚫 - Service \\"BASE_URL\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/BASE_URL\\".", ], + Array [ + "🚫 - Service \\"BUFFER_LIMIT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/BUFFER_LIMIT\\".", + ], Array [ "🚫 - Service \\"BUFFER_LIMIT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/BUFFER_LIMIT\\".", ], @@ -332,6 +362,9 @@ Object { Array [ "🚫 - Service \\"BUFFER_LIMIT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/BUFFER_LIMIT\\".", ], + Array [ + "🚫 - Service \\"DECODERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/DECODERS\\".", + ], Array [ "🚫 - Service \\"DECODERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/DECODERS\\".", ], @@ -344,6 +377,9 @@ Object { Array [ "🚫 - Service \\"DECODERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/DECODERS\\".", ], + Array [ + "🚫 - Service \\"DEFAULT_ERROR_CODE\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/DEFAULT_ERROR_CODE\\".", + ], Array [ "🚫 - Service \\"DEFAULT_ERROR_CODE\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/DEFAULT_ERROR_CODE\\".", ], @@ -356,6 +392,9 @@ Object { Array [ "🚫 - Service \\"DEFAULT_ERROR_CODE\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/DEFAULT_ERROR_CODE\\".", ], + Array [ + "🚫 - Service \\"DEFAULT_MECHANISM\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/DEFAULT_MECHANISM\\".", + ], Array [ "🚫 - Service \\"DEFAULT_MECHANISM\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/DEFAULT_MECHANISM\\".", ], @@ -368,6 +407,9 @@ Object { Array [ "🚫 - Service \\"DEFAULT_MECHANISM\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/DEFAULT_MECHANISM\\".", ], + Array [ + "🚫 - Service \\"DEV_ACCESS_TOKEN\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/DEV_ACCESS_TOKEN\\".", + ], Array [ "🚫 - Service \\"DEV_ACCESS_TOKEN\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/DEV_ACCESS_TOKEN\\".", ], @@ -380,6 +422,9 @@ Object { Array [ "🚫 - Service \\"DEV_ACCESS_TOKEN\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/DEV_ACCESS_TOKEN\\".", ], + Array [ + "🚫 - Service \\"ENCODERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/ENCODERS\\".", + ], Array [ "🚫 - Service \\"ENCODERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/ENCODERS\\".", ], @@ -392,6 +437,9 @@ Object { Array [ "🚫 - Service \\"ENCODERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/ENCODERS\\".", ], + Array [ + "🚫 - Service \\"IGNORED_FILES_PREFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/IGNORED_FILES_PREFIXES\\".", + ], Array [ "🚫 - Service \\"IGNORED_FILES_PREFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/IGNORED_FILES_PREFIXES\\".", ], @@ -404,6 +452,9 @@ Object { Array [ "🚫 - Service \\"IGNORED_FILES_PREFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/IGNORED_FILES_PREFIXES\\".", ], + Array [ + "🚫 - Service \\"IGNORED_FILES_SUFFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/IGNORED_FILES_SUFFIXES\\".", + ], Array [ "🚫 - Service \\"IGNORED_FILES_SUFFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/IGNORED_FILES_SUFFIXES\\".", ], @@ -416,6 +467,9 @@ Object { Array [ "🚫 - Service \\"IGNORED_FILES_SUFFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/IGNORED_FILES_SUFFIXES\\".", ], + Array [ + "🚫 - Service \\"JWT_SECRET_ENV_NAME\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/JWT_SECRET_ENV_NAME\\".", + ], Array [ "🚫 - Service \\"JWT_SECRET_ENV_NAME\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/JWT_SECRET_ENV_NAME\\".", ], @@ -428,6 +482,9 @@ Object { Array [ "🚫 - Service \\"JWT_SECRET_ENV_NAME\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/JWT_SECRET_ENV_NAME\\".", ], + Array [ + "🚫 - Service \\"KEEP_ALIVE_TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/KEEP_ALIVE_TIMEOUT\\".", + ], Array [ "🚫 - Service \\"KEEP_ALIVE_TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/KEEP_ALIVE_TIMEOUT\\".", ], @@ -440,6 +497,9 @@ Object { Array [ "🚫 - Service \\"KEEP_ALIVE_TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/KEEP_ALIVE_TIMEOUT\\".", ], + Array [ + "🚫 - Service \\"MAX_CLEAR_CHARS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/MAX_CLEAR_CHARS\\".", + ], Array [ "🚫 - Service \\"MAX_CLEAR_CHARS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/MAX_CLEAR_CHARS\\".", ], @@ -452,6 +512,9 @@ Object { Array [ "🚫 - Service \\"MAX_CLEAR_CHARS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/MAX_CLEAR_CHARS\\".", ], + Array [ + "🚫 - Service \\"MAX_CLEAR_RATIO\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/MAX_CLEAR_RATIO\\".", + ], Array [ "🚫 - Service \\"MAX_CLEAR_RATIO\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/MAX_CLEAR_RATIO\\".", ], @@ -464,6 +527,9 @@ Object { Array [ "🚫 - Service \\"MAX_CLEAR_RATIO\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/MAX_CLEAR_RATIO\\".", ], + Array [ + "🚫 - Service \\"MAX_CONNECTIONS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/MAX_CONNECTIONS\\".", + ], Array [ "🚫 - Service \\"MAX_CONNECTIONS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/MAX_CONNECTIONS\\".", ], @@ -476,6 +542,9 @@ Object { Array [ "🚫 - Service \\"MAX_CONNECTIONS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/MAX_CONNECTIONS\\".", ], + Array [ + "🚫 - Service \\"MAX_HEADERS_COUNT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/MAX_HEADERS_COUNT\\".", + ], Array [ "🚫 - Service \\"MAX_HEADERS_COUNT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/MAX_HEADERS_COUNT\\".", ], @@ -488,6 +557,9 @@ Object { Array [ "🚫 - Service \\"MAX_HEADERS_COUNT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/MAX_HEADERS_COUNT\\".", ], + Array [ + "🚫 - Service \\"PARSERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/PARSERS\\".", + ], Array [ "🚫 - Service \\"PARSERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/PARSERS\\".", ], @@ -500,6 +572,9 @@ Object { Array [ "🚫 - Service \\"PARSERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/PARSERS\\".", ], + Array [ + "🚫 - Service \\"PROCESS_ENV\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/PROCESS_ENV\\".", + ], Array [ "🚫 - Service \\"PROCESS_ENV\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/PROCESS_ENV\\".", ], @@ -512,6 +587,9 @@ Object { Array [ "🚫 - Service \\"PROCESS_ENV\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/PROCESS_ENV\\".", ], + Array [ + "🚫 - Service \\"PROCESS_NAME\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/PROCESS_NAME\\".", + ], Array [ "🚫 - Service \\"PROCESS_NAME\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/PROCESS_NAME\\".", ], @@ -524,6 +602,9 @@ Object { Array [ "🚫 - Service \\"PROCESS_NAME\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/PROCESS_NAME\\".", ], + Array [ + "🚫 - Service \\"PROTOCOL\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/PROTOCOL\\".", + ], Array [ "🚫 - Service \\"PROTOCOL\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/PROTOCOL\\".", ], @@ -536,6 +617,9 @@ Object { Array [ "🚫 - Service \\"PROTOCOL\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/PROTOCOL\\".", ], + Array [ + "🚫 - Service \\"REDUCED_FILES_SUFFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/REDUCED_FILES_SUFFIXES\\".", + ], Array [ "🚫 - Service \\"REDUCED_FILES_SUFFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/REDUCED_FILES_SUFFIXES\\".", ], @@ -548,6 +632,9 @@ Object { Array [ "🚫 - Service \\"REDUCED_FILES_SUFFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/REDUCED_FILES_SUFFIXES\\".", ], + Array [ + "🚫 - Service \\"SENSIBLE_HEADERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/SENSIBLE_HEADERS\\".", + ], Array [ "🚫 - Service \\"SENSIBLE_HEADERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/SENSIBLE_HEADERS\\".", ], @@ -560,6 +647,9 @@ Object { Array [ "🚫 - Service \\"SENSIBLE_HEADERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/SENSIBLE_HEADERS\\".", ], + Array [ + "🚫 - Service \\"SENSIBLE_PROPS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/SENSIBLE_PROPS\\".", + ], Array [ "🚫 - Service \\"SENSIBLE_PROPS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/SENSIBLE_PROPS\\".", ], @@ -572,6 +662,9 @@ Object { Array [ "🚫 - Service \\"SENSIBLE_PROPS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/SENSIBLE_PROPS\\".", ], + Array [ + "🚫 - Service \\"SHIELD_CHAR\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/SHIELD_CHAR\\".", + ], Array [ "🚫 - Service \\"SHIELD_CHAR\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/SHIELD_CHAR\\".", ], @@ -584,6 +677,9 @@ Object { Array [ "🚫 - Service \\"SHIELD_CHAR\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/SHIELD_CHAR\\".", ], + Array [ + "🚫 - Service \\"SIGNALS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/SIGNALS\\".", + ], Array [ "🚫 - Service \\"SIGNALS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/SIGNALS\\".", ], @@ -596,6 +692,9 @@ Object { Array [ "🚫 - Service \\"SIGNALS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/SIGNALS\\".", ], + Array [ + "🚫 - Service \\"SOCKET_TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/SOCKET_TIMEOUT\\".", + ], Array [ "🚫 - Service \\"SOCKET_TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/SOCKET_TIMEOUT\\".", ], @@ -608,6 +707,9 @@ Object { Array [ "🚫 - Service \\"SOCKET_TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/SOCKET_TIMEOUT\\".", ], + Array [ + "🚫 - Service \\"STRINGIFYERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/STRINGIFYERS\\".", + ], Array [ "🚫 - Service \\"STRINGIFYERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/STRINGIFYERS\\".", ], @@ -620,6 +722,9 @@ Object { Array [ "🚫 - Service \\"STRINGIFYERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/STRINGIFYERS\\".", ], + Array [ + "🚫 - Service \\"TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/TIMEOUT\\".", + ], Array [ "🚫 - Service \\"TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/TIMEOUT\\".", ], @@ -632,12 +737,21 @@ Object { Array [ "🚫 - Service \\"TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/TIMEOUT\\".", ], + Array [ + "🚫 - Service \\"getPingWrapped\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/handlers/getPing\\".", + ], Array [ "🚫 - Service \\"getPingWrapped\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/handlers/getPing\\".", ], + Array [ + "🚫 - Service \\"getPingWrapped\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cors/dist/handlers/getPing\\".", + ], Array [ "🚫 - Service \\"getPingWrapped\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/getPing\\".", ], + Array [ + "🚫 - Service \\"optionsWithCORSWrapped\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/handlers/optionsWithCORS\\".", + ], Array [ "🚫 - Service \\"optionsWithCORSWrapped\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/handlers/optionsWithCORS\\".", ], @@ -645,7 +759,7 @@ Object { "🚫 - Service \\"optionsWithCORSWrapped\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/optionsWithCORS\\".", ], Array [ - "🚫 - Service \\"optionsWithCORSWrapped\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/handlers/optionsWithCORS\\".", + "🚫 - Service \\"readDir\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/readDir\\".", ], Array [ "🚫 - Service \\"readDir\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/readDir\\".", @@ -659,6 +773,9 @@ Object { Array [ "🚫 - Service \\"readDir\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/readDir\\".", ], + Array [ + "🚫 - Service \\"readFile\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/readFile\\".", + ], Array [ "🚫 - Service \\"readFile\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/readFile\\".", ], @@ -671,6 +788,9 @@ Object { Array [ "🚫 - Service \\"readFile\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/readFile\\".", ], + Array [ + "🚫 - Service \\"uniqueId\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/services/uniqueId\\".", + ], Array [ "🚫 - Service \\"uniqueId\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/uniqueId\\".", ], @@ -722,6 +842,18 @@ Object { Array [ "🛂 - Dynamic import of \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/getTime.ts\\".", ], + Array [ + "🛂 - Dynamic import of \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/handleMessages\\".", + ], + Array [ + "🛂 - Dynamic import of \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/handleMessages.ts\\".", + ], + Array [ + "🛂 - Dynamic import of \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/handleMinutes\\".", + ], + Array [ + "🛂 - Dynamic import of \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/handleMinutes.ts\\".", + ], Array [ "🛂 - Dynamic import of \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/putEcho\\".", ], @@ -788,6 +920,12 @@ Object { Array [ "🛂 - Resolving \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/getTime\\" to \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/getTime.ts\\".", ], + Array [ + "🛂 - Resolving \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/handleMessages\\" to \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/handleMessages.ts\\".", + ], + Array [ + "🛂 - Resolving \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/handleMinutes\\" to \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/handleMinutes.ts\\".", + ], Array [ "🛂 - Resolving \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/putEcho\\" to \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/handlers/putEcho.ts\\".", ], @@ -818,6 +956,9 @@ Object { Array [ "🛂 - Resolving \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/BASE_URL\\" to \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/BASE_URL\\".", ], + Array [ + "🛂 - Resolving \\"@whook/aws-lambda\\" to \\"/home/nfroidure/nfroidure/whook/packages/whook-aws-lambda/dist/index\\".", + ], Array [ "🛂 - Resolving \\"@whook/cli\\" to \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/index\\".", ], diff --git a/packages/whook-example/src/build.test.ts b/packages/whook-example/src/build.test.ts new file mode 100644 index 00000000..02555ecf --- /dev/null +++ b/packages/whook-example/src/build.test.ts @@ -0,0 +1,45 @@ +import { exec } from 'child_process'; + +describe('build should work', () => { + [ + ['getPing', '{}'], + ['getOpenAPI', '{}'], + [ + 'getParameters', + '{ "aHeader": "true", "pathParam1":"4", "pathParam2":"a,b,c,d" }', + ], + ['getTime', '{}'], + ['getDelay', '{ "duration": 1 }'], + ['putEcho', '{"body": { "echo": "YOLO!" }}'], + ].forEach(([operationId, parameters]) => { + it(`with ${operationId} http lambdas`, async () => { + await execCommand( + `npx whook testHTTPLambda --name ${operationId} -- parameters '${parameters}'`, + ); + }); + }); + + it(`with cron lambdas`, async () => { + await execCommand(`npx whook testCronLambda --name handleMinutes`); + }); + + it(`with consumer lambdas`, async () => { + await execCommand( + `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(err); + return; + } + resolve({ stdout, stderr }); + }); + }); +} diff --git a/packages/whook-example/src/build.ts b/packages/whook-example/src/build.ts index c6d0ccfc..3243fb5f 100644 --- a/packages/whook-example/src/build.ts +++ b/packages/whook-example/src/build.ts @@ -1,7 +1,10 @@ import Knifecycle, { constant, alsoInject } from 'knifecycle'; import { initBuildConstants } from '@whook/whook'; import { prepareEnvironment } from '.'; -import YError from 'yerror'; +import { + runBuild as runBaseBuild, + prepareBuildEnvironment as prepareBaseBuildEnvironment, +} from '@whook/aws-lambda'; import type { Dependencies } from 'knifecycle'; // Per convention a Whook server build file must export @@ -12,10 +15,8 @@ import type { Dependencies } from 'knifecycle'; export async function runBuild( innerPrepareEnvironment = prepareBuildEnvironment, ): Promise { - throw new YError('E_NO_BUILD_IMPLEMENTED'); - // Usually, here you call the installed build - // return runBaseBuild(innerPrepareEnvironment); + return runBaseBuild(innerPrepareEnvironment); } // The `prepareBuildEnvironment` create the build @@ -26,7 +27,7 @@ export async function prepareBuildEnvironment< $ = await prepareEnvironment($); // Usually, here you call the installed build env - // $ = await prepareBaseBuildEnvironment($); + $ = await prepareBaseBuildEnvironment($); // The build often need to know were initializers // can be found to create a static build and @@ -37,7 +38,7 @@ export async function prepareBuildEnvironment< apm: '@whook/http-transaction/dist/services/apm', obfuscator: '@whook/http-transaction/dist/services/obfuscator', errorHandler: '@whook/http-router/dist/services/errorHandler', - log: 'common-services/dist/log', + log: '@whook/aws-lambda/dist/services/log', time: 'common-services/dist/time', delay: 'common-services/dist/delay', }), diff --git a/packages/whook-example/src/commands/terraformValues.ts b/packages/whook-example/src/commands/terraformValues.ts new file mode 100644 index 00000000..2f35ae96 --- /dev/null +++ b/packages/whook-example/src/commands/terraformValues.ts @@ -0,0 +1,303 @@ +import { extra, autoService } from 'knifecycle'; +import { identity } from '@whook/whook'; +import { readArgs } from '@whook/cli'; +import { getOpenAPIOperations } from '@whook/http-router'; +import YError from 'yerror'; +import { exec } from 'child_process'; +import crypto from 'crypto'; +import type { WhookCommandArgs, WhookCommandDefinition } from '@whook/cli'; +import type { ENVService, WhookConfig } from '@whook/whook'; +import type { LogService } from 'common-services'; +import type { OpenAPIV3 } from 'openapi-types'; +import type { + WhookAWSLambdaBaseCronConfiguration, + APIOperationConfig, +} from '../config/common/config'; +import type { AuthenticationData } from '../services/authentication'; + +export const definition: WhookCommandDefinition = { + description: 'A command printing lambdas informations for Terraform', + example: `whook terraformValues --type paths`, + arguments: { + type: 'object', + additionalProperties: false, + required: ['type'], + properties: { + type: { + description: 'Type of values to return', + type: 'string', + enum: ['globals', 'envvars', 'paths', 'lambdas', 'lambda'], + }, + pretty: { + description: 'Pretty print JSON values', + type: 'boolean', + }, + lambdaName: { + description: 'Name of the lambda', + type: 'string', + }, + pathsIndex: { + description: 'Index of the paths to retrieve', + type: 'number', + }, + lambdaType: { + description: 'Types of the lambdas to return', + type: 'string', + }, + }, + }, +}; + +export default extra(definition, autoService(initTerraformValuesCommand)); + +async function initTerraformValuesCommand({ + API, + CONFIG, + BASE_PATH, + ENV, + PROXYED_ENV_VARS, + log, + args, + execAsync = _execAsync, +}: { + API: OpenAPIV3.Document; + CONFIG: WhookConfig; + BASE_PATH: string; + ENV: ENVService; + PROXYED_ENV_VARS: string[]; + log: LogService; + args: WhookCommandArgs; + execAsync: typeof _execAsync; +}) { + return async (): Promise => { + const { type, pretty, lambdaName, pathsIndex, lambdaType } = readArgs( + definition.arguments, + args, + ) as { + type: string; + pretty: boolean; + lambdaName: string; + pathsIndex: number; + lambdaType: string; + }; + const allOperations = await getOpenAPIOperations(API); + const configurations = allOperations.map((operation) => { + const whookConfiguration = + operation['x-whook'] || + ({ + type: 'http', + } as APIOperationConfig); + const configuration = { + type: whookConfiguration.type || 'http', + timeout: (whookConfiguration.timeout || 10).toString(), + memory: (whookConfiguration.memory || 128).toString(), + contentHandling: 'CONVERT_TO_TEXT', + description: operation.summary || '', + enabled: whookConfiguration.disabled ? 'false' : 'true', + operationId: operation.operationId, + sourceOperationId: operation.operationId, + suffix: whookConfiguration.suffix || '', + ...Object.keys(whookConfiguration).reduce( + (accConfigurations, key) => ({ + ...accConfigurations, + [key]: whookConfiguration[key].toString(), + }), + {}, + ), + schedule: fixAWSSchedule( + (whookConfiguration as WhookAWSLambdaBaseCronConfiguration).schedule, + ), + }; + const qualifiedOperationId = + (configuration.sourceOperationId || operation.operationId) + + (configuration.suffix || ''); + + return { + qualifiedOperationId, + method: operation.method.toUpperCase(), + path: BASE_PATH + operation.path, + resourceName: buildPartName( + (BASE_PATH + operation.path).split('/').filter(identity), + ), + ...configuration, + }; + }); + + if (type === 'globals') { + const commitHash = await execAsync(`git rev-parse HEAD`); + const commitMessage = ( + await execAsync(`git rev-list --format=%B --max-count=1 HEAD`) + ).split('\n')[1]; + const openapi = JSON.stringify({ + ...API, + servers: [], + paths: configurations + .filter(({ type }) => !type || type === 'http') + .reduce((currentPaths, configuration) => { + return { + ...currentPaths, + [configuration.path]: { + ...(currentPaths[configuration.path] || {}), + [configuration.method.toLowerCase()]: { + ...((API.paths[configuration.path] || {})[ + configuration.method.toLowerCase() + ] || {}), + operationId: configuration.qualifiedOperationId, + responses: {}, + ['x-amazon-apigateway-integration']: { + uri: `\${${configuration.qualifiedOperationId}}`, + httpMethod: 'POST', + contentHandling: 'CONVERT_TO_TEXT', + timeoutInMillis: parseInt(configuration.timeout, 10) * 1000, + type: 'aws_proxy', + }, + }, + }, + }; + }, {}), + }); + + const openapiHash = crypto + .createHash('md5') + .update(JSON.stringify(API)) + .digest('hex'); + const infos = { + apiDomain: new URL(CONFIG.baseURL).hostname, + commitHash, + commitMessage, + openapi, + openapiHash, + }; + log('info', JSON.stringify(infos)); + return; + } + + if (type === 'envvars') { + const env = PROXYED_ENV_VARS.reduce( + (finalEnv, key) => ({ ...finalEnv, [key]: ENV[key] }), + {}, + ); + log('info', JSON.stringify(env)); + return; + } + + if (type === 'lambdas') { + const lambdas = configurations + .filter((configuration) => + lambdaType ? configuration.type === lambdaType : true, + ) + .reduce( + (accLambdas, configuration) => ({ + ...accLambdas, + [configuration.qualifiedOperationId]: + configuration.resourceName + + '|' + + (configuration.path.split('/').filter(identity).length - 1), + }), + {}, + ); + + log('info', `${JSON.stringify(lambdas, null, pretty ? 2 : 0)}`); + return; + } + + if (type === 'paths') { + if (typeof pathsIndex !== 'number') { + throw new YError('E_PATHS_INDEX_REQUIRED'); + } + const allPathParts = configurations.reduce( + (accAllPathParts, configuration) => { + const parts = configuration.path.split('/').filter(identity); + + return parts.reduce((accPathParts, part, index) => { + const partName = buildPartName(parts.slice(0, index + 1)); + const parentName = + 0 < index ? buildPartName(parts.slice(0, index)) : '__root'; + + return [ + ...accPathParts, + { + partName, + parentName, + part, + index, + }, + ]; + }, accAllPathParts); + }, + [], + ); + const allPathPartsForIndex = allPathParts + .filter(({ index }) => pathsIndex === index) + .reduce( + (accAllPathPartsForIndex, { partName, parentName, part }) => ({ + ...accAllPathPartsForIndex, + [partName]: parentName + '|' + part, + }), + {}, + ); + + log( + 'info', + `${JSON.stringify(allPathPartsForIndex, null, pretty ? 2 : 0)}`, + ); + return; + } + + if (!lambdaName) { + throw new YError('E_LAMBDA_NAME_REQUIRED'); + } + + const lambdaConfiguration = configurations.find( + ({ qualifiedOperationId }) => qualifiedOperationId === lambdaName, + ); + + log('info', `${JSON.stringify(lambdaConfiguration, null, pretty ? 2 : 0)}`); + }; +} + +function buildPartName(parts: string[]): string { + return parts + .map((aPart, anIndex) => { + const realPartName = aPart.replace(/[{}]/g, ''); + + return anIndex + ? realPartName[0].toUpperCase() + realPartName.slice(1) + : realPartName; + }) + .join(''); +} + +function fixAWSSchedule(schedule: string): string { + if (typeof schedule === 'undefined') { + return ''; + } + + // The last wildcard is for years. + // This is a non-standard AWS addition... + // Also, we have to put a `?` in either + // day(month) or day(week) to fit AWS + // way of building cron tabs... + const fields = schedule.split(' '); + + if ('*' === fields[4]) { + fields[4] = '?'; + } else if ('*' === fields[2]) { + fields[2] = '?'; + } else { + throw new YError('E_BAD_AWS_SCHEDULE', schedule); + } + return `cron(${fields.concat('*').join(' ')})`; +} + +async function _execAsync(command: string): Promise { + return await new Promise((resolve, reject) => { + exec(command, (err: Error, stdout: string, stderr: string) => { + if (err) { + reject(YError.wrap(err, 'E_EXEC_FAILURE', stderr)); + return; + } + resolve(stdout.trim()); + }); + }); +} diff --git a/packages/whook-example/src/config/common/config.ts b/packages/whook-example/src/config/common/config.ts index fb401a80..91363211 100644 --- a/packages/whook-example/src/config/common/config.ts +++ b/packages/whook-example/src/config/common/config.ts @@ -5,7 +5,13 @@ import type { WhookSwaggerUIConfig, } from '@whook/swagger-ui'; import type { WhookAPIOperationCORSConfig, WhookCORSConfig } from '@whook/cors'; -import type { WhookAPIHandlerDefinition, WhookConfigs } from '@whook/whook'; +import type { + WhookAPIHandlerDefinition, + WhookConfigs, + ProxyedENVConfig, + WhookAPIOperationConfig, + WhookCompilerConfig, +} from '@whook/whook'; import type { APIConfig } from '../../services/API'; import type { JWTServiceConfig } from 'jwt-service'; @@ -20,12 +26,68 @@ export type AppConfigs = WhookConfigs & WhookSwaggerUIConfig & WhookCORSConfig & APIConfig & + WhookCompilerConfig & + ProxyedENVConfig & JWTServiceConfig; // Export custom handlers definitions -export type APIHandlerDefinition = WhookAPIHandlerDefinition< - WhookAPIOperationCORSConfig & WhookAPIOperationSwaggerConfig +export type WhookAWSLambdaBaseBuildConfiguration< + T = Record +> = { + private?: boolean; + memory?: number; + timeout?: number; + suffix?: string; + sourceOperationId?: string; +} & T; +export type WhookAWSLambdaBaseHTTPConfiguration = { + type: 'http'; +}; +export type WhookAWSLambdaBaseCronConfiguration = { + type: 'cron'; + enabled: boolean; + schedule: string; +}; +export type WhookAWSLambdaBaseConsumerConfiguration = { + type: 'consumer'; + enabled: boolean; +}; +export type WhookAWSLambdaBaseTransformerConfiguration = { + type: 'transformer'; + enabled: boolean; +}; +export type WhookAWSLambdaBaseKafkaConsumerConfiguration = { + type: 'kafka'; + enabled: boolean; +}; +export type WhookAWSLambdaBaseLogSubscriberConfiguration = { + type: 'log'; + enabled: boolean; +}; +export type WhookAWSLambdaBaseS3Configuration = { + type: 's3'; + enabled: boolean; +}; +export type WhookAWSLambdaBuildConfiguration< + T = Record +> = WhookAWSLambdaBaseBuildConfiguration< + T & + ( + | WhookAWSLambdaBaseHTTPConfiguration + | WhookAWSLambdaBaseCronConfiguration + | WhookAWSLambdaBaseConsumerConfiguration + | WhookAWSLambdaBaseTransformerConfiguration + | WhookAWSLambdaBaseKafkaConsumerConfiguration + | WhookAWSLambdaBaseLogSubscriberConfiguration + | WhookAWSLambdaBaseS3Configuration + ) +>; +export type APIOperationConfig = WhookAWSLambdaBuildConfiguration< + WhookAPIOperationSwaggerConfig & + WhookAPIOperationCORSConfig & + WhookAPIOperationConfig >; +export type APIHandlerDefinition = WhookAPIHandlerDefinition; const CONFIG: AppConfigs = { BASE_ENV: {}, @@ -35,9 +97,11 @@ const CONFIG: AppConfigs = { CONFIG: { name: packageConf.name, description: packageConf.description || '', + baseURL: 'https://api.example.com', }, NODE_ENVS, DEBUG_NODE_ENVS: process.env.DEBUG ? NODE_ENVS : DEBUG_NODE_ENVS, + PROXYED_ENV_VARS: ['NODE_ENV', 'JWT_SECRET'], SERVICE_NAME_MAP: {}, ERRORS_DESCRIPTORS: { ...DEFAULT_ERRORS_DESCRIPTORS, diff --git a/packages/whook-example/src/handlers/handleMessages.ts b/packages/whook-example/src/handlers/handleMessages.ts new file mode 100644 index 00000000..be7e8113 --- /dev/null +++ b/packages/whook-example/src/handlers/handleMessages.ts @@ -0,0 +1,41 @@ +import { autoHandler } from 'knifecycle'; +import type { WhookResponse } from '@whook/whook'; +import type { LogService } from 'common-services'; +import type { APIHandlerDefinition } from '../config/common/config'; + +export const definition = { + path: '/consumer/messages', + method: 'post', + operation: { + operationId: 'handleMessages', + summary: 'Handle queue messages.', + tags: ['system'], + 'x-whook': { + type: 'consumer', + private: true, + disabled: false, + }, + responses: { + 200: { + description: 'Batch handled', + }, + }, + }, +}; + +async function handleMessages( + { log }: { log: LogService }, + { + body, + }: { + body: any; + }, +): Promise> { + log('info', `Received a message ${JSON.stringify(body)} messages.`); + + return { + status: 200, + }; +} + +export default autoHandler(handleMessages); diff --git a/packages/whook-example/src/handlers/handleMinutes.ts b/packages/whook-example/src/handlers/handleMinutes.ts new file mode 100644 index 00000000..0639688d --- /dev/null +++ b/packages/whook-example/src/handlers/handleMinutes.ts @@ -0,0 +1,42 @@ +import { autoHandler } from 'knifecycle'; +import type { WhookResponse } from '@whook/whook'; +import type { LogService } from 'common-services'; +import type { APIHandlerDefinition } from '../config/common/config'; + +export const definition: APIHandlerDefinition = { + path: '/cron/minutes', + method: 'post', + operation: { + operationId: 'handleMinutes', + summary: 'Executes every minutes.', + tags: ['system'], + 'x-whook': { + type: 'cron', + enabled: true, + private: true, + schedule: '*/1 * * * *', + }, + responses: { + 200: { + description: 'Cron executed', + }, + }, + }, +}; + +async function handleMinutes( + { log }: { log: LogService }, + { + date, + }: { + date: string; + }, +): Promise> { + log('info', `Ran the cron at ${date}.`); + + return { + status: 200, + }; +} + +export default autoHandler(handleMinutes); diff --git a/packages/whook-example/src/index.ts b/packages/whook-example/src/index.ts index 0d4e6152..974ee604 100644 --- a/packages/whook-example/src/index.ts +++ b/packages/whook-example/src/index.ts @@ -78,7 +78,12 @@ export async function prepareEnvironment>( // Setup your own whook plugins or avoid whook defaults by leaving it empty $.register( - constant('WHOOK_PLUGINS', ['@whook/cli', '@whook/whook', '@whook/cors']), + constant('WHOOK_PLUGINS', [ + '@whook/aws-lambda', + '@whook/cli', + '@whook/cors', + '@whook/whook', + ]), ); return $; diff --git a/packages/whook-example/src/services/__snapshots__/API.test.ts.snap b/packages/whook-example/src/services/__snapshots__/API.test.ts.snap index a7912c52..74f2c5da 100644 --- a/packages/whook-example/src/services/__snapshots__/API.test.ts.snap +++ b/packages/whook-example/src/services/__snapshots__/API.test.ts.snap @@ -34,6 +34,8 @@ Array [ "options /ping", "options /time", "options /{pathParam1}/{pathParam2}", + "post /consumer/messages", + "post /cron/minutes", "put /echo", ] `; @@ -139,6 +141,45 @@ Object { }, "openapi": "3.0.2", "paths": Object { + "/consumer/messages": Object { + "post": Object { + "operationId": "handleMessages", + "responses": Object { + "200": Object { + "description": "Batch handled", + }, + }, + "summary": "Handle queue messages.", + "tags": Array [ + "system", + ], + "x-whook": Object { + "disabled": false, + "private": true, + "type": "consumer", + }, + }, + }, + "/cron/minutes": Object { + "post": Object { + "operationId": "handleMinutes", + "responses": Object { + "200": Object { + "description": "Cron executed", + }, + }, + "summary": "Executes every minutes.", + "tags": Array [ + "system", + ], + "x-whook": Object { + "disabled": false, + "private": true, + "schedule": "*/1 * * * *", + "type": "cron", + }, + }, + }, "/delay": Object { "get": Object { "operationId": "getDelay", diff --git a/packages/whook-example/terraform/.terraform.lock.hcl b/packages/whook-example/terraform/.terraform.lock.hcl new file mode 100755 index 00000000..89776b44 --- /dev/null +++ b/packages/whook-example/terraform/.terraform.lock.hcl @@ -0,0 +1,76 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/archive" { + version = "2.1.0" + constraints = "~> 2.1" + hashes = [ + "h1:f3WXKM/FBu5EMY6j2BGt982hzVMNicrxTyEAz5EsrOU=", + "zh:033279ecbf60f565303222e9a6d26b50fdebe43aa1c6e8f565f09bb64d67c3fd", + "zh:0af998e42eb421c92e87202df5bfee436b3cfe553214394f08d786c72a9e3f70", + "zh:1183b661c692f38409a61eefb5d412167c246fcd9e49d4d61d6d910012d206ba", + "zh:5febb66f4a8207117f71dcd460fb9c81d3afb7b600b5e598cf517cf6e27cf4b2", + "zh:66135ce46d29d0ccf0e3b6a119423754ca334dbf4266bc989cce5b0b667b5fde", + "zh:6b9dc1a4f0a680bb650a7191784927f99675a8c8dd3c155ba821185f630db604", + "zh:91e249482c016ecf6bf8b83849964005cd2d0b4396688419cd1752809b46b23e", + "zh:a6a2e5f2f010c511e66174cb84ea18899e8bcfc1354c4b9fed972fdb131ffffc", + "zh:bb1f6abc76552a883732caff897ff7b07a91977a9b4bb97915f6aac54116bb65", + "zh:f05a9a63607f85719fde705f58d82ee16fa67f9158a5c3424c0216507631eddf", + "zh:fc603a05a06814387ffa4a054d1baee8ea6b5ab32c53cb73e90a5bf9a2616777", + ] +} + +provider "registry.terraform.io/hashicorp/aws" { + version = "3.30.0" + constraints = "~> 3.30" + hashes = [ + "h1:z9kdXY2A/+dIZrPy9hNlg/B5I/AuETQsp0jz9EgprIQ=", + "zh:01f562a6a31fe46a8ca74804f360e3452b26f71abc549ce1f0ab5a8af2484cdf", + "zh:25bacc5ed725051f0ab1f7d575e45c901e5b8e1d50da4156a31dda92b2b7e481", + "zh:349b79979d9169db614d8ebd1bc2e0caeb7a38dc816e261b8b2b4b5204615519", + "zh:5e41446acc54c6fc15e82c3fa14b72174b30eba81e0711ede297e5620c55a628", + "zh:68ad98f6d612bdc35a65d48950abc8e75c69decb49db28258ce8eeb5458586b7", + "zh:704603d65e8bac17d203b57c2db142c3134a91076e1b4a31c40f75eb3257dde8", + "zh:a362c700032b2db047d16007d52f28b3f216d32671b6b355d23bdaa082c66a4b", + "zh:bd197797b41268de3c93cad02b7c655dc0c4d8661abb37544ca049e6b1eccae6", + "zh:deb12ef0e3396a71d485977ddc14b695775f7937097ebf2b2f53ed348a4365e7", + "zh:ec8a7d0f02738f290107d39bf401d68ddce82a95cd9d998003f7e04b3a196411", + "zh:ffcc43b6c5e7f26c55e2a8c539d7370fca8042722400a3e06bdce4240bd7088a", + ] +} + +provider "registry.terraform.io/hashicorp/external" { + version = "2.1.0" + hashes = [ + "h1:wbtDfLeawmv6xVT1W0w0fctRCb4ABlaD3JTxwb1jXag=", + "zh:0d83ffb72fbd08986378204a7373d8c43b127049096eaf2765bfdd6b00ad9853", + "zh:7577d6edc67b1e8c2cf62fe6501192df1231d74125d90e51d570d586d95269c5", + "zh:9c669ded5d5affa4b2544952c4b6588dfed55260147d24ced02dca3a2829f328", + "zh:a404d46f2831f90633947ab5d57e19dbfe35b3704104ba6ec80bcf50b058acfd", + "zh:ae1caea1c936d459ceadf287bb5c5bd67b5e2a7819df6f5c4114b7305df7f822", + "zh:afb4f805477694a4b9dde86b268d2c0821711c8aab1c6088f5f992228c4c06fb", + "zh:b993b4a1de8a462643e78f4786789e44ce5064b332fee1cb0d6250ed085561b8", + "zh:c84b2c13fa3ea2c0aa7291243006d560ce480a5591294b9001ce3742fc9c5791", + "zh:c8966f69b7eccccb771704fd5335923692eccc9e0e90cb95d14538fe2e92a3b8", + "zh:d5fe68850d449b811e633a300b114d0617df6d450305e8251643b4d143dc855b", + "zh:ddebfd1e674ba336df09b1f27bbaa0e036c25b7a7087dc8081443f6e5954028b", + ] +} + +provider "registry.terraform.io/hashicorp/template" { + version = "2.2.0" + constraints = "~> 2.2.0" + hashes = [ + "h1:94qn780bi1qjrbC3uQtjJh3Wkfwd5+tTtJHOb7KTg9w=", + "zh:01702196f0a0492ec07917db7aaa595843d8f171dc195f4c988d2ffca2a06386", + "zh:09aae3da826ba3d7df69efeb25d146a1de0d03e951d35019a0f80e4f58c89b53", + "zh:09ba83c0625b6fe0a954da6fbd0c355ac0b7f07f86c91a2a97849140fea49603", + "zh:0e3a6c8e16f17f19010accd0844187d524580d9fdb0731f675ffcf4afba03d16", + "zh:45f2c594b6f2f34ea663704cc72048b212fe7d16fb4cfd959365fa997228a776", + "zh:77ea3e5a0446784d77114b5e851c970a3dde1e08fa6de38210b8385d7605d451", + "zh:8a154388f3708e3df5a69122a23bdfaf760a523788a5081976b3d5616f7d30ae", + "zh:992843002f2db5a11e626b3fc23dc0c87ad3729b3b3cff08e32ffb3df97edbde", + "zh:ad906f4cebd3ec5e43d5cd6dc8f4c5c9cc3b33d2243c89c5fc18f97f7277b51d", + "zh:c979425ddb256511137ecd093e23283234da0154b7fa8b21c2687182d9aea8b2", + ] +} diff --git a/packages/whook-example/terraform/api_gateway.tf b/packages/whook-example/terraform/api_gateway.tf new file mode 100644 index 00000000..23a7c879 --- /dev/null +++ b/packages/whook-example/terraform/api_gateway.tf @@ -0,0 +1,79 @@ +# imports the globals +data "external" "globals" { + program = ["env", "NODE_ENV=${terraform.workspace}", "npx", "whook", "terraformValues", "--type='globals'"] + working_dir = ".." +} + +resource "aws_internet_gateway" "api_gateway" { + tags = { + Name = "Whook API ${terraform.workspace}" + } +} + +data "template_file" "template_file" { + template = data.external.globals.result["openapi"] + + vars = zipmap( + keys(data.external.api_lambdas.result), + [for key in keys(data.external.api_lambdas.result) : aws_lambda_function.lambda_function[key].invoke_arn] + ) +} + + +resource "aws_api_gateway_rest_api" "api_gateway_rest_api" { + name = "Whook API (${terraform.workspace})" + description = "An Whook API on the AWS Lambda platform" + minimum_compression_size = 1024 + binary_media_types = [ + "image/png", + "image/*", + "image/apng", + "image/webp", + "application/pdf" + ] + body = data.template_file.template_file.rendered + endpoint_configuration { + types = ["REGIONAL"] + } + depends_on = [aws_lambda_function.lambda_function] +} + +resource "aws_api_gateway_deployment" "api_gateway_deployment" { + rest_api_id = aws_api_gateway_rest_api.api_gateway_rest_api.id + # This has to be left empty to let api_gateway_stage + # manage the stage options + stage_name = "" + stage_description = "Deployment checksums ${data.external.globals.result["openapiHash"]}-${data.external.globals.result["commitHash"]}" + description = data.external.globals.result["commitMessage"] + depends_on = [aws_api_gateway_rest_api.api_gateway_rest_api] + + lifecycle { + create_before_destroy = true + } +} + +resource "aws_api_gateway_stage" "api_gateway_stage" { + stage_name = terraform.workspace + rest_api_id = aws_api_gateway_rest_api.api_gateway_rest_api.id + deployment_id = aws_api_gateway_deployment.api_gateway_deployment.id + cache_cluster_enabled = true + cache_cluster_size = 0.5 + xray_tracing_enabled = true +} + +# You may want to add a custom domain that way +# resource "aws_api_gateway_domain_name" "api_gateway_domain_name" { +# domain_name = data.external.globals.result["domain"] +# regional_certificate_arn = aws_acm_certificate.acm_certificate.arn +# endpoint_configuration { +# types = ["REGIONAL"] +# } +# security_policy = "TLS_1_0" +# } + +# resource "aws_api_gateway_base_path_mapping" "api_gateway_base_path_mapping" { +# api_id = aws_api_gateway_rest_api.api_gateway_rest_api.id +# stage_name = aws_api_gateway_stage.api_gateway_stage.stage_name +# domain_name = aws_api_gateway_domain_name.api_gateway_domain_name.domain_name +# base_path = "" +# } diff --git a/packages/whook-example/terraform/api_lambdas.tf b/packages/whook-example/terraform/api_lambdas.tf new file mode 100644 index 00000000..a59c5cc3 --- /dev/null +++ b/packages/whook-example/terraform/api_lambdas.tf @@ -0,0 +1,13 @@ +# imports the cron lambda list +data "external" "api_lambdas" { + program = ["env", "NODE_ENV=${terraform.workspace}", "npx", "whook", "terraformValues", "--type='lambdas'", "--lambdaType='http'"] + working_dir = ".." +} + +resource "aws_lambda_permission" "lambdas" { + for_each = data.external.api_lambdas.result + statement_id = "AllowExecutionFromAPIGateway" + action = "lambda:InvokeFunction" + function_name = aws_lambda_function.lambda_function[each.key].arn + principal = "apigateway.amazonaws.com" +} diff --git a/packages/whook-example/terraform/api_responses.tf b/packages/whook-example/terraform/api_responses.tf new file mode 100644 index 00000000..82fd33ab --- /dev/null +++ b/packages/whook-example/terraform/api_responses.tf @@ -0,0 +1,399 @@ +# The purpose of this file is to make all AWS +# errors look like the Whook's ones + +resource "aws_api_gateway_gateway_response" "access_denied" { + rest_api_id = aws_api_gateway_rest_api.api_gateway_rest_api.id + status_code = "403" + response_type = "ACCESS_DENIED" + response_templates = { + "application/json" = <