skuba 0.0.0-master-20230318044948
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +67 -0
- package/config/eslint.js +3 -0
- package/config/jest.js +1 -0
- package/config/prettier.d.ts +3 -0
- package/config/prettier.js +5 -0
- package/config/tsconfig.json +9 -0
- package/jest/moduleNameMapper.js +58 -0
- package/jest/moduleNameMapper.test.ts +64 -0
- package/jest/transform.js +50 -0
- package/jest/transform.test.ts +11 -0
- package/jest/tsConfig.js +26 -0
- package/jest-preset.js +34 -0
- package/lib/api/buildkite/annotate.d.ts +26 -0
- package/lib/api/buildkite/annotate.js +49 -0
- package/lib/api/buildkite/annotate.js.map +7 -0
- package/lib/api/buildkite/index.d.ts +3 -0
- package/lib/api/buildkite/index.js +32 -0
- package/lib/api/buildkite/index.js.map +7 -0
- package/lib/api/buildkite/md.d.ts +6 -0
- package/lib/api/buildkite/md.js +33 -0
- package/lib/api/buildkite/md.js.map +7 -0
- package/lib/api/git/commit.d.ts +15 -0
- package/lib/api/git/commit.js +52 -0
- package/lib/api/git/commit.js.map +7 -0
- package/lib/api/git/commitAllChanges.d.ts +19 -0
- package/lib/api/git/commitAllChanges.js +65 -0
- package/lib/api/git/commitAllChanges.js.map +7 -0
- package/lib/api/git/currentBranch.d.ts +10 -0
- package/lib/api/git/currentBranch.js +58 -0
- package/lib/api/git/currentBranch.js.map +7 -0
- package/lib/api/git/getChangedFiles.d.ts +20 -0
- package/lib/api/git/getChangedFiles.js +63 -0
- package/lib/api/git/getChangedFiles.js.map +7 -0
- package/lib/api/git/index.d.ts +10 -0
- package/lib/api/git/index.js +55 -0
- package/lib/api/git/index.js.map +7 -0
- package/lib/api/git/log.d.ts +19 -0
- package/lib/api/git/log.js +71 -0
- package/lib/api/git/log.js.map +7 -0
- package/lib/api/git/pull.d.ts +35 -0
- package/lib/api/git/pull.js +69 -0
- package/lib/api/git/pull.js.map +7 -0
- package/lib/api/git/push.d.ts +43 -0
- package/lib/api/git/push.js +70 -0
- package/lib/api/git/push.js.map +7 -0
- package/lib/api/git/remote.d.ts +20 -0
- package/lib/api/git/remote.js +72 -0
- package/lib/api/git/remote.js.map +7 -0
- package/lib/api/git/reset.d.ts +12 -0
- package/lib/api/git/reset.js +62 -0
- package/lib/api/git/reset.js.map +7 -0
- package/lib/api/git/statusMatrix.d.ts +7 -0
- package/lib/api/git/statusMatrix.js +47 -0
- package/lib/api/git/statusMatrix.js.map +7 -0
- package/lib/api/github/checkRun.d.ts +44 -0
- package/lib/api/github/checkRun.js +81 -0
- package/lib/api/github/checkRun.js.map +7 -0
- package/lib/api/github/environment.d.ts +18 -0
- package/lib/api/github/environment.js +48 -0
- package/lib/api/github/environment.js.map +7 -0
- package/lib/api/github/index.d.ts +7 -0
- package/lib/api/github/index.js +48 -0
- package/lib/api/github/index.js.map +7 -0
- package/lib/api/github/issueComment.d.ts +59 -0
- package/lib/api/github/issueComment.js +83 -0
- package/lib/api/github/issueComment.js.map +7 -0
- package/lib/api/github/pullRequest.d.ts +21 -0
- package/lib/api/github/pullRequest.js +68 -0
- package/lib/api/github/pullRequest.js.map +7 -0
- package/lib/api/github/push.d.ts +79 -0
- package/lib/api/github/push.js +158 -0
- package/lib/api/github/push.js.map +7 -0
- package/lib/api/jest/index.d.ts +144 -0
- package/lib/api/jest/index.js +41 -0
- package/lib/api/jest/index.js.map +7 -0
- package/lib/api/net/compose.d.ts +4 -0
- package/lib/api/net/compose.js +50 -0
- package/lib/api/net/compose.js.map +7 -0
- package/lib/api/net/index.d.ts +1 -0
- package/lib/api/net/index.js +29 -0
- package/lib/api/net/index.js.map +7 -0
- package/lib/api/net/socket.d.ts +5 -0
- package/lib/api/net/socket.js +68 -0
- package/lib/api/net/socket.js.map +7 -0
- package/lib/api/net/waitFor.d.ts +22 -0
- package/lib/api/net/waitFor.js +40 -0
- package/lib/api/net/waitFor.js.map +7 -0
- package/lib/cli/adapter/eslint.d.ts +14 -0
- package/lib/cli/adapter/eslint.js +112 -0
- package/lib/cli/adapter/eslint.js.map +7 -0
- package/lib/cli/adapter/prettier.d.ts +45 -0
- package/lib/cli/adapter/prettier.js +171 -0
- package/lib/cli/adapter/prettier.js.map +7 -0
- package/lib/cli/build/args.d.ts +7 -0
- package/lib/cli/build/args.js +73 -0
- package/lib/cli/build/args.js.map +7 -0
- package/lib/cli/build/esbuild.d.ts +5 -0
- package/lib/cli/build/esbuild.js +133 -0
- package/lib/cli/build/esbuild.js.map +7 -0
- package/lib/cli/build/index.d.ts +1 -0
- package/lib/cli/build/index.js +73 -0
- package/lib/cli/build/index.js.map +7 -0
- package/lib/cli/build/tsc.d.ts +1 -0
- package/lib/cli/build/tsc.js +36 -0
- package/lib/cli/build/tsc.js.map +7 -0
- package/lib/cli/buildPackage.d.ts +1 -0
- package/lib/cli/buildPackage.js +56 -0
- package/lib/cli/buildPackage.js.map +7 -0
- package/lib/cli/configure/addEmptyExports.d.ts +6 -0
- package/lib/cli/configure/addEmptyExports.js +76 -0
- package/lib/cli/configure/addEmptyExports.js.map +7 -0
- package/lib/cli/configure/analyseConfiguration.d.ts +9 -0
- package/lib/cli/configure/analyseConfiguration.js +69 -0
- package/lib/cli/configure/analyseConfiguration.js.map +7 -0
- package/lib/cli/configure/analyseDependencies.d.ts +10 -0
- package/lib/cli/configure/analyseDependencies.js +136 -0
- package/lib/cli/configure/analyseDependencies.js.map +7 -0
- package/lib/cli/configure/analysis/diff.d.ts +1 -0
- package/lib/cli/configure/analysis/diff.js +45 -0
- package/lib/cli/configure/analysis/diff.js.map +7 -0
- package/lib/cli/configure/analysis/files.d.ts +1 -0
- package/lib/cli/configure/analysis/files.js +58 -0
- package/lib/cli/configure/analysis/files.js.map +7 -0
- package/lib/cli/configure/analysis/git.d.ts +1 -0
- package/lib/cli/configure/analysis/git.js +54 -0
- package/lib/cli/configure/analysis/git.js.map +7 -0
- package/lib/cli/configure/analysis/package.d.ts +13 -0
- package/lib/cli/configure/analysis/package.js +110 -0
- package/lib/cli/configure/analysis/package.js.map +7 -0
- package/lib/cli/configure/analysis/project.d.ts +3 -0
- package/lib/cli/configure/analysis/project.js +105 -0
- package/lib/cli/configure/analysis/project.js.map +7 -0
- package/lib/cli/configure/dependencies/index.d.ts +5 -0
- package/lib/cli/configure/dependencies/index.js +41 -0
- package/lib/cli/configure/dependencies/index.js.map +7 -0
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.d.ts +2 -0
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +59 -0
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +7 -0
- package/lib/cli/configure/dependencies/seekKoala.d.ts +2 -0
- package/lib/cli/configure/dependencies/seekKoala.js +56 -0
- package/lib/cli/configure/dependencies/seekKoala.js.map +7 -0
- package/lib/cli/configure/dependencies/skuba.d.ts +2 -0
- package/lib/cli/configure/dependencies/skuba.js +52 -0
- package/lib/cli/configure/dependencies/skuba.js.map +7 -0
- package/lib/cli/configure/dependencies/skubaDeps.d.ts +2 -0
- package/lib/cli/configure/dependencies/skubaDeps.js +56 -0
- package/lib/cli/configure/dependencies/skubaDeps.js.map +7 -0
- package/lib/cli/configure/dependencies/skubaDive.d.ts +3 -0
- package/lib/cli/configure/dependencies/skubaDive.js +70 -0
- package/lib/cli/configure/dependencies/skubaDive.js.map +7 -0
- package/lib/cli/configure/ensureTemplateCompletion.d.ts +9 -0
- package/lib/cli/configure/ensureTemplateCompletion.js +77 -0
- package/lib/cli/configure/ensureTemplateCompletion.js.map +7 -0
- package/lib/cli/configure/getEntryPoint.d.ts +11 -0
- package/lib/cli/configure/getEntryPoint.js +70 -0
- package/lib/cli/configure/getEntryPoint.js.map +7 -0
- package/lib/cli/configure/getProjectType.d.ts +9 -0
- package/lib/cli/configure/getProjectType.js +52 -0
- package/lib/cli/configure/getProjectType.js.map +7 -0
- package/lib/cli/configure/index.d.ts +1 -0
- package/lib/cli/configure/index.js +148 -0
- package/lib/cli/configure/index.js.map +7 -0
- package/lib/cli/configure/modules/eslint.d.ts +2 -0
- package/lib/cli/configure/modules/eslint.js +61 -0
- package/lib/cli/configure/modules/eslint.js.map +7 -0
- package/lib/cli/configure/modules/ignore.d.ts +2 -0
- package/lib/cli/configure/modules/ignore.js +40 -0
- package/lib/cli/configure/modules/ignore.js.map +7 -0
- package/lib/cli/configure/modules/index.d.ts +2 -0
- package/lib/cli/configure/modules/index.js +54 -0
- package/lib/cli/configure/modules/index.js.map +7 -0
- package/lib/cli/configure/modules/jest.d.ts +2 -0
- package/lib/cli/configure/modules/jest.js +86 -0
- package/lib/cli/configure/modules/jest.js.map +7 -0
- package/lib/cli/configure/modules/nodemon.d.ts +2 -0
- package/lib/cli/configure/modules/nodemon.js +30 -0
- package/lib/cli/configure/modules/nodemon.js.map +7 -0
- package/lib/cli/configure/modules/package.d.ts +2 -0
- package/lib/cli/configure/modules/package.js +117 -0
- package/lib/cli/configure/modules/package.js.map +7 -0
- package/lib/cli/configure/modules/prettier.d.ts +2 -0
- package/lib/cli/configure/modules/prettier.js +52 -0
- package/lib/cli/configure/modules/prettier.js.map +7 -0
- package/lib/cli/configure/modules/renovate.d.ts +3 -0
- package/lib/cli/configure/modules/renovate.js +69 -0
- package/lib/cli/configure/modules/renovate.js.map +7 -0
- package/lib/cli/configure/modules/serverless.d.ts +2 -0
- package/lib/cli/configure/modules/serverless.js +36 -0
- package/lib/cli/configure/modules/serverless.js.map +7 -0
- package/lib/cli/configure/modules/skubaDive.d.ts +2 -0
- package/lib/cli/configure/modules/skubaDive.js +72 -0
- package/lib/cli/configure/modules/skubaDive.js.map +7 -0
- package/lib/cli/configure/modules/tsconfig.d.ts +2 -0
- package/lib/cli/configure/modules/tsconfig.js +87 -0
- package/lib/cli/configure/modules/tsconfig.js.map +7 -0
- package/lib/cli/configure/modules/tslint.d.ts +2 -0
- package/lib/cli/configure/modules/tslint.js +30 -0
- package/lib/cli/configure/modules/tslint.js.map +7 -0
- package/lib/cli/configure/patchRenovateConfig.d.ts +1 -0
- package/lib/cli/configure/patchRenovateConfig.js +132 -0
- package/lib/cli/configure/patchRenovateConfig.js.map +7 -0
- package/lib/cli/configure/processing/deleteFiles.d.ts +5 -0
- package/lib/cli/configure/processing/deleteFiles.js +31 -0
- package/lib/cli/configure/processing/deleteFiles.js.map +7 -0
- package/lib/cli/configure/processing/ignoreFile.d.ts +8 -0
- package/lib/cli/configure/processing/ignoreFile.js +74 -0
- package/lib/cli/configure/processing/ignoreFile.js.map +7 -0
- package/lib/cli/configure/processing/javascript.d.ts +2 -0
- package/lib/cli/configure/processing/javascript.js +38 -0
- package/lib/cli/configure/processing/javascript.js.map +7 -0
- package/lib/cli/configure/processing/json.d.ts +2 -0
- package/lib/cli/configure/processing/json.js +57 -0
- package/lib/cli/configure/processing/json.js.map +7 -0
- package/lib/cli/configure/processing/loadFiles.d.ts +5 -0
- package/lib/cli/configure/processing/loadFiles.js +31 -0
- package/lib/cli/configure/processing/loadFiles.js.map +7 -0
- package/lib/cli/configure/processing/module.d.ts +10 -0
- package/lib/cli/configure/processing/module.js +39 -0
- package/lib/cli/configure/processing/module.js.map +7 -0
- package/lib/cli/configure/processing/package.d.ts +73 -0
- package/lib/cli/configure/processing/package.js +87 -0
- package/lib/cli/configure/processing/package.js.map +7 -0
- package/lib/cli/configure/processing/prettier.d.ts +4 -0
- package/lib/cli/configure/processing/prettier.js +44 -0
- package/lib/cli/configure/processing/prettier.js.map +7 -0
- package/lib/cli/configure/processing/record.d.ts +11 -0
- package/lib/cli/configure/processing/record.js +65 -0
- package/lib/cli/configure/processing/record.js.map +7 -0
- package/lib/cli/configure/processing/typescript.d.ts +23 -0
- package/lib/cli/configure/processing/typescript.js +197 -0
- package/lib/cli/configure/processing/typescript.js.map +7 -0
- package/lib/cli/configure/refreshIgnoreFiles.d.ts +3 -0
- package/lib/cli/configure/refreshIgnoreFiles.js +78 -0
- package/lib/cli/configure/refreshIgnoreFiles.js.map +7 -0
- package/lib/cli/configure/types.d.ts +26 -0
- package/lib/cli/configure/types.js +17 -0
- package/lib/cli/configure/types.js.map +7 -0
- package/lib/cli/format.d.ts +1 -0
- package/lib/cli/format.js +70 -0
- package/lib/cli/format.js.map +7 -0
- package/lib/cli/help.d.ts +1 -0
- package/lib/cli/help.js +34 -0
- package/lib/cli/help.js.map +7 -0
- package/lib/cli/init/getConfig.d.ts +26 -0
- package/lib/cli/init/getConfig.js +285 -0
- package/lib/cli/init/getConfig.js.map +7 -0
- package/lib/cli/init/git.d.ts +7 -0
- package/lib/cli/init/git.js +82 -0
- package/lib/cli/init/git.js.map +7 -0
- package/lib/cli/init/index.d.ts +1 -0
- package/lib/cli/init/index.js +146 -0
- package/lib/cli/init/index.js.map +7 -0
- package/lib/cli/init/prompts.d.ts +45 -0
- package/lib/cli/init/prompts.js +97 -0
- package/lib/cli/init/prompts.js.map +7 -0
- package/lib/cli/init/types.d.ts +28 -0
- package/lib/cli/init/types.js +65 -0
- package/lib/cli/init/types.js.map +7 -0
- package/lib/cli/init/validation.d.ts +8 -0
- package/lib/cli/init/validation.js +43 -0
- package/lib/cli/init/validation.js.map +7 -0
- package/lib/cli/init/writePackageJson.d.ts +13 -0
- package/lib/cli/init/writePackageJson.js +58 -0
- package/lib/cli/init/writePackageJson.js.map +7 -0
- package/lib/cli/lint/annotate/buildkite/eslint.d.ts +2 -0
- package/lib/cli/lint/annotate/buildkite/eslint.js +40 -0
- package/lib/cli/lint/annotate/buildkite/eslint.js.map +7 -0
- package/lib/cli/lint/annotate/buildkite/index.d.ts +4 -0
- package/lib/cli/lint/annotate/buildkite/index.js +58 -0
- package/lib/cli/lint/annotate/buildkite/index.js.map +7 -0
- package/lib/cli/lint/annotate/buildkite/prettier.d.ts +2 -0
- package/lib/cli/lint/annotate/buildkite/prettier.js +47 -0
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +7 -0
- package/lib/cli/lint/annotate/buildkite/tsc.d.ts +2 -0
- package/lib/cli/lint/annotate/buildkite/tsc.js +45 -0
- package/lib/cli/lint/annotate/buildkite/tsc.js.map +7 -0
- package/lib/cli/lint/annotate/github/eslint.d.ts +3 -0
- package/lib/cli/lint/annotate/github/eslint.js +45 -0
- package/lib/cli/lint/annotate/github/eslint.js.map +7 -0
- package/lib/cli/lint/annotate/github/index.d.ts +4 -0
- package/lib/cli/lint/annotate/github/index.js +63 -0
- package/lib/cli/lint/annotate/github/index.js.map +7 -0
- package/lib/cli/lint/annotate/github/prettier.d.ts +3 -0
- package/lib/cli/lint/annotate/github/prettier.js +39 -0
- package/lib/cli/lint/annotate/github/prettier.js.map +7 -0
- package/lib/cli/lint/annotate/github/tsc.d.ts +3 -0
- package/lib/cli/lint/annotate/github/tsc.js +63 -0
- package/lib/cli/lint/annotate/github/tsc.js.map +7 -0
- package/lib/cli/lint/annotate/index.d.ts +4 -0
- package/lib/cli/lint/annotate/index.js +36 -0
- package/lib/cli/lint/annotate/index.js.map +7 -0
- package/lib/cli/lint/autofix.d.ts +10 -0
- package/lib/cli/lint/autofix.js +189 -0
- package/lib/cli/lint/autofix.js.map +7 -0
- package/lib/cli/lint/eslint.d.ts +4 -0
- package/lib/cli/lint/eslint.js +55 -0
- package/lib/cli/lint/eslint.js.map +7 -0
- package/lib/cli/lint/external.d.ts +10 -0
- package/lib/cli/lint/external.js +120 -0
- package/lib/cli/lint/external.js.map +7 -0
- package/lib/cli/lint/index.d.ts +2 -0
- package/lib/cli/lint/index.js +49 -0
- package/lib/cli/lint/index.js.map +7 -0
- package/lib/cli/lint/internal.d.ts +1 -0
- package/lib/cli/lint/internal.js +64 -0
- package/lib/cli/lint/internal.js.map +7 -0
- package/lib/cli/lint/prettier.d.ts +4 -0
- package/lib/cli/lint/prettier.js +55 -0
- package/lib/cli/lint/prettier.js.map +7 -0
- package/lib/cli/lint/tsc.d.ts +2 -0
- package/lib/cli/lint/tsc.js +58 -0
- package/lib/cli/lint/tsc.js.map +7 -0
- package/lib/cli/lint/types.d.ts +34 -0
- package/lib/cli/lint/types.js +17 -0
- package/lib/cli/lint/types.js.map +7 -0
- package/lib/cli/node.d.ts +1 -0
- package/lib/cli/node.js +77 -0
- package/lib/cli/node.js.map +7 -0
- package/lib/cli/release.d.ts +1 -0
- package/lib/cli/release.js +32 -0
- package/lib/cli/release.js.map +7 -0
- package/lib/cli/start.d.ts +1 -0
- package/lib/cli/start.js +69 -0
- package/lib/cli/start.js.map +7 -0
- package/lib/cli/test/index.d.ts +1 -0
- package/lib/cli/test/index.js +37 -0
- package/lib/cli/test/index.js.map +7 -0
- package/lib/cli/test/reporters/github/annotations.d.ts +9 -0
- package/lib/cli/test/reporters/github/annotations.js +102 -0
- package/lib/cli/test/reporters/github/annotations.js.map +7 -0
- package/lib/cli/test/reporters/github/index.d.ts +5 -0
- package/lib/cli/test/reporters/github/index.js +77 -0
- package/lib/cli/test/reporters/github/index.js.map +7 -0
- package/lib/cli/version.d.ts +1 -0
- package/lib/cli/version.js +34 -0
- package/lib/cli/version.js.map +7 -0
- package/lib/enquirer.d.js +2 -0
- package/lib/enquirer.d.js.map +7 -0
- package/lib/index.d.ts +22 -0
- package/lib/index.js +51 -0
- package/lib/index.js.map +7 -0
- package/lib/skuba.d.ts +11 -0
- package/lib/skuba.js +55 -0
- package/lib/skuba.js.map +7 -0
- package/lib/utils/args.d.ts +43 -0
- package/lib/utils/args.js +114 -0
- package/lib/utils/args.js.map +7 -0
- package/lib/utils/command.d.ts +6 -0
- package/lib/utils/command.js +72 -0
- package/lib/utils/command.js.map +7 -0
- package/lib/utils/copy.d.ts +16 -0
- package/lib/utils/copy.js +100 -0
- package/lib/utils/copy.js.map +7 -0
- package/lib/utils/dir.d.ts +21 -0
- package/lib/utils/dir.js +91 -0
- package/lib/utils/dir.js.map +7 -0
- package/lib/utils/env.d.ts +5 -0
- package/lib/utils/env.js +29 -0
- package/lib/utils/env.js.map +7 -0
- package/lib/utils/error.d.ts +28 -0
- package/lib/utils/error.js +72 -0
- package/lib/utils/error.js.map +7 -0
- package/lib/utils/exec.d.ts +40 -0
- package/lib/utils/exec.js +166 -0
- package/lib/utils/exec.js.map +7 -0
- package/lib/utils/help.d.ts +1 -0
- package/lib/utils/help.js +34 -0
- package/lib/utils/help.js.map +7 -0
- package/lib/utils/logging.d.ts +27 -0
- package/lib/utils/logging.js +60 -0
- package/lib/utils/logging.js.map +7 -0
- package/lib/utils/logo.d.ts +9 -0
- package/lib/utils/logo.js +74 -0
- package/lib/utils/logo.js.map +7 -0
- package/lib/utils/manifest.d.ts +10 -0
- package/lib/utils/manifest.js +77 -0
- package/lib/utils/manifest.js.map +7 -0
- package/lib/utils/port.d.ts +2 -0
- package/lib/utils/port.js +48 -0
- package/lib/utils/port.js.map +7 -0
- package/lib/utils/template.d.ts +37 -0
- package/lib/utils/template.js +116 -0
- package/lib/utils/template.js.map +7 -0
- package/lib/utils/validation.d.ts +6 -0
- package/lib/utils/validation.js +44 -0
- package/lib/utils/validation.js.map +7 -0
- package/lib/utils/version.d.ts +13 -0
- package/lib/utils/version.js +89 -0
- package/lib/utils/version.js.map +7 -0
- package/lib/utils/wait.d.ts +17 -0
- package/lib/utils/wait.js +59 -0
- package/lib/utils/wait.js.map +7 -0
- package/lib/utils/worker.d.ts +20 -0
- package/lib/utils/worker.js +63 -0
- package/lib/utils/worker.js.map +7 -0
- package/lib/wrapper/function-arguments.d.js +2 -0
- package/lib/wrapper/function-arguments.d.js.map +7 -0
- package/lib/wrapper/functionHandler.d.ts +10 -0
- package/lib/wrapper/functionHandler.js +63 -0
- package/lib/wrapper/functionHandler.js.map +7 -0
- package/lib/wrapper/http.d.ts +20 -0
- package/lib/wrapper/http.js +79 -0
- package/lib/wrapper/http.js.map +7 -0
- package/lib/wrapper/index.d.ts +12 -0
- package/lib/wrapper/index.js +16 -0
- package/lib/wrapper/index.js.map +7 -0
- package/lib/wrapper/main.d.ts +1 -0
- package/lib/wrapper/main.js +47 -0
- package/lib/wrapper/main.js.map +7 -0
- package/lib/wrapper/requestListener.d.ts +11 -0
- package/lib/wrapper/requestListener.js +66 -0
- package/lib/wrapper/requestListener.js.map +7 -0
- package/package.json +167 -0
- package/template/base/.github/CODEOWNERS +5 -0
- package/template/base/.github/renovate.json5 +3 -0
- package/template/base/_.dockerignore +18 -0
- package/template/base/_.eslintignore +14 -0
- package/template/base/_.eslintrc.js +3 -0
- package/template/base/_.gitignore +23 -0
- package/template/base/_.prettierignore +20 -0
- package/template/base/_.prettierrc.js +1 -0
- package/template/base/jest.config.ts +15 -0
- package/template/base/jest.setup.ts +3 -0
- package/template/base/tsconfig.build.json +5 -0
- package/template/base/tsconfig.json +13 -0
- package/template/express-rest-api/.buildkite/pipeline.yml +103 -0
- package/template/express-rest-api/.env +1 -0
- package/template/express-rest-api/.gantry/common.yml +20 -0
- package/template/express-rest-api/.gantry/dev.yml +8 -0
- package/template/express-rest-api/.gantry/prod.yml +8 -0
- package/template/express-rest-api/.nvmrc +1 -0
- package/template/express-rest-api/Dockerfile +37 -0
- package/template/express-rest-api/Dockerfile.dev-deps +11 -0
- package/template/express-rest-api/README.md +106 -0
- package/template/express-rest-api/docker-compose.yml +22 -0
- package/template/express-rest-api/gantry.apply.yml +122 -0
- package/template/express-rest-api/gantry.build.yml +15 -0
- package/template/express-rest-api/package.json +30 -0
- package/template/express-rest-api/skuba.template.js +49 -0
- package/template/express-rest-api/src/api/healthCheck.ts +11 -0
- package/template/express-rest-api/src/api/smokeTest.ts +8 -0
- package/template/express-rest-api/src/app.test.ts +9 -0
- package/template/express-rest-api/src/app.ts +14 -0
- package/template/express-rest-api/src/config.ts +57 -0
- package/template/express-rest-api/src/framework/logging.ts +17 -0
- package/template/express-rest-api/src/listen.ts +23 -0
- package/template/express-rest-api/src/register.ts +1 -0
- package/template/greeter/.buildkite/pipeline.yml +37 -0
- package/template/greeter/.nvmrc +1 -0
- package/template/greeter/Dockerfile +11 -0
- package/template/greeter/README.md +96 -0
- package/template/greeter/docker-compose.yml +22 -0
- package/template/greeter/package.json +24 -0
- package/template/greeter/skuba.template.js +16 -0
- package/template/greeter/src/app.test.ts +5 -0
- package/template/greeter/src/app.ts +4 -0
- package/template/koa-rest-api/.buildkite/pipeline.yml +103 -0
- package/template/koa-rest-api/.env +1 -0
- package/template/koa-rest-api/.gantry/common.yml +20 -0
- package/template/koa-rest-api/.gantry/dev.yml +11 -0
- package/template/koa-rest-api/.gantry/prod.yml +11 -0
- package/template/koa-rest-api/.nvmrc +1 -0
- package/template/koa-rest-api/Dockerfile +37 -0
- package/template/koa-rest-api/Dockerfile.dev-deps +11 -0
- package/template/koa-rest-api/README.md +111 -0
- package/template/koa-rest-api/docker-compose.yml +22 -0
- package/template/koa-rest-api/gantry.apply.yml +129 -0
- package/template/koa-rest-api/gantry.build.yml +15 -0
- package/template/koa-rest-api/package.json +47 -0
- package/template/koa-rest-api/skuba.template.js +49 -0
- package/template/koa-rest-api/src/api/healthCheck.ts +13 -0
- package/template/koa-rest-api/src/api/index.ts +10 -0
- package/template/koa-rest-api/src/api/jobs/getJobs.test.ts +9 -0
- package/template/koa-rest-api/src/api/jobs/getJobs.ts +15 -0
- package/template/koa-rest-api/src/api/jobs/index.ts +10 -0
- package/template/koa-rest-api/src/api/jobs/postJob.test.ts +34 -0
- package/template/koa-rest-api/src/api/jobs/postJob.ts +19 -0
- package/template/koa-rest-api/src/api/smokeTest.ts +11 -0
- package/template/koa-rest-api/src/app.test.ts +21 -0
- package/template/koa-rest-api/src/app.ts +8 -0
- package/template/koa-rest-api/src/config.ts +57 -0
- package/template/koa-rest-api/src/framework/logging.ts +25 -0
- package/template/koa-rest-api/src/framework/metrics.ts +11 -0
- package/template/koa-rest-api/src/framework/middleware.ts +3 -0
- package/template/koa-rest-api/src/framework/server.test.ts +260 -0
- package/template/koa-rest-api/src/framework/server.ts +51 -0
- package/template/koa-rest-api/src/framework/validation.test.ts +72 -0
- package/template/koa-rest-api/src/framework/validation.ts +77 -0
- package/template/koa-rest-api/src/listen.ts +24 -0
- package/template/koa-rest-api/src/register.ts +1 -0
- package/template/koa-rest-api/src/storage/jobs.ts +28 -0
- package/template/koa-rest-api/src/testing/logging.ts +16 -0
- package/template/koa-rest-api/src/testing/metrics.ts +29 -0
- package/template/koa-rest-api/src/testing/server.ts +31 -0
- package/template/koa-rest-api/src/testing/types.ts +24 -0
- package/template/koa-rest-api/src/tracing.ts +61 -0
- package/template/koa-rest-api/src/types/jobs.ts +17 -0
- package/template/koa-rest-api/src/types/koa.ts +8 -0
- package/template/lambda-sqs-worker/.buildkite/pipeline.yml +96 -0
- package/template/lambda-sqs-worker/.env +1 -0
- package/template/lambda-sqs-worker/.nvmrc +1 -0
- package/template/lambda-sqs-worker/Dockerfile +12 -0
- package/template/lambda-sqs-worker/README.md +132 -0
- package/template/lambda-sqs-worker/docker-compose.yml +27 -0
- package/template/lambda-sqs-worker/package.json +44 -0
- package/template/lambda-sqs-worker/serverless.yml +202 -0
- package/template/lambda-sqs-worker/skuba.template.js +32 -0
- package/template/lambda-sqs-worker/src/app.test.ts +116 -0
- package/template/lambda-sqs-worker/src/app.ts +52 -0
- package/template/lambda-sqs-worker/src/config.ts +57 -0
- package/template/lambda-sqs-worker/src/framework/handler.test.ts +61 -0
- package/template/lambda-sqs-worker/src/framework/handler.ts +43 -0
- package/template/lambda-sqs-worker/src/framework/logging.ts +27 -0
- package/template/lambda-sqs-worker/src/framework/metrics.ts +14 -0
- package/template/lambda-sqs-worker/src/framework/validation.test.ts +84 -0
- package/template/lambda-sqs-worker/src/framework/validation.ts +10 -0
- package/template/lambda-sqs-worker/src/hooks.ts +96 -0
- package/template/lambda-sqs-worker/src/mapping/jobScorer.ts +19 -0
- package/template/lambda-sqs-worker/src/services/aws.ts +5 -0
- package/template/lambda-sqs-worker/src/services/jobScorer.test.ts +44 -0
- package/template/lambda-sqs-worker/src/services/jobScorer.ts +56 -0
- package/template/lambda-sqs-worker/src/services/pipelineEventSender.test.ts +40 -0
- package/template/lambda-sqs-worker/src/services/pipelineEventSender.ts +33 -0
- package/template/lambda-sqs-worker/src/testing/handler.ts +13 -0
- package/template/lambda-sqs-worker/src/testing/logging.ts +16 -0
- package/template/lambda-sqs-worker/src/testing/services.ts +28 -0
- package/template/lambda-sqs-worker/src/testing/types.ts +33 -0
- package/template/lambda-sqs-worker/src/types/jobScorer.ts +15 -0
- package/template/lambda-sqs-worker/src/types/pipelineEvents.ts +21 -0
- package/template/lambda-sqs-worker/tsconfig.json +13 -0
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +93 -0
- package/template/lambda-sqs-worker-cdk/.nvmrc +1 -0
- package/template/lambda-sqs-worker-cdk/Dockerfile +13 -0
- package/template/lambda-sqs-worker-cdk/cdk.json +25 -0
- package/template/lambda-sqs-worker-cdk/docker-compose.yml +28 -0
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +723 -0
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +34 -0
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +74 -0
- package/template/lambda-sqs-worker-cdk/infra/index.ts +14 -0
- package/template/lambda-sqs-worker-cdk/package.json +30 -0
- package/template/lambda-sqs-worker-cdk/shared/context-types.ts +21 -0
- package/template/lambda-sqs-worker-cdk/skuba.template.js +27 -0
- package/template/lambda-sqs-worker-cdk/src/app.ts +10 -0
- package/template/lambda-sqs-worker-cdk/tsconfig.json +13 -0
- package/template/oss-npm-package/.github/workflows/release.yml +35 -0
- package/template/oss-npm-package/.github/workflows/validate.yml +31 -0
- package/template/oss-npm-package/.nvmrc +1 -0
- package/template/oss-npm-package/LICENSE +21 -0
- package/template/oss-npm-package/README.md +128 -0
- package/template/oss-npm-package/_package.json +41 -0
- package/template/oss-npm-package/skuba.template.js +22 -0
- package/template/oss-npm-package/src/index.test.ts +5 -0
- package/template/oss-npm-package/src/index.ts +7 -0
- package/template/oss-npm-package/tsconfig.json +10 -0
- package/template/private-npm-package/.buildkite/pipeline.yml +5 -0
- package/template/private-npm-package/.nvmrc +1 -0
- package/template/private-npm-package/README.md +109 -0
- package/template/private-npm-package/_package.json +41 -0
- package/template/private-npm-package/skuba.template.js +24 -0
- package/template/private-npm-package/src/index.test.ts +5 -0
- package/template/private-npm-package/src/index.ts +7 -0
- package/template/private-npm-package/tsconfig.json +10 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
kind: Service
|
|
2
|
+
|
|
3
|
+
schemaVersion: v0.0
|
|
4
|
+
|
|
5
|
+
name: '{{values "service"}}'
|
|
6
|
+
|
|
7
|
+
image: '{{values "image"}}'
|
|
8
|
+
|
|
9
|
+
env:
|
|
10
|
+
# https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html
|
|
11
|
+
AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1'
|
|
12
|
+
|
|
13
|
+
ENVIRONMENT: '{{values "environment"}}'
|
|
14
|
+
OPENTELEMETRY_ENABLED: '{{.Values.openTelemetry.enabled | default false}}'
|
|
15
|
+
SERVICE: '{{values "service"}}'
|
|
16
|
+
|
|
17
|
+
{{range $key, $value := .Values.env}}
|
|
18
|
+
{{$key}}: {{$value}}
|
|
19
|
+
{{end}}
|
|
20
|
+
|
|
21
|
+
{{if .Values.datadogSecretId}}
|
|
22
|
+
datadogSecretId: '{{values "datadogSecretId"}}'
|
|
23
|
+
{{end}}
|
|
24
|
+
|
|
25
|
+
openTelemetry:
|
|
26
|
+
enabled: {{.Values.openTelemetry.enabled | default false}}
|
|
27
|
+
{{if .Values.isProduction}}
|
|
28
|
+
datadogEnvironmentName: production
|
|
29
|
+
{{else}}
|
|
30
|
+
datadogEnvironmentName: development
|
|
31
|
+
{{end}}
|
|
32
|
+
{{if .Values.pagerDutyEndpoint}}
|
|
33
|
+
pagerDutyEndpoint: '{{values "pagerDutyEndpoint"}}'
|
|
34
|
+
{{end}}
|
|
35
|
+
|
|
36
|
+
authentication:
|
|
37
|
+
ignoreRoutes:
|
|
38
|
+
- /health
|
|
39
|
+
- /smoke
|
|
40
|
+
|
|
41
|
+
sslEnabled: true
|
|
42
|
+
|
|
43
|
+
autoScaling:
|
|
44
|
+
maxCount: {{values "maxInstanceCount"}}
|
|
45
|
+
minCount: {{values "minInstanceCount"}}
|
|
46
|
+
|
|
47
|
+
cpuThreshold: 50
|
|
48
|
+
memoryThreshold: 50
|
|
49
|
+
|
|
50
|
+
# Disable Gantry's request-based scaling; the load a request generates can be
|
|
51
|
+
# highly variable. Instead, scale out when *either* CPU or memory are above
|
|
52
|
+
# the threshold, and scale in when *both* are 5% below the threshold.
|
|
53
|
+
#
|
|
54
|
+
# See https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-target-tracking.html
|
|
55
|
+
autoScalingPolicies:
|
|
56
|
+
CpuAutoScalingPolicy:
|
|
57
|
+
Type: AWS::ApplicationAutoScaling::ScalingPolicy
|
|
58
|
+
Properties:
|
|
59
|
+
PolicyName: CpuAutoScalingPolicy
|
|
60
|
+
PolicyType: TargetTrackingScaling
|
|
61
|
+
ScalingTargetId:
|
|
62
|
+
Ref: AutoScalingTarget
|
|
63
|
+
TargetTrackingScalingPolicyConfiguration:
|
|
64
|
+
ScaleInCooldown: 300
|
|
65
|
+
ScaleOutCooldown: 60
|
|
66
|
+
TargetValue:
|
|
67
|
+
Ref: CpuUtilisationAutoScalingThreshold
|
|
68
|
+
PredefinedMetricSpecification:
|
|
69
|
+
PredefinedMetricType: ECSServiceAverageCPUUtilization
|
|
70
|
+
|
|
71
|
+
MemoryAutoScalingPolicy:
|
|
72
|
+
Type: AWS::ApplicationAutoScaling::ScalingPolicy
|
|
73
|
+
Properties:
|
|
74
|
+
PolicyName: MemoryAutoScalingPolicy
|
|
75
|
+
PolicyType: TargetTrackingScaling
|
|
76
|
+
ScalingTargetId:
|
|
77
|
+
Ref: AutoScalingTarget
|
|
78
|
+
TargetTrackingScalingPolicyConfiguration:
|
|
79
|
+
ScaleInCooldown: 300
|
|
80
|
+
ScaleOutCooldown: 60
|
|
81
|
+
TargetValue:
|
|
82
|
+
Ref: MemoryUtilisationAutoScalingThreshold
|
|
83
|
+
PredefinedMetricSpecification:
|
|
84
|
+
PredefinedMetricType: ECSServiceAverageMemoryUtilization
|
|
85
|
+
|
|
86
|
+
RequestsScaleOutAlarm:
|
|
87
|
+
Type: AWS::CloudWatch::Alarm
|
|
88
|
+
Properties:
|
|
89
|
+
AlarmDescription: Stub alarm for Gantry to tag
|
|
90
|
+
Metrics:
|
|
91
|
+
- Id: missing
|
|
92
|
+
Expression: SUM(METRICS())
|
|
93
|
+
Period: 60
|
|
94
|
+
ReturnData: true
|
|
95
|
+
ActionsEnabled: false
|
|
96
|
+
EvaluationPeriods: 1
|
|
97
|
+
Threshold: 0
|
|
98
|
+
ComparisonOperator: LessThanThreshold
|
|
99
|
+
|
|
100
|
+
RequestsScaleInAlarm:
|
|
101
|
+
Type: AWS::CloudWatch::Alarm
|
|
102
|
+
Properties:
|
|
103
|
+
AlarmDescription: Stub alarm for Gantry to tag
|
|
104
|
+
Metrics:
|
|
105
|
+
- Id: missing
|
|
106
|
+
Expression: SUM(METRICS())
|
|
107
|
+
Period: 60
|
|
108
|
+
ReturnData: true
|
|
109
|
+
ActionsEnabled: false
|
|
110
|
+
EvaluationPeriods: 1
|
|
111
|
+
Threshold: 0
|
|
112
|
+
ComparisonOperator: LessThanThreshold
|
|
113
|
+
|
|
114
|
+
cpu: 256
|
|
115
|
+
memory: 512
|
|
116
|
+
|
|
117
|
+
deployment:
|
|
118
|
+
# SEEK-Jobs/gantry#488
|
|
119
|
+
ignoreAlarms: true
|
|
120
|
+
smokeTest:
|
|
121
|
+
path: /smoke
|
|
122
|
+
useExternalDns: true
|
|
123
|
+
|
|
124
|
+
tags:
|
|
125
|
+
{{range $key, $value := .Values.tags}}
|
|
126
|
+
{{$key}}: '{{$value}}'
|
|
127
|
+
{{end}}
|
|
128
|
+
|
|
129
|
+
cpuArchitecture: <%- platformName %>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
kind: ContainerImage
|
|
2
|
+
|
|
3
|
+
schemaVersion: v0.0
|
|
4
|
+
|
|
5
|
+
image: '{{values "image"}}'
|
|
6
|
+
|
|
7
|
+
buildArgs:
|
|
8
|
+
# https://github.com/seek-oss/docker-ecr-cache-buildkite-plugin#building-on-the-resulting-image
|
|
9
|
+
BASE_IMAGE: '{{.Env.BUILDKITE_PLUGIN_DOCKER_ECR_CACHE_EXPORT_IMAGE}}'
|
|
10
|
+
BASE_TAG: '{{.Env.BUILDKITE_PLUGIN_DOCKER_ECR_CACHE_EXPORT_TAG}}'
|
|
11
|
+
|
|
12
|
+
# SEEK-Jobs/gantry#1661
|
|
13
|
+
failOnScanFindings: false
|
|
14
|
+
|
|
15
|
+
cpuArchitecture: <%- platformName %>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"private": true,
|
|
3
|
+
"license": "UNLICENSED",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build": "skuba build",
|
|
6
|
+
"format": "skuba format",
|
|
7
|
+
"lint": "skuba lint",
|
|
8
|
+
"start": "skuba start --port <%- port %>",
|
|
9
|
+
"start:debug": "yarn start --inspect-brk",
|
|
10
|
+
"test": "skuba test",
|
|
11
|
+
"test:ci": "skuba test --coverage",
|
|
12
|
+
"test:watch": "skuba test --watch"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@koa/router": "^12.0.0",
|
|
16
|
+
"@opentelemetry/api": "^1.1.0",
|
|
17
|
+
"@opentelemetry/exporter-collector-grpc": "^0.25.0",
|
|
18
|
+
"@opentelemetry/instrumentation-aws-sdk": "^0.34.0",
|
|
19
|
+
"@opentelemetry/instrumentation-http": "^0.36.0",
|
|
20
|
+
"@opentelemetry/sdk-node": "^0.35.0",
|
|
21
|
+
"@seek/logger": "^5.0.1",
|
|
22
|
+
"aws-sdk": "^2.1039.0",
|
|
23
|
+
"hot-shots": "^10.0.0",
|
|
24
|
+
"koa": "^2.13.4",
|
|
25
|
+
"koa-bodyparser": "^4.3.0",
|
|
26
|
+
"koa-compose": "^4.2.0",
|
|
27
|
+
"seek-datadog-custom-metrics": "^4.0.0",
|
|
28
|
+
"seek-koala": "^6.0.0",
|
|
29
|
+
"skuba-dive": "^2.0.0",
|
|
30
|
+
"zod": "^3.19.1"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/chance": "^1.1.3",
|
|
34
|
+
"@types/koa": "^2.13.4",
|
|
35
|
+
"@types/koa-bodyparser": "^5.0.2",
|
|
36
|
+
"@types/koa__router": "^12.0.0",
|
|
37
|
+
"@types/node": "^18.11.5",
|
|
38
|
+
"@types/supertest": "^2.0.11",
|
|
39
|
+
"chance": "^1.1.8",
|
|
40
|
+
"pino-pretty": "^10.0.0",
|
|
41
|
+
"skuba": "*",
|
|
42
|
+
"supertest": "^6.1.6"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run `skuba configure` to finish templating and remove this file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
entryPoint: 'src/app.ts',
|
|
7
|
+
fields: [
|
|
8
|
+
{
|
|
9
|
+
name: 'serviceName',
|
|
10
|
+
message: 'Service slug',
|
|
11
|
+
initial: 'my-project',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'devBuildkiteQueueName',
|
|
15
|
+
message: 'Dev Buildkite queue',
|
|
16
|
+
initial: 'my-team-aws-account-dev:cicd',
|
|
17
|
+
validate: (value) => /^.+:.+$/.test(value),
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'prodBuildkiteQueueName',
|
|
21
|
+
message: 'Prod Buildkite queue',
|
|
22
|
+
initial: 'my-team-aws-account-prod:cicd',
|
|
23
|
+
validate: (value) => /^.+:.+$/.test(value),
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'devGantryEnvironmentName',
|
|
27
|
+
message: 'Dev Gantry environment',
|
|
28
|
+
initial: 'my-gantry-dev',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'prodGantryEnvironmentName',
|
|
32
|
+
message: 'Prod Gantry environment',
|
|
33
|
+
initial: 'my-gantry-prod',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'prodAwsAccountId',
|
|
37
|
+
message: 'Prod AWS account',
|
|
38
|
+
initial: '123456789012',
|
|
39
|
+
validate: (value) => /^\d{12}$/.test(value),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'region',
|
|
43
|
+
message: 'AWS region',
|
|
44
|
+
initial: 'my-region-0',
|
|
45
|
+
validate: (value) => /^[a-z]{2}-[a-z]+-\d+$/.test(value),
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
type: 'application',
|
|
49
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Middleware } from 'src/types/koa';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Signifies that the API is available to serve requests.
|
|
5
|
+
*
|
|
6
|
+
* The deployment environment calls this endpoint to see if the container is
|
|
7
|
+
* unhealthy and needs to be recycled.
|
|
8
|
+
*/
|
|
9
|
+
export const healthCheckHandler: Middleware = (ctx) => {
|
|
10
|
+
ctx.state.skipRequestLogging = true;
|
|
11
|
+
|
|
12
|
+
ctx.body = '';
|
|
13
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Router from '@koa/router';
|
|
2
|
+
|
|
3
|
+
import { healthCheckHandler } from './healthCheck';
|
|
4
|
+
import { jobRouter } from './jobs';
|
|
5
|
+
import { smokeTestHandler } from './smokeTest';
|
|
6
|
+
|
|
7
|
+
export const router = new Router()
|
|
8
|
+
.get('/health', healthCheckHandler)
|
|
9
|
+
.get('/smoke', smokeTestHandler)
|
|
10
|
+
.use('/jobs', jobRouter.routes());
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { logger } from 'src/framework/logging';
|
|
2
|
+
import { metricsClient } from 'src/framework/metrics';
|
|
3
|
+
import * as storage from 'src/storage/jobs';
|
|
4
|
+
import { Middleware } from 'src/types/koa';
|
|
5
|
+
|
|
6
|
+
export const getJobsHandler: Middleware = async (ctx) => {
|
|
7
|
+
const jobs = await storage.readJobs();
|
|
8
|
+
|
|
9
|
+
// no PII in these jobs
|
|
10
|
+
logger.debug({ jobs }, 'read jobs');
|
|
11
|
+
|
|
12
|
+
metricsClient.increment('job.reads', jobs.length);
|
|
13
|
+
|
|
14
|
+
ctx.body = jobs;
|
|
15
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Router from '@koa/router';
|
|
2
|
+
|
|
3
|
+
import { jsonBodyParser } from 'src/framework/middleware';
|
|
4
|
+
|
|
5
|
+
import { getJobsHandler } from './getJobs';
|
|
6
|
+
import { postJobHandler } from './postJob';
|
|
7
|
+
|
|
8
|
+
export const jobRouter = new Router()
|
|
9
|
+
.get('/', getJobsHandler)
|
|
10
|
+
.post('/', jsonBodyParser, postJobHandler);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { agentFromRouter } from 'src/testing/server';
|
|
2
|
+
import { mockJobInput } from 'src/testing/types';
|
|
3
|
+
|
|
4
|
+
import { jobRouter } from '.';
|
|
5
|
+
|
|
6
|
+
const agent = agentFromRouter(jobRouter);
|
|
7
|
+
|
|
8
|
+
describe('postJobHandler', () => {
|
|
9
|
+
it('200s and allocates an ID on valid input', () => {
|
|
10
|
+
const jobInput = mockJobInput();
|
|
11
|
+
|
|
12
|
+
return agent
|
|
13
|
+
.post('/')
|
|
14
|
+
.send(jobInput)
|
|
15
|
+
.expect(200)
|
|
16
|
+
.expect(({ body }) =>
|
|
17
|
+
expect(body).toStrictEqual({ ...jobInput, id: expect.any(String) }),
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('422s on invalid input', () => {
|
|
22
|
+
const jobInput = {};
|
|
23
|
+
|
|
24
|
+
return agent
|
|
25
|
+
.post('/')
|
|
26
|
+
.send(jobInput)
|
|
27
|
+
.expect(422)
|
|
28
|
+
.expect(({ text }) =>
|
|
29
|
+
expect(text).toMatchInlineSnapshot(
|
|
30
|
+
`"{"message":"Input validation failed","invalidFields":{"/hirer":"Required"}}"`,
|
|
31
|
+
),
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { logger } from 'src/framework/logging';
|
|
2
|
+
import { metricsClient } from 'src/framework/metrics';
|
|
3
|
+
import { validateRequestBody } from 'src/framework/validation';
|
|
4
|
+
import * as storage from 'src/storage/jobs';
|
|
5
|
+
import { JobInputSchema } from 'src/types/jobs';
|
|
6
|
+
import { Middleware } from 'src/types/koa';
|
|
7
|
+
|
|
8
|
+
export const postJobHandler: Middleware = async (ctx) => {
|
|
9
|
+
const jobInput = validateRequestBody(ctx, JobInputSchema);
|
|
10
|
+
|
|
11
|
+
const job = await storage.createJob(jobInput);
|
|
12
|
+
|
|
13
|
+
// no PII in these jobs
|
|
14
|
+
logger.debug({ job }, 'created job');
|
|
15
|
+
|
|
16
|
+
metricsClient.increment('job.creations');
|
|
17
|
+
|
|
18
|
+
ctx.body = job;
|
|
19
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { smokeTestJobStorage } from 'src/storage/jobs';
|
|
2
|
+
import { Middleware } from 'src/types/koa';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Tests connectivity to ensure appropriate access and network configuration.
|
|
6
|
+
*/
|
|
7
|
+
export const smokeTestHandler: Middleware = async (ctx) => {
|
|
8
|
+
await Promise.all([smokeTestJobStorage()]);
|
|
9
|
+
|
|
10
|
+
ctx.body = 'Smoke test passed';
|
|
11
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { agentFromApp } from 'src/testing/server';
|
|
2
|
+
|
|
3
|
+
import app from './app';
|
|
4
|
+
|
|
5
|
+
const agent = agentFromApp(app);
|
|
6
|
+
|
|
7
|
+
describe('app', () => {
|
|
8
|
+
it('exports callback for skuba start', () =>
|
|
9
|
+
expect(app).toHaveProperty('callback'));
|
|
10
|
+
|
|
11
|
+
it('has a happy health check', () => agent.get('/health').expect(200, ''));
|
|
12
|
+
|
|
13
|
+
it('has a reachable smoke test', () =>
|
|
14
|
+
agent.get('/smoke').expect(({ status }) => status !== 404));
|
|
15
|
+
|
|
16
|
+
it('has a reachable nested route', () =>
|
|
17
|
+
agent.get('/jobs').expect(({ status }) => status !== 404));
|
|
18
|
+
|
|
19
|
+
it('has OPTIONS for a nested route', () =>
|
|
20
|
+
agent.options('/jobs').expect(200).expect('allow', /HEAD/));
|
|
21
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Env } from 'skuba-dive';
|
|
2
|
+
|
|
3
|
+
interface Config {
|
|
4
|
+
environment: Environment;
|
|
5
|
+
|
|
6
|
+
logLevel: string;
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
|
|
10
|
+
metricsServer?: string;
|
|
11
|
+
port?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type Environment = (typeof environments)[number];
|
|
15
|
+
|
|
16
|
+
const dev = '<%- devGantryEnvironmentName %>';
|
|
17
|
+
const prod = '<%- prodGantryEnvironmentName %>';
|
|
18
|
+
|
|
19
|
+
const environments = ['local', 'test', dev, prod] as const;
|
|
20
|
+
|
|
21
|
+
const environment = Env.oneOf(environments)('ENVIRONMENT');
|
|
22
|
+
|
|
23
|
+
/* istanbul ignore next: config verification makes more sense in a smoke test */
|
|
24
|
+
const configs: Record<Environment, () => Omit<Config, 'environment'>> = {
|
|
25
|
+
local: () => ({
|
|
26
|
+
logLevel: 'debug',
|
|
27
|
+
name: '<%- serviceName %>',
|
|
28
|
+
version: 'local',
|
|
29
|
+
}),
|
|
30
|
+
|
|
31
|
+
test: () => ({
|
|
32
|
+
...configs.local(),
|
|
33
|
+
|
|
34
|
+
logLevel: Env.string('LOG_LEVEL', { default: 'silent' }),
|
|
35
|
+
version: 'test',
|
|
36
|
+
}),
|
|
37
|
+
|
|
38
|
+
[dev]: () => ({
|
|
39
|
+
...configs[prod](),
|
|
40
|
+
|
|
41
|
+
logLevel: 'debug',
|
|
42
|
+
}),
|
|
43
|
+
|
|
44
|
+
[prod]: () => ({
|
|
45
|
+
logLevel: 'info',
|
|
46
|
+
name: Env.string('SERVICE'),
|
|
47
|
+
version: Env.string('VERSION'),
|
|
48
|
+
|
|
49
|
+
metricsServer: 'localhost',
|
|
50
|
+
port: Env.nonNegativeInteger('PORT'),
|
|
51
|
+
}),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const config: Config = {
|
|
55
|
+
...configs[environment](),
|
|
56
|
+
environment,
|
|
57
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import createLogger from '@seek/logger';
|
|
2
|
+
import { RequestLogging } from 'seek-koala';
|
|
3
|
+
|
|
4
|
+
import { config } from 'src/config';
|
|
5
|
+
|
|
6
|
+
const { createContextMiddleware, mixin } =
|
|
7
|
+
RequestLogging.createContextStorage();
|
|
8
|
+
|
|
9
|
+
export const contextMiddleware = createContextMiddleware();
|
|
10
|
+
|
|
11
|
+
export const logger = createLogger({
|
|
12
|
+
base: {
|
|
13
|
+
environment: config.environment,
|
|
14
|
+
version: config.version,
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
mixin,
|
|
18
|
+
|
|
19
|
+
level: config.logLevel,
|
|
20
|
+
|
|
21
|
+
name: config.name,
|
|
22
|
+
|
|
23
|
+
transport:
|
|
24
|
+
config.environment === 'local' ? { target: 'pino-pretty' } : undefined,
|
|
25
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StatsD } from 'hot-shots';
|
|
2
|
+
import { createStatsDClient } from 'seek-datadog-custom-metrics';
|
|
3
|
+
|
|
4
|
+
import { config } from 'src/config';
|
|
5
|
+
|
|
6
|
+
import { logger } from './logging';
|
|
7
|
+
|
|
8
|
+
/* istanbul ignore next: StatsD client is not our responsibility */
|
|
9
|
+
export const metricsClient = createStatsDClient(StatsD, config, (err) =>
|
|
10
|
+
logger.error({ err }, 'StatsD error'),
|
|
11
|
+
);
|