skuba 4.4.0 → 5.0.0-beta.0
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/config/tsconfig.json +1 -0
- package/jest/moduleNameMapper.js +50 -78
- package/jest/moduleNameMapper.test.ts +4 -14
- package/jest/transform.js +10 -1
- package/jest/tsConfig.js +26 -0
- package/lib/api/buildkite/annotate.js +46 -33
- package/lib/api/buildkite/annotate.js.map +7 -1
- package/lib/api/buildkite/index.js +31 -7
- package/lib/api/buildkite/index.js.map +7 -1
- package/lib/api/buildkite/md.js +31 -8
- package/lib/api/buildkite/md.js.map +7 -1
- package/lib/api/git/commit.js +45 -17
- package/lib/api/git/commit.js.map +7 -1
- package/lib/api/git/commitAllChanges.js +57 -27
- package/lib/api/git/commitAllChanges.js.map +7 -1
- package/lib/api/git/currentBranch.js +50 -28
- package/lib/api/git/currentBranch.js.map +7 -1
- package/lib/api/git/getChangedFiles.js +49 -27
- package/lib/api/git/getChangedFiles.js.map +7 -1
- package/lib/api/git/index.js +54 -22
- package/lib/api/git/index.js.map +7 -1
- package/lib/api/git/log.js +63 -42
- package/lib/api/git/log.js.map +7 -1
- package/lib/api/git/pull.js +62 -31
- package/lib/api/git/pull.js.map +7 -1
- package/lib/api/git/push.js +63 -31
- package/lib/api/git/push.js.map +7 -1
- package/lib/api/git/remote.js +59 -56
- package/lib/api/git/remote.js.map +7 -1
- package/lib/api/git/reset.js +55 -27
- package/lib/api/git/reset.js.map +7 -1
- package/lib/api/git/statusMatrix.js +46 -13
- package/lib/api/git/statusMatrix.js.map +7 -1
- package/lib/api/github/checkRun.js +70 -79
- package/lib/api/github/checkRun.js.map +7 -1
- package/lib/api/github/environment.js +40 -33
- package/lib/api/github/environment.js.map +7 -1
- package/lib/api/github/index.js +47 -17
- package/lib/api/github/index.js.map +7 -1
- package/lib/api/github/issueComment.js +73 -81
- package/lib/api/github/issueComment.js.map +7 -1
- package/lib/api/github/pullRequest.js +60 -61
- package/lib/api/github/pullRequest.js.map +7 -1
- package/lib/api/github/push.js +138 -133
- package/lib/api/github/push.js.map +7 -1
- package/lib/api/jest/index.d.ts +2 -1
- package/lib/api/jest/index.js +35 -14
- package/lib/api/jest/index.js.map +7 -1
- package/lib/api/net/compose.js +45 -17
- package/lib/api/net/compose.js.map +7 -1
- package/lib/api/net/index.js +28 -5
- package/lib/api/net/index.js.map +7 -1
- package/lib/api/net/socket.js +58 -36
- package/lib/api/net/socket.js.map +7 -1
- package/lib/api/net/waitFor.js +38 -18
- package/lib/api/net/waitFor.js.map +7 -1
- package/lib/cli/adapter/eslint.js +95 -72
- package/lib/cli/adapter/eslint.js.map +7 -1
- package/lib/cli/adapter/prettier.js +126 -124
- package/lib/cli/adapter/prettier.js.map +7 -1
- package/lib/cli/build/args.d.ts +7 -0
- package/lib/cli/build/args.js +69 -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 +128 -0
- package/lib/cli/build/esbuild.js.map +7 -0
- package/lib/cli/build/index.d.ts +1 -1
- package/lib/cli/build/index.js +68 -5
- package/lib/cli/build/index.js.map +7 -1
- package/lib/cli/build/tsc.d.ts +1 -1
- package/lib/cli/build/tsc.js +34 -23
- package/lib/cli/build/tsc.js.map +7 -1
- package/lib/cli/buildPackage.js +53 -23
- package/lib/cli/buildPackage.js.map +7 -1
- package/lib/cli/configure/addEmptyExports.d.ts +5 -0
- package/lib/cli/configure/addEmptyExports.js +67 -0
- package/lib/cli/configure/addEmptyExports.js.map +7 -0
- package/lib/cli/configure/analyseConfiguration.js +61 -31
- package/lib/cli/configure/analyseConfiguration.js.map +7 -1
- package/lib/cli/configure/analyseDependencies.js +122 -113
- package/lib/cli/configure/analyseDependencies.js.map +7 -1
- package/lib/cli/configure/analysis/diff.js +37 -11
- package/lib/cli/configure/analysis/diff.js.map +7 -1
- package/lib/cli/configure/analysis/files.js +49 -22
- package/lib/cli/configure/analysis/files.js.map +7 -1
- package/lib/cli/configure/analysis/git.js +46 -16
- package/lib/cli/configure/analysis/git.js.map +7 -1
- package/lib/cli/configure/analysis/package.js +99 -52
- package/lib/cli/configure/analysis/package.js.map +7 -1
- package/lib/cli/configure/analysis/project.js +90 -54
- package/lib/cli/configure/analysis/project.js.map +7 -1
- package/lib/cli/configure/dependencies/index.js +40 -13
- package/lib/cli/configure/dependencies/index.js.map +7 -1
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +57 -32
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +7 -1
- package/lib/cli/configure/dependencies/seekKoala.js +53 -31
- package/lib/cli/configure/dependencies/seekKoala.js.map +7 -1
- package/lib/cli/configure/dependencies/skuba.js +49 -27
- package/lib/cli/configure/dependencies/skuba.js.map +7 -1
- package/lib/cli/configure/dependencies/skubaDeps.js +49 -28
- package/lib/cli/configure/dependencies/skubaDeps.js.map +7 -1
- package/lib/cli/configure/dependencies/skubaDive.js +65 -38
- package/lib/cli/configure/dependencies/skubaDive.js.map +7 -1
- package/lib/cli/configure/ensureTemplateCompletion.js +69 -41
- package/lib/cli/configure/ensureTemplateCompletion.js.map +7 -1
- package/lib/cli/configure/getEntryPoint.js +62 -32
- package/lib/cli/configure/getEntryPoint.js.map +7 -1
- package/lib/cli/configure/getProjectType.js +50 -28
- package/lib/cli/configure/getProjectType.js.map +7 -1
- package/lib/cli/configure/index.js +134 -109
- package/lib/cli/configure/index.js.map +7 -1
- package/lib/cli/configure/modules/eslint.js +57 -26
- package/lib/cli/configure/modules/eslint.js.map +7 -1
- package/lib/cli/configure/modules/ignore.js +37 -14
- package/lib/cli/configure/modules/ignore.js.map +7 -1
- package/lib/cli/configure/modules/index.js +53 -28
- package/lib/cli/configure/modules/index.js.map +7 -1
- package/lib/cli/configure/modules/jest.js +84 -47
- package/lib/cli/configure/modules/jest.js.map +7 -1
- package/lib/cli/configure/modules/nodemon.js +29 -6
- package/lib/cli/configure/modules/nodemon.js.map +7 -1
- package/lib/cli/configure/modules/package.js +113 -92
- package/lib/cli/configure/modules/package.js.map +7 -1
- package/lib/cli/configure/modules/prettier.js +48 -19
- package/lib/cli/configure/modules/prettier.js.map +7 -1
- package/lib/cli/configure/modules/renovate.js +52 -39
- package/lib/cli/configure/modules/renovate.js.map +7 -1
- package/lib/cli/configure/modules/serverless.js +33 -15
- package/lib/cli/configure/modules/serverless.js.map +7 -1
- package/lib/cli/configure/modules/skubaDive.js +63 -37
- package/lib/cli/configure/modules/skubaDive.js.map +7 -1
- package/lib/cli/configure/modules/tsconfig.js +79 -63
- package/lib/cli/configure/modules/tsconfig.js.map +7 -1
- package/lib/cli/configure/modules/tslint.js +29 -6
- package/lib/cli/configure/modules/tslint.js.map +7 -1
- package/lib/cli/configure/processing/deleteFiles.js +30 -8
- package/lib/cli/configure/processing/deleteFiles.js.map +7 -1
- package/lib/cli/configure/processing/ignoreFile.js +65 -59
- package/lib/cli/configure/processing/ignoreFile.js.map +7 -1
- package/lib/cli/configure/processing/javascript.js +35 -15
- package/lib/cli/configure/processing/javascript.js.map +7 -1
- package/lib/cli/configure/processing/json.js +51 -20
- package/lib/cli/configure/processing/json.js.map +7 -1
- package/lib/cli/configure/processing/loadFiles.js +30 -8
- package/lib/cli/configure/processing/loadFiles.js.map +7 -1
- package/lib/cli/configure/processing/module.js +37 -14
- package/lib/cli/configure/processing/module.js.map +7 -1
- package/lib/cli/configure/processing/package.js +73 -43
- package/lib/cli/configure/processing/package.js.map +7 -1
- package/lib/cli/configure/processing/prettier.js +37 -11
- package/lib/cli/configure/processing/prettier.js.map +7 -1
- package/lib/cli/configure/processing/record.js +54 -31
- package/lib/cli/configure/processing/record.js.map +7 -1
- package/lib/cli/configure/processing/typescript.js +176 -158
- package/lib/cli/configure/processing/typescript.js.map +7 -1
- package/lib/cli/configure/refreshIgnoreFiles.js +64 -40
- package/lib/cli/configure/refreshIgnoreFiles.js.map +7 -1
- package/lib/cli/configure/types.js +16 -2
- package/lib/cli/configure/types.js.map +7 -1
- package/lib/cli/format.js +58 -31
- package/lib/cli/format.js.map +7 -1
- package/lib/cli/help.js +31 -8
- package/lib/cli/help.js.map +7 -1
- package/lib/cli/init/getConfig.js +238 -207
- package/lib/cli/init/getConfig.js.map +7 -1
- package/lib/cli/init/git.js +70 -63
- package/lib/cli/init/git.js.map +7 -1
- package/lib/cli/init/index.js +133 -100
- package/lib/cli/init/index.js.map +7 -1
- package/lib/cli/init/prompts.js +84 -54
- package/lib/cli/init/prompts.js.map +7 -1
- package/lib/cli/init/types.js +52 -52
- package/lib/cli/init/types.js.map +7 -1
- package/lib/cli/init/validation.js +34 -12
- package/lib/cli/init/validation.js.map +7 -1
- package/lib/cli/init/writePackageJson.js +51 -22
- package/lib/cli/init/writePackageJson.js.map +7 -1
- package/lib/cli/lint/annotate/buildkite/eslint.js +34 -28
- package/lib/cli/lint/annotate/buildkite/eslint.js.map +7 -1
- package/lib/cli/lint/annotate/buildkite/index.js +50 -44
- package/lib/cli/lint/annotate/buildkite/index.js.map +7 -1
- package/lib/cli/lint/annotate/buildkite/prettier.js +41 -35
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +7 -1
- package/lib/cli/lint/annotate/buildkite/tsc.js +39 -39
- package/lib/cli/lint/annotate/buildkite/tsc.js.map +7 -1
- package/lib/cli/lint/annotate/github/eslint.js +40 -16
- package/lib/cli/lint/annotate/github/eslint.js.map +7 -1
- package/lib/cli/lint/annotate/github/index.js +55 -51
- package/lib/cli/lint/annotate/github/index.js.map +7 -1
- package/lib/cli/lint/annotate/github/prettier.js +36 -13
- package/lib/cli/lint/annotate/github/prettier.js.map +7 -1
- package/lib/cli/lint/annotate/github/tsc.js +52 -52
- package/lib/cli/lint/annotate/github/tsc.js.map +7 -1
- package/lib/cli/lint/annotate/index.js +33 -10
- package/lib/cli/lint/annotate/index.js.map +7 -1
- package/lib/cli/lint/autofix.js +122 -117
- package/lib/cli/lint/autofix.js.map +7 -1
- package/lib/cli/lint/eslint.js +48 -18
- package/lib/cli/lint/eslint.js.map +7 -1
- package/lib/cli/lint/external.js +102 -81
- package/lib/cli/lint/external.js.map +7 -1
- package/lib/cli/lint/index.js +42 -18
- package/lib/cli/lint/index.js.map +7 -1
- package/lib/cli/lint/internal.js +54 -21
- package/lib/cli/lint/internal.js.map +7 -1
- package/lib/cli/lint/prettier.js +48 -18
- package/lib/cli/lint/prettier.js.map +7 -1
- package/lib/cli/lint/tsc.js +56 -32
- package/lib/cli/lint/tsc.js.map +7 -1
- package/lib/cli/lint/types.js +16 -2
- package/lib/cli/lint/types.js.map +7 -1
- package/lib/cli/node.js +65 -58
- package/lib/cli/node.js.map +7 -1
- package/lib/cli/release.js +29 -6
- package/lib/cli/release.js.map +7 -1
- package/lib/cli/start.js +61 -24
- package/lib/cli/start.js.map +7 -1
- package/lib/cli/test/index.js +35 -11
- package/lib/cli/test/index.js.map +7 -1
- package/lib/cli/test/reporters/github/annotations.js +89 -92
- package/lib/cli/test/reporters/github/annotations.js.map +7 -1
- package/lib/cli/test/reporters/github/index.js +68 -68
- package/lib/cli/test/reporters/github/index.js.map +7 -1
- package/lib/cli/version.js +31 -8
- package/lib/cli/version.js.map +7 -1
- package/lib/enquirer.d.js +2 -0
- package/lib/enquirer.d.js.map +7 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +45 -41
- package/lib/index.js.map +7 -1
- package/lib/skuba.js +45 -38
- package/lib/skuba.js.map +7 -1
- package/lib/utils/args.js +97 -96
- package/lib/utils/args.js.map +7 -1
- package/lib/utils/command.js +64 -33
- package/lib/utils/command.js.map +7 -1
- package/lib/utils/copy.js +88 -51
- package/lib/utils/copy.js.map +7 -1
- package/lib/utils/dir.js +79 -67
- package/lib/utils/dir.js.map +7 -1
- package/lib/utils/env.js +27 -7
- package/lib/utils/env.js.map +7 -1
- package/lib/utils/error.js +58 -56
- package/lib/utils/error.js.map +7 -1
- package/lib/utils/exec.js +139 -110
- package/lib/utils/exec.js.map +7 -1
- package/lib/utils/help.js +31 -8
- package/lib/utils/help.js.map +7 -1
- package/lib/utils/logging.js +52 -24
- package/lib/utils/logging.js.map +7 -1
- package/lib/utils/logo.js +65 -27
- package/lib/utils/logo.js.map +7 -1
- package/lib/utils/manifest.d.ts +1 -0
- package/lib/utils/manifest.js +65 -51
- package/lib/utils/manifest.js.map +7 -1
- package/lib/utils/port.js +38 -17
- package/lib/utils/port.js.map +7 -1
- package/lib/utils/template.js +106 -87
- package/lib/utils/template.js.map +7 -1
- package/lib/utils/validation.js +43 -18
- package/lib/utils/validation.js.map +7 -1
- package/lib/utils/version.js +73 -40
- package/lib/utils/version.js.map +7 -1
- package/lib/utils/wait.js +52 -25
- package/lib/utils/wait.js.map +7 -1
- package/lib/utils/worker.js +59 -44
- package/lib/utils/worker.js.map +7 -1
- package/lib/wrapper/function-arguments.d.js +2 -0
- package/lib/wrapper/function-arguments.d.js.map +7 -0
- package/lib/wrapper/functionHandler.js +56 -29
- package/lib/wrapper/functionHandler.js.map +7 -1
- package/lib/wrapper/http.js +66 -56
- package/lib/wrapper/http.js.map +7 -1
- package/lib/wrapper/index.js +9 -21
- package/lib/wrapper/index.js.map +7 -1
- package/lib/wrapper/main.js +39 -20
- package/lib/wrapper/main.js.map +7 -1
- package/lib/wrapper/requestListener.js +50 -35
- package/lib/wrapper/requestListener.js.map +7 -1
- package/package.json +21 -14
- package/template/base/jest.config.ts +0 -6
- package/template/base/jest.setup.ts +2 -0
- package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/express-rest-api/package.json +1 -1
- package/template/greeter/.buildkite/pipeline.yml +1 -1
- package/template/greeter/package.json +1 -1
- package/template/greeter/src/app.test.ts +3 -1
- package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/koa-rest-api/package.json +6 -9
- package/template/koa-rest-api/src/api/jobs/postJob.test.ts +3 -7
- package/template/koa-rest-api/src/api/jobs/postJob.ts +2 -2
- package/template/koa-rest-api/src/framework/validation.test.ts +17 -15
- package/template/koa-rest-api/src/framework/validation.ts +50 -9
- package/template/koa-rest-api/src/storage/jobs.ts +2 -2
- package/template/koa-rest-api/src/testing/types.ts +5 -10
- package/template/koa-rest-api/src/types/jobs.ts +5 -10
- package/template/lambda-sqs-worker/.buildkite/pipeline.yml +3 -3
- package/template/lambda-sqs-worker/README.md +1 -1
- package/template/lambda-sqs-worker/package.json +4 -4
- package/template/lambda-sqs-worker/serverless.yml +17 -2
- package/template/lambda-sqs-worker/src/app.test.ts +19 -17
- package/template/lambda-sqs-worker/src/app.ts +8 -8
- package/template/lambda-sqs-worker/src/config.ts +3 -0
- package/template/lambda-sqs-worker/src/framework/handler.test.ts +7 -7
- package/template/lambda-sqs-worker/src/framework/handler.ts +31 -8
- package/template/lambda-sqs-worker/src/framework/metrics.ts +10 -6
- package/template/lambda-sqs-worker/src/framework/validation.test.ts +37 -17
- package/template/lambda-sqs-worker/src/framework/validation.ts +4 -2
- package/template/lambda-sqs-worker/src/services/jobScorer.ts +2 -2
- package/template/lambda-sqs-worker/src/testing/types.ts +5 -10
- package/template/lambda-sqs-worker/src/types/jobScorer.ts +9 -16
- package/template/lambda-sqs-worker/src/types/pipelineEvents.ts +13 -20
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +3 -3
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +6 -0
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +3 -3
- package/template/lambda-sqs-worker-cdk/infra/index.ts +2 -2
- package/template/lambda-sqs-worker-cdk/package.json +2 -2
- package/template/lambda-sqs-worker-cdk/shared/context-types.ts +16 -25
- package/template/oss-npm-package/_package.json +1 -1
- package/template/private-npm-package/_package.json +1 -1
- package/jest/resolver.js +0 -24
package/lib/wrapper/http.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/wrapper/http.ts"],
|
|
4
|
+
"sourcesContent": ["import http from 'http';\nimport type { AddressInfo } from 'net';\n\nimport { serializeError } from 'serialize-error';\n\nimport { log } from '../utils/logging';\n\n/**\n * Create an HTTP request listener based on the supplied function.\n *\n * - The request body is JSON parsed and passed into the function as parameters.\n * - The function's return value is JSON stringified into the response body.\n */\nexport const createRequestListenerFromFunction =\n (\n fn: (...args: unknown[]) => unknown | Promise<unknown>,\n ): http.RequestListener =>\n async (req, res) => {\n const writeJsonResponse = (statusCode: number, jsonResponse: unknown) => {\n res.writeHead(statusCode, { 'Content-Type': 'application/json' });\n\n return new Promise<void>((resolve, reject) =>\n jsonResponse === undefined\n ? res.end(resolve)\n : res.write(JSON.stringify(jsonResponse, null, 2), 'utf8', (err) =>\n err ? reject(err) : res.end(resolve),\n ),\n );\n };\n\n try {\n const requestBody = await new Promise<string>((resolve, reject) => {\n const data: Buffer[] = [];\n\n req\n .on('data', (chunk: Buffer) => data.push(chunk))\n .on('end', () => resolve(Buffer.concat(data).toString()))\n .on('error', (err) => reject(err));\n });\n\n // Treat an empty body as no arguments\n const jsonRequest: unknown = requestBody ? JSON.parse(requestBody) : [];\n\n // Pass a non-array request body as the first parameter\n const args: unknown[] = Array.isArray(jsonRequest)\n ? jsonRequest\n : [jsonRequest];\n\n const response: unknown = await fn(...args);\n\n await writeJsonResponse(200, response);\n } catch (err) {\n await writeJsonResponse(500, serializeError(err));\n }\n };\n\n/**\n * Create a HTTP server based on the supplied `http.RequestListener`.\n *\n * This function resolves when the server is closed.\n */\nexport const serveRequestListener = (\n requestListener: http.RequestListener,\n port?: number,\n) => {\n const server = http.createServer(requestListener);\n\n return new Promise<void>((resolve, reject) =>\n server\n .listen(port)\n .on('close', resolve)\n .on('error', reject)\n .on('listening', () => {\n const address = server.address() as AddressInfo;\n\n log.ok('listening on port', log.bold(address.port));\n }),\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAGjB,6BAA+B;AAE/B,qBAAoB;AAQb,MAAM,oCACX,CACE,OAEF,OAAO,KAAK,QAAQ;AAClB,QAAM,oBAAoB,CAAC,YAAoB,iBAA0B;AACvE,QAAI,UAAU,YAAY,EAAE,gBAAgB,mBAAmB,CAAC;AAEhE,WAAO,IAAI;AAAA,MAAc,CAAC,SAAS,WACjC,iBAAiB,SACb,IAAI,IAAI,OAAO,IACf,IAAI;AAAA,QAAM,KAAK,UAAU,cAAc,MAAM,CAAC;AAAA,QAAG;AAAA,QAAQ,CAAC,QACxD,MAAM,OAAO,GAAG,IAAI,IAAI,IAAI,OAAO;AAAA,MACrC;AAAA,IACN;AAAA,EACF;AAEA,MAAI;AACF,UAAM,cAAc,MAAM,IAAI,QAAgB,CAAC,SAAS,WAAW;AACjE,YAAM,OAAiB,CAAC;AAExB,UACG,GAAG,QAAQ,CAAC,UAAkB,KAAK,KAAK,KAAK,CAAC,EAC9C,GAAG,OAAO,MAAM,QAAQ,OAAO,OAAO,IAAI,EAAE,SAAS,CAAC,CAAC,EACvD,GAAG,SAAS,CAAC,QAAQ,OAAO,GAAG,CAAC;AAAA,IACrC,CAAC;AAGD,UAAM,cAAuB,cAAc,KAAK,MAAM,WAAW,IAAI,CAAC;AAGtE,UAAM,OAAkB,MAAM,QAAQ,WAAW,IAC7C,cACA,CAAC,WAAW;AAEhB,UAAM,WAAoB,MAAM,GAAG,GAAG,IAAI;AAE1C,UAAM,kBAAkB,KAAK,QAAQ;AAAA,EACvC,SAAS,KAAP;AACA,UAAM,kBAAkB,SAAK,uCAAe,GAAG,CAAC;AAAA,EAClD;AACF;AAOK,MAAM,uBAAuB,CAClC,iBACA,SACG;AACH,QAAM,SAAS,YAAAA,QAAK,aAAa,eAAe;AAEhD,SAAO,IAAI;AAAA,IAAc,CAAC,SAAS,WACjC,OACG,OAAO,IAAI,EACX,GAAG,SAAS,OAAO,EACnB,GAAG,SAAS,MAAM,EAClB,GAAG,aAAa,MAAM;AACrB,YAAM,UAAU,OAAO,QAAQ;AAE/B,yBAAI,GAAG,qBAAqB,mBAAI,KAAK,QAAQ,IAAI,CAAC;AAAA,IACpD,CAAC;AAAA,EACL;AACF;",
|
|
6
|
+
"names": ["http"]
|
|
7
|
+
}
|
package/lib/wrapper/index.js
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* - If you set the entry point to an exported function like `src/app#handler`,
|
|
8
|
-
* it will spin up a local HTTP server that calls into the function.
|
|
9
|
-
*
|
|
10
|
-
* - If you `export =` or `export default` an Express or Koa application,
|
|
11
|
-
* it will spin up a local HTTP server based on the request listener.
|
|
12
|
-
*/
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
const error_1 = require("../utils/error");
|
|
15
|
-
const logging_1 = require("../utils/logging");
|
|
16
|
-
const main_1 = require("./main");
|
|
17
|
-
const ENTRY_POINT_VAR = '__SKUBA_ENTRY_POINT';
|
|
18
|
-
const PORT_VAR = '__SKUBA_PORT';
|
|
2
|
+
var import_error = require("../utils/error");
|
|
3
|
+
var import_logging = require("../utils/logging");
|
|
4
|
+
var import_main = require("./main");
|
|
5
|
+
const ENTRY_POINT_VAR = "__SKUBA_ENTRY_POINT";
|
|
6
|
+
const PORT_VAR = "__SKUBA_PORT";
|
|
19
7
|
const rawEntryPoint = process.env[ENTRY_POINT_VAR];
|
|
20
8
|
if (!rawEntryPoint) {
|
|
21
|
-
|
|
9
|
+
throw new Error(`Missing environment variable: ${import_logging.log.bold(ENTRY_POINT_VAR)}`);
|
|
22
10
|
}
|
|
23
11
|
const rawPort = process.env[PORT_VAR];
|
|
24
12
|
if (!rawPort) {
|
|
25
|
-
|
|
13
|
+
throw new Error(`Missing environment variable: ${import_logging.log.bold(PORT_VAR)}`);
|
|
26
14
|
}
|
|
27
|
-
(0,
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
|
15
|
+
(0, import_main.main)(rawEntryPoint, rawPort).catch(import_error.handleCliError);
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
package/lib/wrapper/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/wrapper/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Wrapper around an entry point provided to `skuba node` or `skuba start`.\n *\n * Beyond simply loading the entry point, it supports the following features:\n *\n * - If you set the entry point to an exported function like `src/app#handler`,\n * it will spin up a local HTTP server that calls into the function.\n *\n * - If you `export =` or `export default` an Express or Koa application,\n * it will spin up a local HTTP server based on the request listener.\n */\n\nimport { handleCliError } from '../utils/error';\nimport { log } from '../utils/logging';\n\nimport { main } from './main';\n\nconst ENTRY_POINT_VAR = '__SKUBA_ENTRY_POINT';\nconst PORT_VAR = '__SKUBA_PORT';\n\nconst rawEntryPoint = process.env[ENTRY_POINT_VAR];\nif (!rawEntryPoint) {\n throw new Error(`Missing environment variable: ${log.bold(ENTRY_POINT_VAR)}`);\n}\n\nconst rawPort = process.env[PORT_VAR];\nif (!rawPort) {\n throw new Error(`Missing environment variable: ${log.bold(PORT_VAR)}`);\n}\n\nmain(rawEntryPoint, rawPort).catch(handleCliError);\n"],
|
|
5
|
+
"mappings": ";AAYA,mBAA+B;AAC/B,qBAAoB;AAEpB,kBAAqB;AAErB,MAAM,kBAAkB;AACxB,MAAM,WAAW;AAEjB,MAAM,gBAAgB,QAAQ,IAAI;AAClC,IAAI,CAAC,eAAe;AAClB,QAAM,IAAI,MAAM,iCAAiC,mBAAI,KAAK,eAAe,GAAG;AAC9E;AAEA,MAAM,UAAU,QAAQ,IAAI;AAC5B,IAAI,CAAC,SAAS;AACZ,QAAM,IAAI,MAAM,iCAAiC,mBAAI,KAAK,QAAQ,GAAG;AACvE;AAAA,IAEA,kBAAK,eAAe,OAAO,EAAE,MAAM,2BAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/lib/wrapper/main.js
CHANGED
|
@@ -1,24 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
11
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var main_exports = {};
|
|
26
|
+
__export(main_exports, {
|
|
27
|
+
main: () => main
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(main_exports);
|
|
30
|
+
var import_path = __toESM(require("path"));
|
|
31
|
+
var import_functionHandler = require("./functionHandler");
|
|
32
|
+
var import_requestListener = require("./requestListener");
|
|
10
33
|
const main = async (rawEntryPoint, rawPort) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.split('#', 2);
|
|
16
|
-
// Load entry point as module
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
18
|
-
const entryPoint = require(modulePath);
|
|
19
|
-
return functionName
|
|
20
|
-
? (0, functionHandler_1.runFunctionHandler)({ availablePort, entryPoint, functionName })
|
|
21
|
-
: (0, requestListener_1.runRequestListener)({ availablePort, entryPoint });
|
|
34
|
+
const availablePort = Number(rawPort) || void 0;
|
|
35
|
+
const [modulePath, functionName] = import_path.default.join(process.cwd(), rawEntryPoint).split("#", 2);
|
|
36
|
+
const entryPoint = require(modulePath);
|
|
37
|
+
return functionName ? (0, import_functionHandler.runFunctionHandler)({ availablePort, entryPoint, functionName }) : (0, import_requestListener.runRequestListener)({ availablePort, entryPoint });
|
|
22
38
|
};
|
|
23
|
-
|
|
24
|
-
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
main
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=main.js.map
|
package/lib/wrapper/main.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/wrapper/main.ts"],
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport { runFunctionHandler } from './functionHandler';\nimport { runRequestListener } from './requestListener';\n\nexport const main = async (rawEntryPoint: string, rawPort: string) => {\n const availablePort = Number(rawPort) || undefined;\n\n // Support exported function targeting, e.g. `src/module.ts#callMeMaybe`\n const [modulePath, functionName] = path\n .join(process.cwd(), rawEntryPoint)\n .split('#', 2);\n\n // Load entry point as module\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const entryPoint = require(modulePath) as unknown;\n\n return functionName\n ? runFunctionHandler({ availablePort, entryPoint, functionName })\n : runRequestListener({ availablePort, entryPoint });\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,6BAAmC;AACnC,6BAAmC;AAE5B,MAAM,OAAO,OAAO,eAAuB,YAAoB;AACpE,QAAM,gBAAgB,OAAO,OAAO,KAAK;AAGzC,QAAM,CAAC,YAAY,YAAY,IAAI,YAAAA,QAChC,KAAK,QAAQ,IAAI,GAAG,aAAa,EACjC,MAAM,KAAK,CAAC;AAIf,QAAM,aAAa,QAAQ,UAAU;AAErC,SAAO,mBACH,2CAAmB,EAAE,eAAe,YAAY,aAAa,CAAC,QAC9D,2CAAmB,EAAE,eAAe,WAAW,CAAC;AACtD;",
|
|
6
|
+
"names": ["path"]
|
|
7
|
+
}
|
|
@@ -1,37 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* This supports Express and Koa applications out of the box.
|
|
11
|
-
*/
|
|
12
|
-
const runRequestListener = async ({ availablePort, entryPoint, }) => {
|
|
13
|
-
if (!isConfig(entryPoint)) {
|
|
14
|
-
// Assume an executable script with weird exports
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
let config = entryPoint;
|
|
18
|
-
if (typeof config === 'object' && isConfig(config.default)) {
|
|
19
|
-
// Prefer `export default` over `export =`
|
|
20
|
-
config = config.default;
|
|
21
|
-
}
|
|
22
|
-
if (Object.keys(config).length === 0) {
|
|
23
|
-
// Assume an executable script with no exports
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const requestListener = typeof config === 'function'
|
|
27
|
-
? config
|
|
28
|
-
: config.requestListener ?? config.callback?.();
|
|
29
|
-
if (typeof requestListener !== 'function') {
|
|
30
|
-
// Assume an executable script with non-request listener exports
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const port = (0, validation_1.isIpPort)(config.port) ? config.port : availablePort;
|
|
34
|
-
return (0, http_1.serveRequestListener)(requestListener, port);
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
35
9
|
};
|
|
36
|
-
|
|
37
|
-
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var requestListener_exports = {};
|
|
20
|
+
__export(requestListener_exports, {
|
|
21
|
+
runRequestListener: () => runRequestListener
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(requestListener_exports);
|
|
24
|
+
var import_validation = require("../utils/validation");
|
|
25
|
+
var import_http = require("./http");
|
|
26
|
+
const isConfig = (data) => (0, import_validation.isFunction)(data) || (0, import_validation.isObject)(data);
|
|
27
|
+
const runRequestListener = async ({
|
|
28
|
+
availablePort,
|
|
29
|
+
entryPoint
|
|
30
|
+
}) => {
|
|
31
|
+
if (!isConfig(entryPoint)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let config = entryPoint;
|
|
35
|
+
if (typeof config === "object" && isConfig(config.default)) {
|
|
36
|
+
config = config.default;
|
|
37
|
+
}
|
|
38
|
+
if (Object.keys(config).length === 0) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const requestListener = typeof config === "function" ? config : config.requestListener ?? config.callback?.();
|
|
42
|
+
if (typeof requestListener !== "function") {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const port = (0, import_validation.isIpPort)(config.port) ? config.port : availablePort;
|
|
46
|
+
return (0, import_http.serveRequestListener)(requestListener, port);
|
|
47
|
+
};
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
runRequestListener
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=requestListener.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/wrapper/requestListener.ts"],
|
|
4
|
+
"sourcesContent": ["import type http from 'http';\n\nimport { isFunction, isIpPort, isObject } from '../utils/validation';\n\nimport { serveRequestListener } from './http';\n\n// Express compatibility\ninterface FunctionConfig extends http.RequestListener {\n port?: number;\n}\n\ninterface ObjectConfig {\n // Koa compatibility\n callback?: () => http.RequestListener;\n\n requestListener?: http.RequestListener;\n\n default?: unknown;\n port?: unknown;\n}\n\nconst isConfig = (data: unknown): data is FunctionConfig | ObjectConfig =>\n isFunction(data) || isObject(data);\n\ninterface Args {\n availablePort?: number;\n entryPoint: unknown;\n}\n\n/**\n * Create an HTTP server that calls into an exported `http.RequestListener`.\n *\n * This supports Express and Koa applications out of the box.\n */\nexport const runRequestListener = async ({\n availablePort,\n entryPoint,\n}: Args): Promise<void> => {\n if (!isConfig(entryPoint)) {\n // Assume an executable script with weird exports\n return;\n }\n\n let config = entryPoint;\n\n if (typeof config === 'object' && isConfig(config.default)) {\n // Prefer `export default` over `export =`\n config = config.default;\n }\n\n if (Object.keys(config).length === 0) {\n // Assume an executable script with no exports\n return;\n }\n\n const requestListener =\n typeof config === 'function'\n ? config\n : config.requestListener ?? config.callback?.();\n\n if (typeof requestListener !== 'function') {\n // Assume an executable script with non-request listener exports\n return;\n }\n\n const port = isIpPort(config.port) ? config.port : availablePort;\n\n return serveRequestListener(requestListener, port);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,wBAA+C;AAE/C,kBAAqC;AAiBrC,MAAM,WAAW,CAAC,aAChB,8BAAW,IAAI,SAAK,4BAAS,IAAI;AAY5B,MAAM,qBAAqB,OAAO;AAAA,EACvC;AAAA,EACA;AACF,MAA2B;AACzB,MAAI,CAAC,SAAS,UAAU,GAAG;AAEzB;AAAA,EACF;AAEA,MAAI,SAAS;AAEb,MAAI,OAAO,WAAW,YAAY,SAAS,OAAO,OAAO,GAAG;AAE1D,aAAS,OAAO;AAAA,EAClB;AAEA,MAAI,OAAO,KAAK,MAAM,EAAE,WAAW,GAAG;AAEpC;AAAA,EACF;AAEA,QAAM,kBACJ,OAAO,WAAW,aACd,SACA,OAAO,mBAAmB,OAAO,WAAW;AAElD,MAAI,OAAO,oBAAoB,YAAY;AAEzC;AAAA,EACF;AAEA,QAAM,WAAO,4BAAS,OAAO,IAAI,IAAI,OAAO,OAAO;AAEnD,aAAO,kCAAqB,iBAAiB,IAAI;AACnD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/seek-oss/skuba/issues"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
+
"@esbuild-plugins/tsconfig-paths": "^0.0.4",
|
|
9
10
|
"@jest/types": "^29.0.0",
|
|
10
11
|
"@octokit/graphql": "^5.0.0",
|
|
11
12
|
"@octokit/graphql-schema": "^12.0.0",
|
|
12
13
|
"@octokit/rest": "^19.0.0",
|
|
13
|
-
"@octokit/types": "^
|
|
14
|
+
"@octokit/types": "^8.0.0",
|
|
14
15
|
"@types/jest": "^29.0.0",
|
|
15
16
|
"@types/node": ">=14.18",
|
|
16
17
|
"chalk": "^4.1.0",
|
|
@@ -18,6 +19,7 @@
|
|
|
18
19
|
"dotenv": "^16.0.0",
|
|
19
20
|
"ejs": "^3.1.6",
|
|
20
21
|
"enquirer": "^2.3.6",
|
|
22
|
+
"esbuild": "~0.15.7",
|
|
21
23
|
"eslint": "^8.11.0",
|
|
22
24
|
"eslint-config-skuba": "1.1.4",
|
|
23
25
|
"execa": "^5.0.0",
|
|
@@ -30,11 +32,12 @@
|
|
|
30
32
|
"isomorphic-git": "^1.11.1",
|
|
31
33
|
"jest": "^29.0.1",
|
|
32
34
|
"jest-watch-typeahead": "^2.1.1",
|
|
35
|
+
"libnpmsearch": "^6.0.0",
|
|
33
36
|
"lodash.mergewith": "^4.6.2",
|
|
34
|
-
"
|
|
37
|
+
"minimist": "^1.2.6",
|
|
38
|
+
"normalize-package-data": "^5.0.0",
|
|
35
39
|
"npm-run-path": "^4.0.1",
|
|
36
40
|
"npm-which": "^3.0.1",
|
|
37
|
-
"package-json": "^7.0.0",
|
|
38
41
|
"picomatch": "^2.2.2",
|
|
39
42
|
"prettier": "~2.7.0",
|
|
40
43
|
"read-pkg-up": "^7.0.1",
|
|
@@ -45,37 +48,40 @@
|
|
|
45
48
|
"sort-package-json": "^1.57.0",
|
|
46
49
|
"strip-ansi": "^6.0.1",
|
|
47
50
|
"ts-dedent": "^2.2.0",
|
|
48
|
-
"ts-jest": "^29.0.
|
|
51
|
+
"ts-jest": "^29.0.3",
|
|
49
52
|
"ts-node": "^10.7.0",
|
|
50
53
|
"ts-node-dev": "^2.0.0",
|
|
51
54
|
"tsconfig-paths": "^4.0.0",
|
|
52
55
|
"tsconfig-seek": "1.0.2",
|
|
53
|
-
"typescript": "~4.8.2"
|
|
56
|
+
"typescript": "~4.8.2",
|
|
57
|
+
"validate-npm-package-name": "^5.0.0"
|
|
54
58
|
},
|
|
55
59
|
"description": "SEEK development toolkit for backend applications and packages",
|
|
56
60
|
"devDependencies": {
|
|
57
|
-
"@changesets/cli": "2.
|
|
61
|
+
"@changesets/cli": "2.25.0",
|
|
58
62
|
"@changesets/get-github-info": "0.5.1",
|
|
59
|
-
"@jest/reporters": "29.
|
|
63
|
+
"@jest/reporters": "29.2.1",
|
|
60
64
|
"@types/ejs": "3.1.1",
|
|
61
|
-
"@types/express": "4.17.
|
|
65
|
+
"@types/express": "4.17.14",
|
|
62
66
|
"@types/fs-extra": "9.0.13",
|
|
63
67
|
"@types/koa": "2.13.5",
|
|
68
|
+
"@types/libnpmsearch": "2.0.3",
|
|
64
69
|
"@types/lodash.mergewith": "4.6.7",
|
|
65
70
|
"@types/module-alias": "2.0.1",
|
|
66
71
|
"@types/npm-which": "3.0.1",
|
|
67
72
|
"@types/picomatch": "2.3.0",
|
|
68
73
|
"@types/supertest": "2.0.12",
|
|
74
|
+
"@types/validate-npm-package-name": "4.0.0",
|
|
69
75
|
"enhanced-resolve": "5.10.0",
|
|
70
|
-
"express": "4.18.
|
|
76
|
+
"express": "4.18.2",
|
|
71
77
|
"jsonfile": "6.1.0",
|
|
72
78
|
"koa": "2.13.4",
|
|
73
79
|
"memfs": "3.4.7",
|
|
74
80
|
"remark-cli": "11.0.0",
|
|
75
81
|
"remark-preset-lint-recommended": "6.1.2",
|
|
76
|
-
"semver": "7.3.
|
|
77
|
-
"supertest": "6.
|
|
78
|
-
"type-fest": "2.
|
|
82
|
+
"semver": "7.3.8",
|
|
83
|
+
"supertest": "6.3.0",
|
|
84
|
+
"type-fest": "2.19.0"
|
|
79
85
|
},
|
|
80
86
|
"engines": {
|
|
81
87
|
"node": ">=14.18"
|
|
@@ -132,7 +138,7 @@
|
|
|
132
138
|
"**/@types/node": ">=14.18"
|
|
133
139
|
},
|
|
134
140
|
"scripts": {
|
|
135
|
-
"build": "
|
|
141
|
+
"build": "scripts/build.sh",
|
|
136
142
|
"deploy": "scripts/deploy.sh",
|
|
137
143
|
"format": "yarn skuba format",
|
|
138
144
|
"lint": "yarn skuba lint && yarn lint:md",
|
|
@@ -148,11 +154,12 @@
|
|
|
148
154
|
},
|
|
149
155
|
"sideEffects": false,
|
|
150
156
|
"skuba": {
|
|
157
|
+
"build": "esbuild",
|
|
151
158
|
"entryPoint": "src/index.ts",
|
|
152
159
|
"template": null,
|
|
153
160
|
"type": "package",
|
|
154
161
|
"version": "4.0.0"
|
|
155
162
|
},
|
|
156
163
|
"types": "./lib/index.d.ts",
|
|
157
|
-
"version": "
|
|
164
|
+
"version": "5.0.0-beta.0"
|
|
158
165
|
}
|
|
@@ -3,30 +3,27 @@
|
|
|
3
3
|
"@koa/router": "^12.0.0",
|
|
4
4
|
"@opentelemetry/api": "^1.1.0",
|
|
5
5
|
"@opentelemetry/exporter-collector-grpc": "^0.25.0",
|
|
6
|
-
"@opentelemetry/instrumentation-aws-sdk": "^0.
|
|
7
|
-
"@opentelemetry/instrumentation-http": "^0.
|
|
8
|
-
"@opentelemetry/sdk-node": "^0.
|
|
6
|
+
"@opentelemetry/instrumentation-aws-sdk": "^0.9.0",
|
|
7
|
+
"@opentelemetry/instrumentation-http": "^0.33.0",
|
|
8
|
+
"@opentelemetry/sdk-node": "^0.33.0",
|
|
9
9
|
"@seek/logger": "^5.0.1",
|
|
10
10
|
"aws-sdk": "^2.1039.0",
|
|
11
11
|
"hot-shots": "^9.0.0",
|
|
12
12
|
"koa": "^2.13.4",
|
|
13
13
|
"koa-bodyparser": "^4.3.0",
|
|
14
14
|
"koa-compose": "^4.2.0",
|
|
15
|
-
"runtypes": "^6.4.1",
|
|
16
|
-
"runtypes-filter": "^0.6.0",
|
|
17
15
|
"seek-datadog-custom-metrics": "^4.0.0",
|
|
18
16
|
"seek-koala": "^6.0.0",
|
|
19
17
|
"skuba-dive": "^2.0.0",
|
|
20
|
-
"
|
|
18
|
+
"zod": "^3.19.1"
|
|
21
19
|
},
|
|
22
20
|
"devDependencies": {
|
|
23
21
|
"@types/chance": "^1.1.3",
|
|
24
22
|
"@types/koa": "^2.13.4",
|
|
25
23
|
"@types/koa-bodyparser": "^5.0.2",
|
|
26
|
-
"@types/koa__router": "^
|
|
27
|
-
"@types/node": "
|
|
24
|
+
"@types/koa__router": "^12.0.0",
|
|
25
|
+
"@types/node": "16.11.64",
|
|
28
26
|
"@types/supertest": "^2.0.11",
|
|
29
|
-
"@types/uuid": "^8.3.1",
|
|
30
27
|
"chance": "^1.1.8",
|
|
31
28
|
"pino-pretty": "^9.0.0",
|
|
32
29
|
"skuba": "*",
|
|
@@ -26,13 +26,9 @@ describe('postJobHandler', () => {
|
|
|
26
26
|
.send(jobInput)
|
|
27
27
|
.expect(422)
|
|
28
28
|
.expect(({ text }) =>
|
|
29
|
-
expect(text).toMatchInlineSnapshot(
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
"hirer": "Expected { id: string; }, but was missing"
|
|
33
|
-
}.
|
|
34
|
-
Object should match { hirer: { id: string; }; }"
|
|
35
|
-
`),
|
|
29
|
+
expect(text).toMatchInlineSnapshot(
|
|
30
|
+
`"{"message":"Input validation failed","invalidFields":{"/hirer":"Required"}}"`,
|
|
31
|
+
),
|
|
36
32
|
);
|
|
37
33
|
});
|
|
38
34
|
});
|
|
@@ -2,11 +2,11 @@ import { logger } from 'src/framework/logging';
|
|
|
2
2
|
import { metricsClient } from 'src/framework/metrics';
|
|
3
3
|
import { validateRequestBody } from 'src/framework/validation';
|
|
4
4
|
import * as storage from 'src/storage/jobs';
|
|
5
|
-
import {
|
|
5
|
+
import { JobInputSchema } from 'src/types/jobs';
|
|
6
6
|
import { Middleware } from 'src/types/koa';
|
|
7
7
|
|
|
8
8
|
export const postJobHandler: Middleware = async (ctx) => {
|
|
9
|
-
const jobInput = validateRequestBody(ctx,
|
|
9
|
+
const jobInput = validateRequestBody(ctx, JobInputSchema);
|
|
10
10
|
|
|
11
11
|
const job = await storage.createJob(jobInput);
|
|
12
12
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { agentFromMiddleware } from 'src/testing/server';
|
|
2
2
|
import {
|
|
3
|
+
IdDescriptionSchema,
|
|
3
4
|
chance,
|
|
4
|
-
filterIdDescription,
|
|
5
5
|
mockIdDescription,
|
|
6
6
|
} from 'src/testing/types';
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ const agent = agentFromMiddleware(jsonBodyParser, (ctx) => {
|
|
|
12
12
|
const result = validate({
|
|
13
13
|
ctx,
|
|
14
14
|
input: ctx.request.body,
|
|
15
|
-
|
|
15
|
+
schema: IdDescriptionSchema,
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
ctx.body = result;
|
|
@@ -41,13 +41,14 @@ describe('validate', () => {
|
|
|
41
41
|
.post('/')
|
|
42
42
|
.send({ ...idDescription, id: null })
|
|
43
43
|
.expect(422)
|
|
44
|
-
.expect(({
|
|
45
|
-
expect(
|
|
46
|
-
"Validation failed:
|
|
44
|
+
.expect(({ body }) =>
|
|
45
|
+
expect(body).toMatchInlineSnapshot(`
|
|
47
46
|
{
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
"invalidFields": {
|
|
48
|
+
"/id": "Expected string, received null",
|
|
49
|
+
},
|
|
50
|
+
"message": "Input validation failed",
|
|
51
|
+
}
|
|
51
52
|
`),
|
|
52
53
|
);
|
|
53
54
|
});
|
|
@@ -57,14 +58,15 @@ describe('validate', () => {
|
|
|
57
58
|
.post('/')
|
|
58
59
|
.send({})
|
|
59
60
|
.expect(422)
|
|
60
|
-
.expect(({
|
|
61
|
-
expect(
|
|
62
|
-
"Validation failed:
|
|
61
|
+
.expect(({ body }) =>
|
|
62
|
+
expect(body).toMatchInlineSnapshot(`
|
|
63
63
|
{
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
"invalidFields": {
|
|
65
|
+
"/description": "Required",
|
|
66
|
+
"/id": "Required",
|
|
67
|
+
},
|
|
68
|
+
"message": "Input validation failed",
|
|
69
|
+
}
|
|
68
70
|
`),
|
|
69
71
|
));
|
|
70
72
|
});
|