From 4c537fe5cd748c60154bb95934cd1b8a5bfb7607 Mon Sep 17 00:00:00 2001 From: Nicolas Froidure Date: Mon, 30 Mar 2020 10:06:55 +0200 Subject: [PATCH] feat(@whook/example): add Google Cloud Functions build --- .../__snapshots__/createWhook.test.ts.snap | 8 +- .../src/services/createWhook.test.ts | 18 +- packages/whook-example/README.md | 51 ++++ packages/whook-example/package.json | 6 +- .../src/__snapshots__/cli.test.ts.snap | 13 +- .../src/__snapshots__/index.test.ts.snap | 106 ++++++- packages/whook-example/src/build.test.ts | 35 +++ packages/whook-example/src/build.ts | 13 +- .../src/commands/terraformValues.ts | 258 ++++++++++++++++++ .../whook-example/src/config/common/config.ts | 17 +- .../whook-example/src/config/test/config.ts | 4 + packages/whook-example/src/index.ts | 7 +- packages/whook-example/terraform/functions.tf | 53 ++++ packages/whook-example/terraform/main.tf | 67 +++++ 14 files changed, 629 insertions(+), 27 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/terraform/functions.tf create mode 100644 packages/whook-example/terraform/main.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 26cd9403..bc435f0e 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\\",\\"architecture\\":\\"jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md\\",\\"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\\",\\"whook-repl\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- bin/repl.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.1\\",\\"http-auth-utils\\":\\"^3.0.1\\",\\"jwt-service\\":\\"^7.1.3\\",\\"knifecycle\\":\\"^11.1.1\\",\\"strict-qs\\":\\"^6.1.4\\",\\"type-fest\\":\\"^2.3.3\\",\\"yerror\\":\\"^6.0.1\\",\\"yhttperror\\":\\"^6.0.1\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.13.14\\",\\"@babel/core\\":\\"^7.13.15\\",\\"@babel/eslint-parser\\":\\"^7.13.14\\",\\"@babel/node\\":\\"^7.13.13\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.13.0\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.13.8\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.13.15\\",\\"@babel/preset-typescript\\":\\"^7.13.0\\",\\"@babel/register\\":\\"^7.13.14\\",\\"@types/jest\\":\\"^26.0.22\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.21.0\\",\\"@typescript-eslint/parser\\":\\"^4.21.0\\",\\"axios\\":\\"^0.21.4\\",\\"babel-plugin-knifecycle\\":\\"^5.0.1\\",\\"chokidar\\":\\"^3.5.1\\",\\"eslint\\":\\"^7.23.0\\",\\"eslint-plugin-prettier\\":\\"^3.3.1\\",\\"jest\\":\\"^26.6.3\\",\\"jsarch\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^8.0.0\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.2.1\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.1\\",\\"typescript\\":\\"^4.2.4\\"},\\"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\\",\\"architecture\\":\\"jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md\\",\\"build\\":\\"npm run compile && npm run types && 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\\",\\"whook-repl\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- bin/repl.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/gcp-functions\\":\\"^8.4.2\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^9.0.1\\",\\"http-auth-utils\\":\\"^3.0.1\\",\\"jwt-service\\":\\"^7.1.3\\",\\"knifecycle\\":\\"^11.1.1\\",\\"js-yaml\\":\\"^3.13.1\\",\\"strict-qs\\":\\"^6.1.4\\",\\"type-fest\\":\\"^2.3.3\\",\\"yerror\\":\\"^6.0.1\\",\\"yhttperror\\":\\"^6.0.1\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.13.14\\",\\"@babel/core\\":\\"^7.13.15\\",\\"@babel/eslint-parser\\":\\"^7.13.14\\",\\"@babel/node\\":\\"^7.13.13\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.13.0\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.13.8\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.13.15\\",\\"@babel/preset-typescript\\":\\"^7.13.0\\",\\"@babel/register\\":\\"^7.13.14\\",\\"@types/jest\\":\\"^26.0.22\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.21.0\\",\\"@typescript-eslint/parser\\":\\"^4.21.0\\",\\"axios\\":\\"^0.21.4\\",\\"babel-plugin-knifecycle\\":\\"^5.0.1\\",\\"chokidar\\":\\"^3.5.1\\",\\"eslint\\":\\"^7.23.0\\",\\"eslint-plugin-prettier\\":\\"^3.3.1\\",\\"jest\\":\\"^26.6.3\\",\\"jsarch\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^8.0.0\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.2.1\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.1\\",\\"typescript\\":\\"^4.2.4\\"},\\"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\\"}}", ], 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\\",\\"architecture\\":\\"jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md\\",\\"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\\",\\"whook-repl\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- bin/repl.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.1\\",\\"http-auth-utils\\":\\"^3.0.1\\",\\"jwt-service\\":\\"^7.1.3\\",\\"knifecycle\\":\\"^11.1.1\\",\\"strict-qs\\":\\"^6.1.4\\",\\"type-fest\\":\\"^2.3.3\\",\\"yerror\\":\\"^6.0.1\\",\\"yhttperror\\":\\"^6.0.1\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.13.14\\",\\"@babel/core\\":\\"^7.13.15\\",\\"@babel/eslint-parser\\":\\"^7.13.14\\",\\"@babel/node\\":\\"^7.13.13\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.13.0\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.13.8\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.13.15\\",\\"@babel/preset-typescript\\":\\"^7.13.0\\",\\"@babel/register\\":\\"^7.13.14\\",\\"@types/jest\\":\\"^26.0.22\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.21.0\\",\\"@typescript-eslint/parser\\":\\"^4.21.0\\",\\"axios\\":\\"^0.21.4\\",\\"babel-plugin-knifecycle\\":\\"^5.0.1\\",\\"chokidar\\":\\"^3.5.1\\",\\"eslint\\":\\"^7.23.0\\",\\"eslint-plugin-prettier\\":\\"^3.3.1\\",\\"jest\\":\\"^26.6.3\\",\\"jsarch\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^8.0.0\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.2.1\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.1\\",\\"typescript\\":\\"^4.2.4\\"},\\"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\\",\\"architecture\\":\\"jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md\\",\\"build\\":\\"npm run compile && npm run types && 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\\",\\"whook-repl\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- bin/repl.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/gcp-functions\\":\\"^8.4.2\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^9.0.1\\",\\"http-auth-utils\\":\\"^3.0.1\\",\\"jwt-service\\":\\"^7.1.3\\",\\"knifecycle\\":\\"^11.1.1\\",\\"js-yaml\\":\\"^3.13.1\\",\\"strict-qs\\":\\"^6.1.4\\",\\"type-fest\\":\\"^2.3.3\\",\\"yerror\\":\\"^6.0.1\\",\\"yhttperror\\":\\"^6.0.1\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.13.14\\",\\"@babel/core\\":\\"^7.13.15\\",\\"@babel/eslint-parser\\":\\"^7.13.14\\",\\"@babel/node\\":\\"^7.13.13\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.13.0\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.13.8\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.13.15\\",\\"@babel/preset-typescript\\":\\"^7.13.0\\",\\"@babel/register\\":\\"^7.13.14\\",\\"@types/jest\\":\\"^26.0.22\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.21.0\\",\\"@typescript-eslint/parser\\":\\"^4.21.0\\",\\"axios\\":\\"^0.21.4\\",\\"babel-plugin-knifecycle\\":\\"^5.0.1\\",\\"chokidar\\":\\"^3.5.1\\",\\"eslint\\":\\"^7.23.0\\",\\"eslint-plugin-prettier\\":\\"^3.3.1\\",\\"jest\\":\\"^26.6.3\\",\\"jsarch\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^8.0.0\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.2.1\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.1\\",\\"typescript\\":\\"^4.2.4\\"},\\"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\\"}}", ], 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\\",\\"architecture\\":\\"jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md\\",\\"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\\",\\"whook-repl\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- bin/repl.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.1\\",\\"http-auth-utils\\":\\"^3.0.1\\",\\"jwt-service\\":\\"^7.1.3\\",\\"knifecycle\\":\\"^11.1.1\\",\\"strict-qs\\":\\"^6.1.4\\",\\"type-fest\\":\\"^2.3.3\\",\\"yerror\\":\\"^6.0.1\\",\\"yhttperror\\":\\"^6.0.1\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.13.14\\",\\"@babel/core\\":\\"^7.13.15\\",\\"@babel/eslint-parser\\":\\"^7.13.14\\",\\"@babel/node\\":\\"^7.13.13\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.13.0\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.13.8\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.13.15\\",\\"@babel/preset-typescript\\":\\"^7.13.0\\",\\"@babel/register\\":\\"^7.13.14\\",\\"@types/jest\\":\\"^26.0.22\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.21.0\\",\\"@typescript-eslint/parser\\":\\"^4.21.0\\",\\"axios\\":\\"^0.21.4\\",\\"babel-plugin-knifecycle\\":\\"^5.0.1\\",\\"chokidar\\":\\"^3.5.1\\",\\"eslint\\":\\"^7.23.0\\",\\"eslint-plugin-prettier\\":\\"^3.3.1\\",\\"jest\\":\\"^26.6.3\\",\\"jsarch\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^8.0.0\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.2.1\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.1\\",\\"typescript\\":\\"^4.2.4\\"},\\"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\\",\\"architecture\\":\\"jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md\\",\\"build\\":\\"npm run compile && npm run types && 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\\",\\"whook-repl\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- bin/repl.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/gcp-functions\\":\\"^8.4.2\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^9.0.1\\",\\"http-auth-utils\\":\\"^3.0.1\\",\\"jwt-service\\":\\"^7.1.3\\",\\"knifecycle\\":\\"^11.1.1\\",\\"js-yaml\\":\\"^3.13.1\\",\\"strict-qs\\":\\"^6.1.4\\",\\"type-fest\\":\\"^2.3.3\\",\\"yerror\\":\\"^6.0.1\\",\\"yhttperror\\":\\"^6.0.1\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.13.14\\",\\"@babel/core\\":\\"^7.13.15\\",\\"@babel/eslint-parser\\":\\"^7.13.14\\",\\"@babel/node\\":\\"^7.13.13\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.13.0\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.13.8\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.13.15\\",\\"@babel/preset-typescript\\":\\"^7.13.0\\",\\"@babel/register\\":\\"^7.13.14\\",\\"@types/jest\\":\\"^26.0.22\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.21.0\\",\\"@typescript-eslint/parser\\":\\"^4.21.0\\",\\"axios\\":\\"^0.21.4\\",\\"babel-plugin-knifecycle\\":\\"^5.0.1\\",\\"chokidar\\":\\"^3.5.1\\",\\"eslint\\":\\"^7.23.0\\",\\"eslint-plugin-prettier\\":\\"^3.3.1\\",\\"jest\\":\\"^26.6.3\\",\\"jsarch\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^8.0.0\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.2.1\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.1\\",\\"typescript\\":\\"^4.2.4\\"},\\"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\\"}}", ], 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\\",\\"architecture\\":\\"jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md\\",\\"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\\",\\"whook-repl\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- bin/repl.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.1\\",\\"http-auth-utils\\":\\"^3.0.1\\",\\"jwt-service\\":\\"^7.1.3\\",\\"knifecycle\\":\\"^11.1.1\\",\\"strict-qs\\":\\"^6.1.4\\",\\"type-fest\\":\\"^2.3.3\\",\\"yerror\\":\\"^6.0.1\\",\\"yhttperror\\":\\"^6.0.1\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.13.14\\",\\"@babel/core\\":\\"^7.13.15\\",\\"@babel/eslint-parser\\":\\"^7.13.14\\",\\"@babel/node\\":\\"^7.13.13\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.13.0\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.13.8\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.13.15\\",\\"@babel/preset-typescript\\":\\"^7.13.0\\",\\"@babel/register\\":\\"^7.13.14\\",\\"@types/jest\\":\\"^26.0.22\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.21.0\\",\\"@typescript-eslint/parser\\":\\"^4.21.0\\",\\"axios\\":\\"^0.21.4\\",\\"babel-plugin-knifecycle\\":\\"^5.0.1\\",\\"chokidar\\":\\"^3.5.1\\",\\"eslint\\":\\"^7.23.0\\",\\"eslint-plugin-prettier\\":\\"^3.3.1\\",\\"jest\\":\\"^26.6.3\\",\\"jsarch\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^8.0.0\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.2.1\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.1\\",\\"typescript\\":\\"^4.2.4\\"},\\"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\\",\\"architecture\\":\\"jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md\\",\\"build\\":\\"npm run compile && npm run types && 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\\",\\"whook-repl\\":\\"PROJECT_SRC=\\\\\\"$PWD/src\\\\\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- bin/repl.js\\"},\\"files\\":[\\"bin\\",\\"dist\\",\\"src\\",\\"LICENSE\\",\\"README.md\\",\\"CHANGELOG.md\\"],\\"dependencies\\":{\\"@whook/authorization\\":\\"\\",\\"@whook/cli\\":\\"\\",\\"@whook/cors\\":\\"\\",\\"@whook/gcp-functions\\":\\"^8.4.2\\",\\"@whook/http-router\\":\\"\\",\\"@whook/http-transaction\\":\\"\\",\\"@whook/swagger-ui\\":\\"\\",\\"@whook/whook\\":\\"\\",\\"common-services\\":\\"^9.0.1\\",\\"http-auth-utils\\":\\"^3.0.1\\",\\"jwt-service\\":\\"^7.1.3\\",\\"knifecycle\\":\\"^11.1.1\\",\\"js-yaml\\":\\"^3.13.1\\",\\"strict-qs\\":\\"^6.1.4\\",\\"type-fest\\":\\"^2.3.3\\",\\"yerror\\":\\"^6.0.1\\",\\"yhttperror\\":\\"^6.0.1\\"},\\"devDependencies\\":{\\"@babel/cli\\":\\"^7.13.14\\",\\"@babel/core\\":\\"^7.13.15\\",\\"@babel/eslint-parser\\":\\"^7.13.14\\",\\"@babel/node\\":\\"^7.13.13\\",\\"@babel/plugin-proposal-class-properties\\":\\"^7.13.0\\",\\"@babel/plugin-proposal-object-rest-spread\\":\\"^7.13.8\\",\\"@babel/plugin-syntax-dynamic-import\\":\\"^7.8.3\\",\\"@babel/plugin-syntax-import-meta\\":\\"^7.10.4\\",\\"@babel/preset-env\\":\\"^7.13.15\\",\\"@babel/preset-typescript\\":\\"^7.13.0\\",\\"@babel/register\\":\\"^7.13.14\\",\\"@types/jest\\":\\"^26.0.22\\",\\"@typescript-eslint/eslint-plugin\\":\\"^4.21.0\\",\\"@typescript-eslint/parser\\":\\"^4.21.0\\",\\"axios\\":\\"^0.21.4\\",\\"babel-plugin-knifecycle\\":\\"^5.0.1\\",\\"chokidar\\":\\"^3.5.1\\",\\"eslint\\":\\"^7.23.0\\",\\"eslint-plugin-prettier\\":\\"^3.3.1\\",\\"jest\\":\\"^26.6.3\\",\\"jsarch\\":\\"^4.0.1\\",\\"openapi-schema-validator\\":\\"^8.0.0\\",\\"parse-gitignore\\":\\"^1.0.1\\",\\"prettier\\":\\"^2.2.1\\",\\"rimraf\\":\\"^3.0.2\\",\\"schema2dts\\":\\"^2.0.1\\",\\"typescript\\":\\"^4.2.4\\"},\\"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\\"}}", ], 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 054851f3..4f9ffa6b 100644 --- a/packages/whook-create/src/services/createWhook.test.ts +++ b/packages/whook-create/src/services/createWhook.test.ts @@ -186,12 +186,14 @@ Mr Bean "@whook/authorization": "", "@whook/cli": "", "@whook/cors": "", + "@whook/gcp-functions": "^8.4.2", "@whook/http-router": "", "@whook/http-transaction": "", "@whook/swagger-ui": "", "@whook/whook": "", "common-services": "^9.0.1", "http-auth-utils": "^3.0.1", + "js-yaml": "^3.13.1", "jwt-service": "^7.1.3", "knifecycle": "^11.1.1", "strict-qs": "^6.1.4", @@ -299,7 +301,7 @@ Mr Bean "scripts": Object { "apitypes": "npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts", "architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md", - "build": "npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build", + "build": "npm run compile && npm run types && 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", @@ -310,7 +312,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", @@ -444,12 +446,14 @@ Mr Bean "@whook/authorization": "", "@whook/cli": "", "@whook/cors": "", + "@whook/gcp-functions": "^8.4.2", "@whook/http-router": "", "@whook/http-transaction": "", "@whook/swagger-ui": "", "@whook/whook": "", "common-services": "^9.0.1", "http-auth-utils": "^3.0.1", + "js-yaml": "^3.13.1", "jwt-service": "^7.1.3", "knifecycle": "^11.1.1", "strict-qs": "^6.1.4", @@ -557,7 +561,7 @@ Mr Bean "scripts": Object { "apitypes": "npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts", "architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md", - "build": "npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build", + "build": "npm run compile && npm run types && 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", @@ -568,7 +572,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", @@ -687,12 +691,14 @@ Mr Bean "@whook/authorization": "", "@whook/cli": "", "@whook/cors": "", + "@whook/gcp-functions": "^8.4.2", "@whook/http-router": "", "@whook/http-transaction": "", "@whook/swagger-ui": "", "@whook/whook": "", "common-services": "^9.0.1", "http-auth-utils": "^3.0.1", + "js-yaml": "^3.13.1", "jwt-service": "^7.1.3", "knifecycle": "^11.1.1", "strict-qs": "^6.1.4", @@ -800,7 +806,7 @@ Mr Bean "scripts": Object { "apitypes": "npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts", "architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md", - "build": "npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build", + "build": "npm run compile && npm run types && 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", @@ -811,7 +817,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 65cd23fd..dad92be2 100644 --- a/packages/whook-example/README.md +++ b/packages/whook-example/README.md @@ -93,6 +93,57 @@ Debug `knifecycle` internals (dependency injection issues): DEBUG=knifecycle npm run dev ``` +## Deploying with Google Cloud Functions + +Create a project and save its credentials to `.credentials.json`. + +Then install Terraform: +```sh +wget https://releases.hashicorp.com/terraform/0.12.24/terraform_0.12.24_linux_amd64.zip +mkdir .bin +unzip -d .bin terraform_0.12.24_linux_amd64.zip +rm terraform_0.12.24_linux_amd64.zip +``` + +Then initialize the Terraform configuration: +```sh +.bin/terraform init ./terraform; +``` + +Create a new workspace: +```sh +.bin/terraform workspace new staging +``` + +Build the functions: +```sh +NODE_ENV=staging npm run build +``` + +Build the Whook commands Terraform depends on: +```sh +npm run compile +``` + +Plan the deployment: +```sh +.bin/terraform plan -var="project_id=my-project-1664" \ + -out=terraform.plan terraform +``` + +Apply changes: +```sh +# parallelism may be necessary to avoid hitting +# timeouts with a slow connection +.bin/terraform apply -parallelism=1 terraform.plan +``` + +Finally retrieve the API URL and enjoy! +```sh +.bin/terraform -var="project_id=my-project-1664" \ + output api_url +``` + [//]: # (::contents:end) # Authors diff --git a/packages/whook-example/package.json b/packages/whook-example/package.json index 9014b035..f2e05d69 100644 --- a/packages/whook-example/package.json +++ b/packages/whook-example/package.json @@ -45,7 +45,7 @@ "scripts": { "apitypes": "npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts", "architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md", - "build": "npm run compile && NODE_ENV=${NODE_ENV:-development} node bin/build", + "build": "npm run compile && npm run types && NODE_ENV=${NODE_ENV:-development} node bin/build", "cli": "env NODE_ENV=${NODE_ENV:-cli}", "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", @@ -58,7 +58,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", @@ -83,6 +83,7 @@ "@whook/authorization": "^8.4.2", "@whook/cli": "^8.4.2", "@whook/cors": "^8.4.2", + "@whook/gcp-functions": "^8.4.2", "@whook/http-router": "^8.4.2", "@whook/http-transaction": "^8.3.0", "@whook/swagger-ui": "^8.4.2", @@ -91,6 +92,7 @@ "http-auth-utils": "^3.0.1", "jwt-service": "^7.1.3", "knifecycle": "^11.1.1", + "js-yaml": "^3.13.1", "strict-qs": "^6.1.4", "type-fest": "^2.3.3", "yerror": "^6.0.1", diff --git a/packages/whook-example/src/__snapshots__/cli.test.ts.snap b/packages/whook-example/src/__snapshots__/cli.test.ts.snap index c3204d66..c454cae7 100644 --- a/packages/whook-example/src/__snapshots__/cli.test.ts.snap +++ b/packages/whook-example/src/__snapshots__/cli.test.ts.snap @@ -28,10 +28,18 @@ 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 functions informations for Terraform + + +# Provided by \\"@whook/gcp-functions\\": 1 commands +- testHTTPLambda: A command for testing AWS HTTP lambda + + +# Provided by \\"@whook/cors\\": none # Provided by \\"@whook/cli\\": 6 commands @@ -44,9 +52,6 @@ Object { # Provided by \\"@whook/whook\\": none - - -# Provided by \\"@whook/cors\\": none ", } `; diff --git a/packages/whook-example/src/__snapshots__/index.test.ts.snap b/packages/whook-example/src/__snapshots__/index.test.ts.snap index 380cf286..bfd2ac5c 100644 --- a/packages/whook-example/src/__snapshots__/index.test.ts.snap +++ b/packages/whook-example/src/__snapshots__/index.test.ts.snap @@ -167,6 +167,9 @@ Object { Array [ "➰ - Plugin \\"@whook/cors\\" resolved to \\"/home/nfroidure/nfroidure/whook/packages/whook-cors/dist\\".", ], + Array [ + "➰ - Plugin \\"@whook/gcp-functions\\" resolved to \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist\\".", + ], Array [ "➰ - Plugin \\"@whook/whook\\" resolved to \\"/home/nfroidure/nfroidure/whook/packages/whook/dist\\".", ], @@ -326,9 +329,15 @@ Object { 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 \\"BASE_URL\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/BASE_URL\\".", + ], Array [ "🚫 - Service \\"BUFFER_LIMIT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/BUFFER_LIMIT\\".", ], @@ -338,6 +347,9 @@ Object { Array [ "🚫 - Service \\"BUFFER_LIMIT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/BUFFER_LIMIT\\".", ], + Array [ + "🚫 - Service \\"BUFFER_LIMIT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/BUFFER_LIMIT\\".", + ], Array [ "🚫 - Service \\"BUFFER_LIMIT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/BUFFER_LIMIT\\".", ], @@ -350,6 +362,9 @@ Object { Array [ "🚫 - Service \\"DECODERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/DECODERS\\".", ], + Array [ + "🚫 - Service \\"DECODERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/DECODERS\\".", + ], Array [ "🚫 - Service \\"DECODERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/DECODERS\\".", ], @@ -362,6 +377,9 @@ Object { Array [ "🚫 - Service \\"DEFAULT_ERROR_CODE\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/DEFAULT_ERROR_CODE\\".", ], + Array [ + "🚫 - Service \\"DEFAULT_ERROR_CODE\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/DEFAULT_ERROR_CODE\\".", + ], Array [ "🚫 - Service \\"DEFAULT_ERROR_CODE\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/DEFAULT_ERROR_CODE\\".", ], @@ -374,6 +392,9 @@ Object { Array [ "🚫 - Service \\"DEFAULT_MECHANISM\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/DEFAULT_MECHANISM\\".", ], + Array [ + "🚫 - Service \\"DEFAULT_MECHANISM\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/DEFAULT_MECHANISM\\".", + ], Array [ "🚫 - Service \\"DEFAULT_MECHANISM\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/DEFAULT_MECHANISM\\".", ], @@ -386,6 +407,9 @@ Object { Array [ "🚫 - Service \\"DEV_ACCESS_TOKEN\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/DEV_ACCESS_TOKEN\\".", ], + Array [ + "🚫 - Service \\"DEV_ACCESS_TOKEN\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/DEV_ACCESS_TOKEN\\".", + ], Array [ "🚫 - Service \\"DEV_ACCESS_TOKEN\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/DEV_ACCESS_TOKEN\\".", ], @@ -398,6 +422,9 @@ Object { Array [ "🚫 - Service \\"ENCODERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/ENCODERS\\".", ], + Array [ + "🚫 - Service \\"ENCODERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/ENCODERS\\".", + ], Array [ "🚫 - Service \\"ENCODERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/ENCODERS\\".", ], @@ -410,6 +437,9 @@ Object { Array [ "🚫 - Service \\"IGNORED_FILES_PREFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/IGNORED_FILES_PREFIXES\\".", ], + Array [ + "🚫 - Service \\"IGNORED_FILES_PREFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/IGNORED_FILES_PREFIXES\\".", + ], Array [ "🚫 - Service \\"IGNORED_FILES_PREFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/IGNORED_FILES_PREFIXES\\".", ], @@ -422,6 +452,9 @@ Object { Array [ "🚫 - Service \\"IGNORED_FILES_SUFFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/IGNORED_FILES_SUFFIXES\\".", ], + Array [ + "🚫 - Service \\"IGNORED_FILES_SUFFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/IGNORED_FILES_SUFFIXES\\".", + ], Array [ "🚫 - Service \\"IGNORED_FILES_SUFFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/IGNORED_FILES_SUFFIXES\\".", ], @@ -434,6 +467,9 @@ Object { Array [ "🚫 - Service \\"JWT_SECRET_ENV_NAME\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/JWT_SECRET_ENV_NAME\\".", ], + Array [ + "🚫 - Service \\"JWT_SECRET_ENV_NAME\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/JWT_SECRET_ENV_NAME\\".", + ], Array [ "🚫 - Service \\"JWT_SECRET_ENV_NAME\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/JWT_SECRET_ENV_NAME\\".", ], @@ -446,6 +482,9 @@ Object { Array [ "🚫 - Service \\"KEEP_ALIVE_TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/KEEP_ALIVE_TIMEOUT\\".", ], + Array [ + "🚫 - Service \\"KEEP_ALIVE_TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/KEEP_ALIVE_TIMEOUT\\".", + ], Array [ "🚫 - Service \\"KEEP_ALIVE_TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/KEEP_ALIVE_TIMEOUT\\".", ], @@ -458,6 +497,9 @@ Object { Array [ "🚫 - Service \\"MAX_CLEAR_CHARS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/MAX_CLEAR_CHARS\\".", ], + Array [ + "🚫 - Service \\"MAX_CLEAR_CHARS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/MAX_CLEAR_CHARS\\".", + ], Array [ "🚫 - Service \\"MAX_CLEAR_CHARS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/MAX_CLEAR_CHARS\\".", ], @@ -470,6 +512,9 @@ Object { Array [ "🚫 - Service \\"MAX_CLEAR_RATIO\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/MAX_CLEAR_RATIO\\".", ], + Array [ + "🚫 - Service \\"MAX_CLEAR_RATIO\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/MAX_CLEAR_RATIO\\".", + ], Array [ "🚫 - Service \\"MAX_CLEAR_RATIO\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/MAX_CLEAR_RATIO\\".", ], @@ -482,6 +527,9 @@ Object { Array [ "🚫 - Service \\"MAX_CONNECTIONS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/MAX_CONNECTIONS\\".", ], + Array [ + "🚫 - Service \\"MAX_CONNECTIONS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/MAX_CONNECTIONS\\".", + ], Array [ "🚫 - Service \\"MAX_CONNECTIONS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/MAX_CONNECTIONS\\".", ], @@ -494,6 +542,9 @@ Object { Array [ "🚫 - Service \\"MAX_HEADERS_COUNT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/MAX_HEADERS_COUNT\\".", ], + Array [ + "🚫 - Service \\"MAX_HEADERS_COUNT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/MAX_HEADERS_COUNT\\".", + ], Array [ "🚫 - Service \\"MAX_HEADERS_COUNT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/MAX_HEADERS_COUNT\\".", ], @@ -506,6 +557,9 @@ Object { Array [ "🚫 - Service \\"PARSERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/PARSERS\\".", ], + Array [ + "🚫 - Service \\"PARSERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/PARSERS\\".", + ], Array [ "🚫 - Service \\"PARSERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/PARSERS\\".", ], @@ -518,6 +572,9 @@ Object { Array [ "🚫 - Service \\"PROCESS_ENV\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/PROCESS_ENV\\".", ], + Array [ + "🚫 - Service \\"PROCESS_ENV\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/PROCESS_ENV\\".", + ], Array [ "🚫 - Service \\"PROCESS_ENV\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/PROCESS_ENV\\".", ], @@ -530,6 +587,9 @@ Object { Array [ "🚫 - Service \\"PROCESS_NAME\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/PROCESS_NAME\\".", ], + Array [ + "🚫 - Service \\"PROCESS_NAME\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/PROCESS_NAME\\".", + ], Array [ "🚫 - Service \\"PROCESS_NAME\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/PROCESS_NAME\\".", ], @@ -542,6 +602,9 @@ Object { Array [ "🚫 - Service \\"PROTOCOL\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/PROTOCOL\\".", ], + Array [ + "🚫 - Service \\"PROTOCOL\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/PROTOCOL\\".", + ], Array [ "🚫 - Service \\"PROTOCOL\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/PROTOCOL\\".", ], @@ -554,6 +617,9 @@ Object { Array [ "🚫 - Service \\"REDUCED_FILES_SUFFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/REDUCED_FILES_SUFFIXES\\".", ], + Array [ + "🚫 - Service \\"REDUCED_FILES_SUFFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/REDUCED_FILES_SUFFIXES\\".", + ], Array [ "🚫 - Service \\"REDUCED_FILES_SUFFIXES\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/REDUCED_FILES_SUFFIXES\\".", ], @@ -566,6 +632,9 @@ Object { Array [ "🚫 - Service \\"SENSIBLE_HEADERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/SENSIBLE_HEADERS\\".", ], + Array [ + "🚫 - Service \\"SENSIBLE_HEADERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/SENSIBLE_HEADERS\\".", + ], Array [ "🚫 - Service \\"SENSIBLE_HEADERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/SENSIBLE_HEADERS\\".", ], @@ -578,6 +647,9 @@ Object { Array [ "🚫 - Service \\"SENSIBLE_PROPS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/SENSIBLE_PROPS\\".", ], + Array [ + "🚫 - Service \\"SENSIBLE_PROPS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/SENSIBLE_PROPS\\".", + ], Array [ "🚫 - Service \\"SENSIBLE_PROPS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/SENSIBLE_PROPS\\".", ], @@ -590,6 +662,9 @@ Object { Array [ "🚫 - Service \\"SHIELD_CHAR\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/SHIELD_CHAR\\".", ], + Array [ + "🚫 - Service \\"SHIELD_CHAR\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/SHIELD_CHAR\\".", + ], Array [ "🚫 - Service \\"SHIELD_CHAR\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/SHIELD_CHAR\\".", ], @@ -602,6 +677,9 @@ Object { Array [ "🚫 - Service \\"SIGNALS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/SIGNALS\\".", ], + Array [ + "🚫 - Service \\"SIGNALS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/SIGNALS\\".", + ], Array [ "🚫 - Service \\"SIGNALS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/SIGNALS\\".", ], @@ -614,6 +692,9 @@ Object { Array [ "🚫 - Service \\"SOCKET_TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/SOCKET_TIMEOUT\\".", ], + Array [ + "🚫 - Service \\"SOCKET_TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/SOCKET_TIMEOUT\\".", + ], Array [ "🚫 - Service \\"SOCKET_TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/SOCKET_TIMEOUT\\".", ], @@ -626,6 +707,9 @@ Object { Array [ "🚫 - Service \\"STRINGIFYERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/STRINGIFYERS\\".", ], + Array [ + "🚫 - Service \\"STRINGIFYERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/STRINGIFYERS\\".", + ], Array [ "🚫 - Service \\"STRINGIFYERS\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/STRINGIFYERS\\".", ], @@ -638,23 +722,29 @@ Object { Array [ "🚫 - Service \\"TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/TIMEOUT\\".", ], + Array [ + "🚫 - Service \\"TIMEOUT\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/TIMEOUT\\".", + ], 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-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-cli/dist/handlers/optionsWithCORS\\".", + "🚫 - Service \\"getPingWrapped\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/handlers/getPing\\".", ], Array [ "🚫 - 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 \\"optionsWithCORSWrapped\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/handlers/optionsWithCORS\\".", ], Array [ "🚫 - Service \\"readDir\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-cli/dist/services/readDir\\".", @@ -665,6 +755,9 @@ Object { Array [ "🚫 - Service \\"readDir\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/readDir\\".", ], + Array [ + "🚫 - Service \\"readDir\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/readDir\\".", + ], Array [ "🚫 - Service \\"readDir\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/readDir\\".", ], @@ -677,6 +770,9 @@ Object { Array [ "🚫 - Service \\"readFile\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/readFile\\".", ], + Array [ + "🚫 - Service \\"readFile\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/readFile\\".", + ], Array [ "🚫 - Service \\"readFile\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/readFile\\".", ], @@ -689,6 +785,9 @@ Object { Array [ "🚫 - Service \\"uniqueId\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-example/src/services/uniqueId\\".", ], + Array [ + "🚫 - Service \\"uniqueId\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/services/uniqueId\\".", + ], Array [ "🚫 - Service \\"uniqueId\\" not found in \\"/home/nfroidure/nfroidure/whook/packages/whook/dist/services/uniqueId\\".", ], @@ -833,6 +932,9 @@ Object { Array [ "🛂 - Resolving \\"@whook/cors\\" to \\"/home/nfroidure/nfroidure/whook/packages/whook-cors/dist/index\\".", ], + Array [ + "🛂 - Resolving \\"@whook/gcp-functions\\" to \\"/home/nfroidure/nfroidure/whook/packages/whook-gcp-functions/dist/index\\".", + ], Array [ "🛂 - Resolving \\"@whook/whook\\" to \\"/home/nfroidure/nfroidure/whook/packages/whook/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..0899aff1 --- /dev/null +++ b/packages/whook-example/src/build.test.ts @@ -0,0 +1,35 @@ +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( + `JWT_SECRET=test npx whook testHTTPFunction --name ${operationId} --parameters '${parameters}'`, + ); + }); + }); +}); + +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 275c36bc..67557af7 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/gcp-functions'; 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/gcp-functions/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..d860c342 --- /dev/null +++ b/packages/whook-example/src/commands/terraformValues.ts @@ -0,0 +1,258 @@ +import { extra, autoService } from 'knifecycle'; +import { readArgs } from '@whook/cli'; +import { flattenOpenAPI, getOpenAPIOperations } from '@whook/http-router'; +import YError from 'yerror'; +import { exec } from 'child_process'; +import crypto from 'crypto'; +import yaml from 'js-yaml'; +import type { LogService } from 'common-services'; +import type { WhookCommandArgs, WhookCommandDefinition } from '@whook/cli'; +import type { OpenAPIV3 } from 'openapi-types'; + +export type WhookGoogleFunctionsBaseBuildConfiguration = { + private?: boolean; + memory?: number; + timeout?: number; + suffix?: string; + sourceOperationId?: string; +}; +export type WhookGoogleFunctionsBuildConfiguration = { + type: 'http'; +} & WhookGoogleFunctionsBaseBuildConfiguration; + +export const definition: WhookCommandDefinition = { + description: 'A command printing functions 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', 'paths', 'functions', 'function'], + }, + pretty: { + description: 'Pretty print JSON values', + type: 'boolean', + }, + functionName: { + description: 'Name of the function', + type: 'string', + }, + pathsIndex: { + description: 'Index of the paths to retrieve', + type: 'number', + }, + functionType: { + description: 'Types of the functions to return', + type: 'string', + }, + }, + }, +}; + +export default extra(definition, autoService(initTerraformValuesCommand)); + +async function initTerraformValuesCommand({ + API, + BASE_PATH, + log, + args, + execAsync = _execAsync, +}: { + API: OpenAPIV3.Document; + BASE_PATH: string; + log: LogService; + args: WhookCommandArgs; + execAsync: typeof _execAsync; +}) { + return async () => { + const { type, pretty, functionName, pathsIndex, functionType } = readArgs( + definition.arguments, + args, + ) as { + type: string; + pretty: boolean; + functionName: string; + pathsIndex: number; + functionType: string; + }; + const operations = getOpenAPIOperations(await flattenOpenAPI(API)); + const configurations = operations.map((operation) => { + const whookConfiguration = (operation['x-whook'] || { + type: 'http', + }) as WhookGoogleFunctionsBuildConfiguration; + const configuration = { + type: 'http', + timeout: '10', + memory: '128', + description: operation.summary || '', + enabled: 'true', + sourceOperationId: operation.operationId, + suffix: '', + ...Object.keys(whookConfiguration).reduce( + (accConfigurations, key) => ({ + ...accConfigurations, + [key]: whookConfiguration[key].toString(), + }), + {}, + ), + }; + const qualifiedOperationId = + (configuration.sourceOperationId || operation.operationId) + + (configuration.suffix || ''); + + return { + qualifiedOperationId, + method: operation.method.toUpperCase(), + path: operation.path, + ...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 openapi2 = yaml.safeDump({ + swagger: '2.0', + info: { + title: API.info.title, + description: API.info.description, + version: API.info.version, + }, + host: '${infos_host}', + basePath: BASE_PATH, + schemes: ['https'], + produces: ['application/json'], + paths: configurations.reduce((accPaths, configuration) => { + const operation = operations.find( + ({ operationId }) => + operationId === configuration.sourceOperationId, + ); + + return { + ...accPaths, + [configuration.path]: { + ...(accPaths[configuration.path] || {}), + [configuration.method.toLowerCase()]: { + summary: configuration.description || '', + operationId: configuration.qualifiedOperationId, + ...(operation.parameters.length + ? { + parameters: (operation.parameters as OpenAPIV3.ParameterObject[]).map( + ({ in: theIn, name, required }) => ({ + in: theIn, + name, + type: 'string', + required: required || false, + }), + ), + } + : undefined), + 'x-google-backend': { + address: `\${function_${configuration.qualifiedOperationId}}`, + }, + responses: { + '200': { description: 'x', schema: { type: 'string' } }, + }, + }, + }, + }; + }, {}), + }); + const openapiHash = crypto + .createHash('md5') + .update(JSON.stringify(API)) + .digest('hex'); + const infos = { + commitHash, + commitMessage, + openapi2, + openapiHash, + }; + log('info', JSON.stringify(infos)); + return; + } + + if (type === 'functions') { + const functions = configurations + .filter((configuration) => + functionType ? configuration.type === functionType : true, + ) + .reduce( + (accLambdas, configuration) => ({ + ...accLambdas, + [configuration.qualifiedOperationId]: + configuration.qualifiedOperationId, + }), + {}, + ); + + log('info', `${JSON.stringify(functions, null, pretty ? 2 : 0)}`); + return; + } + + if (!functionName) { + throw new YError('E_FUNCTION_NAME_REQUIRED'); + } + + const functionConfiguration = configurations.find( + ({ qualifiedOperationId }) => qualifiedOperationId === functionName, + ); + + log( + 'info', + `${JSON.stringify(functionConfiguration, 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 53ce722a..9bd1d853 100644 --- a/packages/whook-example/src/config/common/config.ts +++ b/packages/whook-example/src/config/common/config.ts @@ -5,9 +5,14 @@ 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, + WhookCompilerConfig, +} from '@whook/whook'; import type { APIConfig } from '../../services/API'; import type { JWTServiceConfig } from 'jwt-service'; +import type { ProxyedENVConfig } from '@whook/whook'; /* Architecture Note #2: Configuration @@ -33,7 +38,10 @@ export type AppConfigs = WhookConfigs & WhookSwaggerUIConfig & WhookCORSConfig & APIConfig & - JWTServiceConfig; + JWTServiceConfig & + WhookCompilerConfig & + ProxyedENVConfig & + APIConfig; /* Architecture Note #3.2.3: Typings @@ -63,7 +71,12 @@ const CONFIG: AppConfigs = { }, NODE_ENVS, DEBUG_NODE_ENVS: process.env.DEBUG ? NODE_ENVS : DEBUG_NODE_ENVS, + PROXYED_ENV_VARS: ['NODE_ENV', 'JWT_SECRET'], SERVICE_NAME_MAP: {}, + COMPILER_OPTIONS: { + externalModules: ['portfinder', 'internal-ip'], + ignoredModules: ['ecstatic', 'swagger-ui-dist'], + }, ERRORS_DESCRIPTORS: { ...DEFAULT_ERRORS_DESCRIPTORS, E_INVALID_FAKE_TOKEN: { diff --git a/packages/whook-example/src/config/test/config.ts b/packages/whook-example/src/config/test/config.ts index b530f4c4..dc2f0774 100644 --- a/packages/whook-example/src/config/test/config.ts +++ b/packages/whook-example/src/config/test/config.ts @@ -2,6 +2,10 @@ import COMMON_CONFIG from '../common/config'; import type { AppConfigs } from '../common/config'; const CONFIG: AppConfigs = { + BASE_ENV: { + ...COMMON_CONFIG.BASE_ENV, + JWT_SECRET: 'yop', + }, ...COMMON_CONFIG, }; diff --git a/packages/whook-example/src/index.ts b/packages/whook-example/src/index.ts index 4f987def..fb45fe05 100644 --- a/packages/whook-example/src/index.ts +++ b/packages/whook-example/src/index.ts @@ -167,7 +167,12 @@ export async function prepareEnvironment>( You can also avoid Whook defaults by leaving it empty. */ $.register( - constant('WHOOK_PLUGINS', ['@whook/cli', '@whook/whook', '@whook/cors']), + constant('WHOOK_PLUGINS', [ + '@whook/gcp-functions', + '@whook/cors', + '@whook/cli', + '@whook/whook', + ]), ); // Add the CORS wrapped error handler diff --git a/packages/whook-example/terraform/functions.tf b/packages/whook-example/terraform/functions.tf new file mode 100644 index 00000000..c19b9f70 --- /dev/null +++ b/packages/whook-example/terraform/functions.tf @@ -0,0 +1,53 @@ +data "external" "functionConfiguration" { + for_each = data.external.functions.result + + program = ["env", "NODE_ENV=${terraform.workspace}", "npx", "whook", "terraformValues", "--type='function'", "--functionName='${each.key}'"] +} + +resource "google_storage_bucket" "storage_bucket" { + name = "whook_functions" +} + +data "archive_file" "functions" { + for_each = data.external.functions.result + + type = "zip" + source_dir = "./builds/${terraform.workspace}/${each.key}" + output_path = "./builds/${terraform.workspace}/${each.key}.zip" +} + +resource "google_storage_bucket_object" "storage_bucket_object" { + for_each = data.external.functions.result + + name = "${terraform.workspace}_${each.key}" + source = "./builds/${terraform.workspace}/${each.key}.zip" + bucket = google_storage_bucket.storage_bucket.name + depends_on = [data.archive_file.functions] +} + +resource "google_cloudfunctions_function" "cloudfunctions_function" { + for_each = data.external.functions.result + + name = "${terraform.workspace}_${each.key}" + description = data.external.functionConfiguration[each.key].result["description"] + runtime = "nodejs10" + + available_memory_mb = data.external.functionConfiguration[each.key].result["memory"] + timeout = data.external.functionConfiguration[each.key].result["timeout"] + source_archive_bucket = google_storage_bucket.storage_bucket.name + source_archive_object = google_storage_bucket_object.storage_bucket_object[each.key].name + trigger_http = true + entry_point = "default" +} + +# Seems to not work (no idea why) +# resource "google_cloudfunctions_function_iam_member" "invoker" { +# for_each = data.external.functions.result + +# project = google_cloudfunctions_function.cloudfunctions_function[each.key].project +# region = google_cloudfunctions_function.cloudfunctions_function[each.key].region +# cloud_function = google_cloudfunctions_function.cloudfunctions_function[each.key].name + +# role = "roles/cloudfunctions.invoker" +# member = "allUsers" +# } diff --git a/packages/whook-example/terraform/main.tf b/packages/whook-example/terraform/main.tf new file mode 100644 index 00000000..ff7c5946 --- /dev/null +++ b/packages/whook-example/terraform/main.tf @@ -0,0 +1,67 @@ +variable "project_id" { + type = string +} + +variable "region" { + type = string + default = "europe-west1" +} + +variable "zone" { + type = string + default = "europe-west1-b" +} + +variable "api_name" { + type = string + default = "api2" +} + +provider "google" { + version = "~> 3.14" + project = var.project_id + region = var.region + zone = var.zone + credentials = file(".credentials.json") +} + +provider "archive" { + version = "~> 1.3" +} + +provider "template" { + version = "~> 2.1.2" +} + +output "api_url" { + value = google_endpoints_service.endpoints_service.dns_address +} + +data "google_project" "project" { + project_id = var.project_id +} + +# imports the functions list +data "external" "functions" { + program = ["env", "NODE_ENV=${terraform.workspace}", "npx", "whook", "terraformValues", "--type='functions'", "--functionType='http'"] +} +data "external" "globals" { + program = ["env", "NODE_ENV=${terraform.workspace}", "npx", "whook", "terraformValues", "--type='globals'"] +} + +data "template_file" "template_file" { + template = data.external.globals.result["openapi2"] + + vars = merge({ + "infos_host" : "${var.api_name}.endpoints.${data.google_project.project.project_id}.cloud.goog" + }, zipmap( + [for key in keys(data.external.functions.result) : "function_${key}"], + [for key in keys(data.external.functions.result) : google_cloudfunctions_function.cloudfunctions_function[key].https_trigger_url] + )) +} + +resource "google_endpoints_service" "endpoints_service" { + service_name = "${var.api_name}.endpoints.${data.google_project.project.project_id}.cloud.goog" + project = data.google_project.project.project_id + openapi_config = data.template_file.template_file.rendered +}