skuba 0.0.0-master-20230319220011 → 0.0.0-master-20230815032514
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/README.md +1 -1
- package/config/tsconfig.json +3 -1
- package/jest-preset.js +7 -1
- package/lib/api/buildkite/md.js.map +1 -1
- package/lib/api/git/commitAllChanges.d.ts +2 -2
- package/lib/api/git/commitAllChanges.js.map +2 -2
- package/lib/api/git/currentBranch.js +2 -1
- package/lib/api/git/currentBranch.js.map +2 -2
- package/lib/api/git/findRoot.d.ts +9 -0
- package/lib/api/git/findRoot.js +52 -0
- package/lib/api/git/findRoot.js.map +7 -0
- package/lib/api/git/index.d.ts +1 -0
- package/lib/api/git/index.js +3 -0
- package/lib/api/git/index.js.map +2 -2
- package/lib/api/git/pull.js.map +1 -1
- package/lib/api/git/push.js.map +1 -1
- package/lib/api/git/remote.js +2 -1
- package/lib/api/git/remote.js.map +2 -2
- package/lib/api/git/reset.js.map +1 -1
- package/lib/api/github/checkRun.d.ts +1 -1
- package/lib/api/github/checkRun.js.map +2 -2
- package/lib/api/github/environment.js.map +1 -1
- package/lib/api/github/issueComment.js.map +1 -1
- package/lib/api/github/pullRequest.js +3 -2
- package/lib/api/github/pullRequest.js.map +2 -2
- package/lib/api/github/push.js.map +1 -1
- package/lib/api/jest/index.d.ts +24 -21
- package/lib/api/net/compose.js.map +1 -1
- package/lib/api/net/socket.js.map +1 -1
- package/lib/api/net/waitFor.d.ts +1 -1
- package/lib/api/net/waitFor.js.map +2 -2
- package/lib/cli/adapter/eslint.d.ts +2 -2
- package/lib/cli/adapter/eslint.js +0 -24
- package/lib/cli/adapter/eslint.js.map +2 -2
- package/lib/cli/adapter/prettier.d.ts +9 -2
- package/lib/cli/adapter/prettier.js +20 -15
- package/lib/cli/adapter/prettier.js.map +2 -2
- package/lib/cli/build/assets.d.ts +10 -0
- package/lib/cli/build/assets.js +107 -0
- package/lib/cli/build/assets.js.map +7 -0
- package/lib/cli/build/esbuild.js +7 -42
- package/lib/cli/build/esbuild.js.map +3 -3
- package/lib/cli/build/index.js +12 -2
- package/lib/cli/build/index.js.map +2 -2
- package/lib/cli/build/tsc.d.ts +3 -0
- package/lib/cli/build/tsc.js +66 -0
- package/lib/cli/build/tsc.js.map +3 -3
- package/lib/cli/buildPackage.js +13 -0
- package/lib/cli/buildPackage.js.map +2 -2
- package/lib/cli/configure/addEmptyExports.js +1 -1
- package/lib/cli/configure/addEmptyExports.js.map +2 -2
- package/lib/cli/configure/analyseDependencies.js +1 -1
- package/lib/cli/configure/analyseDependencies.js.map +2 -2
- package/lib/cli/configure/analysis/files.js.map +1 -1
- package/lib/cli/configure/analysis/package.js.map +2 -2
- package/lib/cli/configure/analysis/project.js +7 -3
- package/lib/cli/configure/analysis/project.js.map +2 -2
- package/lib/cli/configure/ensureTemplateCompletion.d.ts +1 -1
- package/lib/cli/configure/ensureTemplateCompletion.js +1 -1
- package/lib/cli/configure/ensureTemplateCompletion.js.map +2 -2
- package/lib/cli/configure/getEntryPoint.js +3 -0
- package/lib/cli/configure/getEntryPoint.js.map +3 -3
- package/lib/cli/configure/index.js +1 -1
- package/lib/cli/configure/index.js.map +2 -2
- package/lib/cli/configure/modules/jest.js +2 -2
- package/lib/cli/configure/modules/jest.js.map +2 -2
- package/lib/cli/configure/modules/skubaDive.js.map +1 -1
- package/lib/cli/configure/modules/tsconfig.js.map +1 -1
- package/lib/cli/configure/patchDockerfile.d.ts +1 -0
- package/lib/cli/configure/patchDockerfile.js +65 -0
- package/lib/cli/configure/patchDockerfile.js.map +7 -0
- package/lib/cli/configure/patchRenovateConfig.js +9 -4
- package/lib/cli/configure/patchRenovateConfig.js.map +2 -2
- package/lib/cli/configure/patchServerListener.js +1 -1
- package/lib/cli/configure/patchServerListener.js.map +2 -2
- package/lib/cli/configure/processing/ignoreFile.js.map +1 -1
- package/lib/cli/configure/processing/javascript.js.map +1 -1
- package/lib/cli/configure/processing/json.d.ts +1 -1
- package/lib/cli/configure/processing/json.js.map +1 -1
- package/lib/cli/configure/processing/module.js.map +1 -1
- package/lib/cli/configure/processing/package.d.ts +2 -2
- package/lib/cli/configure/processing/prettier.d.ts +1 -1
- package/lib/cli/configure/processing/typescript.d.ts +2 -2
- package/lib/cli/configure/processing/typescript.js +15 -7
- package/lib/cli/configure/processing/typescript.js.map +2 -2
- package/lib/cli/configure/refreshIgnoreFiles.js.map +1 -1
- package/lib/cli/configure/types.d.ts +1 -1
- package/lib/cli/configure/types.js.map +1 -1
- package/lib/cli/format.js +2 -0
- package/lib/cli/format.js.map +2 -2
- package/lib/cli/init/getConfig.d.ts +2 -2
- package/lib/cli/init/getConfig.js +5 -2
- package/lib/cli/init/getConfig.js.map +2 -2
- package/lib/cli/init/git.js.map +1 -1
- package/lib/cli/init/index.js.map +1 -1
- package/lib/cli/init/prompts.d.ts +1 -1
- package/lib/cli/init/prompts.js +1 -1
- package/lib/cli/init/prompts.js.map +2 -2
- package/lib/cli/init/writePackageJson.js +1 -1
- package/lib/cli/init/writePackageJson.js.map +2 -2
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +2 -2
- package/lib/cli/lint/annotate/github/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/github/index.js.map +1 -1
- package/lib/cli/lint/annotate/github/tsc.js +1 -1
- package/lib/cli/lint/annotate/github/tsc.js.map +2 -2
- package/lib/cli/lint/autofix.js +21 -0
- package/lib/cli/lint/autofix.js.map +2 -2
- package/lib/cli/lint/eslint.d.ts +1 -1
- package/lib/cli/lint/eslint.js.map +2 -2
- package/lib/cli/lint/external.js.map +1 -1
- package/lib/cli/lint/internal.js.map +1 -1
- package/lib/cli/lint/prettier.d.ts +1 -1
- package/lib/cli/lint/prettier.js.map +2 -2
- package/lib/cli/lint/tsc.js.map +1 -1
- package/lib/cli/test/reporters/github/annotations.js +1 -1
- package/lib/cli/test/reporters/github/annotations.js.map +2 -2
- package/lib/cli/test/reporters/github/index.js +0 -2
- package/lib/cli/test/reporters/github/index.js.map +1 -1
- package/lib/cli/test/reporters/prettier/index.d.ts +4 -0
- package/lib/cli/test/reporters/prettier/index.js +67 -0
- package/lib/cli/test/reporters/prettier/index.js.map +7 -0
- package/lib/index.js.map +1 -1
- package/lib/skuba.js +1 -0
- package/lib/skuba.js.map +2 -2
- package/lib/utils/args.d.ts +1 -1
- package/lib/utils/args.js.map +2 -2
- package/lib/utils/command.js +1 -1
- package/lib/utils/command.js.map +2 -2
- package/lib/utils/copy.d.ts +2 -1
- package/lib/utils/copy.js +6 -1
- package/lib/utils/copy.js.map +2 -2
- package/lib/utils/dir.d.ts +3 -2
- package/lib/utils/dir.js +6 -6
- package/lib/utils/dir.js.map +2 -2
- package/lib/utils/exec.d.ts +1 -2
- package/lib/utils/exec.js.map +2 -2
- package/lib/utils/logging.js.map +1 -1
- package/lib/utils/logo.js.map +1 -1
- package/lib/utils/manifest.d.ts +2 -2
- package/lib/utils/manifest.js +8 -2
- package/lib/utils/manifest.js.map +2 -2
- package/lib/utils/validation.d.ts +3 -3
- package/lib/utils/validation.js.map +2 -2
- package/lib/utils/version.js.map +1 -1
- package/lib/utils/wait.js.map +1 -1
- package/lib/utils/worker.js.map +1 -1
- package/lib/wrapper/functionHandler.js.map +1 -1
- package/lib/wrapper/http.d.ts +1 -1
- package/lib/wrapper/http.js.map +2 -2
- package/lib/wrapper/index.js.map +1 -1
- package/lib/wrapper/main.js.map +2 -2
- package/lib/wrapper/requestListener.js +3 -0
- package/lib/wrapper/requestListener.js.map +2 -2
- package/package.json +29 -26
- package/template/base/.github/CODEOWNERS +0 -4
- package/template/base/_.prettierignore +1 -13
- package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/express-rest-api/Dockerfile +1 -1
- package/template/express-rest-api/gantry.apply.yml +0 -2
- package/template/express-rest-api/package.json +2 -2
- package/template/express-rest-api/src/api/healthCheck.ts +1 -1
- package/template/express-rest-api/src/api/smokeTest.ts +1 -1
- package/template/greeter/.buildkite/pipeline.yml +1 -1
- package/template/greeter/package.json +1 -1
- package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/koa-rest-api/Dockerfile +1 -1
- package/template/koa-rest-api/gantry.apply.yml +0 -2
- package/template/koa-rest-api/package.json +7 -7
- package/template/koa-rest-api/src/api/healthCheck.ts +1 -1
- package/template/koa-rest-api/src/api/jobs/getJobs.ts +1 -1
- package/template/koa-rest-api/src/api/jobs/postJob.ts +1 -1
- package/template/koa-rest-api/src/api/smokeTest.ts +1 -1
- package/template/koa-rest-api/src/framework/server.test.ts +1 -1
- package/template/koa-rest-api/src/framework/server.ts +1 -1
- package/template/koa-rest-api/src/framework/validation.ts +2 -2
- package/template/koa-rest-api/src/storage/jobs.ts +1 -1
- package/template/koa-rest-api/src/testing/server.ts +3 -3
- package/template/koa-rest-api/src/testing/types.ts +1 -1
- package/template/lambda-sqs-worker/.buildkite/pipeline.yml +2 -2
- package/template/lambda-sqs-worker/package.json +9 -9
- package/template/lambda-sqs-worker/src/app.test.ts +1 -1
- package/template/lambda-sqs-worker/src/app.ts +10 -5
- package/template/lambda-sqs-worker/src/framework/handler.test.ts +4 -4
- package/template/lambda-sqs-worker/src/framework/handler.ts +1 -1
- package/template/lambda-sqs-worker/src/framework/validation.ts +1 -1
- package/template/lambda-sqs-worker/src/mapping/jobScorer.ts +5 -2
- package/template/lambda-sqs-worker/src/services/jobScorer.ts +6 -3
- package/template/lambda-sqs-worker/src/testing/handler.ts +3 -3
- package/template/lambda-sqs-worker/src/testing/logging.ts +3 -0
- package/template/lambda-sqs-worker/src/testing/types.ts +1 -1
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +2 -2
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +1 -1
- package/template/lambda-sqs-worker-cdk/package.json +2 -2
- package/template/lambda-sqs-worker-cdk/src/app.ts +1 -1
- package/template/oss-npm-package/.github/workflows/release.yml +1 -0
- package/template/oss-npm-package/_package.json +4 -1
- package/template/private-npm-package/_package.json +1 -1
package/lib/wrapper/http.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 (
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAGjB,6BAA+B;AAE/B,qBAAoB;AAQb,MAAM,oCACX,
|
|
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 (fn: (...args: unknown[]) => Promise<unknown>): 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 return startServer(server, port);\n};\n\n/**\n * Returns a HTTP server wrapped in a promise\n *\n * This function resolves when the server is closed.\n */\nexport const startServer = (server: http.Server, port?: number) =>\n 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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAGjB,6BAA+B;AAE/B,qBAAoB;AAQb,MAAM,oCACX,CAAC,OACD,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,KAAK;AACZ,UAAM,kBAAkB,SAAK,uCAAe,GAAG,CAAC;AAAA,EAClD;AACF;AAOK,MAAM,uBAAuB,CAClC,iBACA,SACG;AACH,QAAM,SAAS,YAAAA,QAAK,aAAa,eAAe;AAChD,SAAO,YAAY,QAAQ,IAAI;AACjC;AAOO,MAAM,cAAc,CAAC,QAAqB,SAC/C,IAAI;AAAA,EAAc,CAAC,SAAS,WAC1B,OACG,OAAO,IAAI,EACX,GAAG,SAAS,OAAO,EACnB,GAAG,SAAS,MAAM,EAClB,GAAG,aAAa,MAAM;AACrB,UAAM,UAAU,OAAO,QAAQ;AAE/B,uBAAI,GAAG,qBAAqB,mBAAI,KAAK,QAAQ,IAAI,CAAC;AAAA,EACpD,CAAC;AACL;",
|
|
6
6
|
"names": ["http"]
|
|
7
7
|
}
|
package/lib/wrapper/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/wrapper/index.ts"],
|
|
4
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,eAAe;AACjD,IAAI,CAAC,eAAe;AAClB,QAAM,IAAI,MAAM,iCAAiC,mBAAI,KAAK,eAAe,
|
|
5
|
+
"mappings": ";AAYA,mBAA+B;AAC/B,qBAAoB;AAEpB,kBAAqB;AAErB,MAAM,kBAAkB;AACxB,MAAM,WAAW;AAEjB,MAAM,gBAAgB,QAAQ,IAAI,eAAe;AACjD,IAAI,CAAC,eAAe;AAClB,QAAM,IAAI,MAAM,iCAAiC,mBAAI,KAAK,eAAe,CAAC,EAAE;AAC9E;AAEA,MAAM,UAAU,QAAQ,IAAI,QAAQ;AACpC,IAAI,CAAC,SAAS;AACZ,QAAM,IAAI,MAAM,iCAAiC,mBAAI,KAAK,QAAQ,CAAC,EAAE;AACvE;AAAA,IAEA,kBAAK,eAAe,OAAO,EAAE,MAAM,2BAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/wrapper/main.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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,
|
|
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 string) 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,UAAoB;AAE/C,SAAO,mBACH,2CAAmB,EAAE,eAAe,YAAY,aAAa,CAAC,QAC9D,2CAAmB,EAAE,eAAe,WAAW,CAAC;AACtD;",
|
|
6
6
|
"names": ["path"]
|
|
7
7
|
}
|
|
@@ -50,6 +50,9 @@ const runRequestListener = async ({
|
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
const port = (0, import_validation.isIpPort)(config.port) ? config.port : availablePort;
|
|
53
|
+
if (typeof config !== "function" && config instanceof import_http.default.Server) {
|
|
54
|
+
return (0, import_http2.startServer)(config, port);
|
|
55
|
+
}
|
|
53
56
|
if (typeof config !== "function" && config.server && config.server instanceof import_http.default.Server) {
|
|
54
57
|
return (0, import_http2.startServer)(config.server, port);
|
|
55
58
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/wrapper/requestListener.ts"],
|
|
4
|
-
"sourcesContent": ["import http from 'http';\n\nimport { isFunction, isIpPort, isObject } from '../utils/validation';\n\nimport { serveRequestListener, startServer } 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 // Fastify compatibility\n server?: http.Server;\n\n default?: Promise<unknown>;\n port?: unknown;\n}\n\nconst isConfig = (\n data: unknown,\n): data is Promise<FunctionConfig> | Promise<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: FunctionConfig | ObjectConfig = await entryPoint;\n\n if (typeof config === 'object' && isConfig(config.default)) {\n // Prefer `export default` over `export =`\n config = await 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 port = isIpPort(config.port) ? config.port : availablePort;\n\n // Fastify workaround\n if (\n typeof config !== 'function' &&\n config.server &&\n config.server instanceof http.Server\n ) {\n return startServer(config.server, port);\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 return serveRequestListener(requestListener, port);\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,wBAA+C;AAE/C,IAAAA,eAAkD;AAoBlD,MAAM,WAAW,CACf,aAEA,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,SAAwC,MAAM;AAElD,MAAI,OAAO,WAAW,YAAY,SAAS,OAAO,OAAO,GAAG;AAE1D,aAAS,MAAM,OAAO;AAAA,EACxB;AAEA,MAAI,OAAO,KAAK,MAAM,EAAE,WAAW,GAAG;AAEpC;AAAA,EACF;AAEA,QAAM,WAAO,4BAAS,OAAO,IAAI,IAAI,OAAO,OAAO;AAGnD,MACE,OAAO,WAAW,cAClB,OAAO,UACP,OAAO,kBAAkB,
|
|
4
|
+
"sourcesContent": ["import http from 'http';\n\nimport { isFunction, isIpPort, isObject } from '../utils/validation';\n\nimport { serveRequestListener, startServer } 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 // Fastify compatibility\n server?: http.Server;\n\n default?: Promise<unknown>;\n port?: unknown;\n}\n\nconst isConfig = (\n data: unknown,\n): data is Promise<FunctionConfig> | Promise<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: FunctionConfig | ObjectConfig = await entryPoint;\n\n if (typeof config === 'object' && isConfig(config.default)) {\n // Prefer `export default` over `export =`\n config = await 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 port = isIpPort(config.port) ? config.port : availablePort;\n\n // http.Server support\n if (typeof config !== 'function' && config instanceof http.Server) {\n return startServer(config, port);\n }\n\n // Fastify workaround\n if (\n typeof config !== 'function' &&\n config.server &&\n config.server instanceof http.Server\n ) {\n return startServer(config.server, port);\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 return serveRequestListener(requestListener, port);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,wBAA+C;AAE/C,IAAAA,eAAkD;AAoBlD,MAAM,WAAW,CACf,aAEA,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,SAAwC,MAAM;AAElD,MAAI,OAAO,WAAW,YAAY,SAAS,OAAO,OAAO,GAAG;AAE1D,aAAS,MAAM,OAAO;AAAA,EACxB;AAEA,MAAI,OAAO,KAAK,MAAM,EAAE,WAAW,GAAG;AAEpC;AAAA,EACF;AAEA,QAAM,WAAO,4BAAS,OAAO,IAAI,IAAI,OAAO,OAAO;AAGnD,MAAI,OAAO,WAAW,cAAc,kBAAkB,YAAAC,QAAK,QAAQ;AACjE,eAAO,0BAAY,QAAQ,IAAI;AAAA,EACjC;AAGA,MACE,OAAO,WAAW,cAClB,OAAO,UACP,OAAO,kBAAkB,YAAAA,QAAK,QAC9B;AACA,eAAO,0BAAY,OAAO,QAAQ,IAAI;AAAA,EACxC;AAEA,QAAM,kBACJ,OAAO,WAAW,aACd,SACA,OAAO,mBAAmB,OAAO,WAAW;AAElD,MAAI,OAAO,oBAAoB,YAAY;AAEzC;AAAA,EACF;AAEA,aAAO,mCAAqB,iBAAiB,IAAI;AACnD;",
|
|
6
6
|
"names": ["import_http", "http"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skuba",
|
|
3
|
-
"version": "0.0.0-master-
|
|
3
|
+
"version": "0.0.0-master-20230815032514",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "SEEK development toolkit for backend applications and packages",
|
|
6
6
|
"homepage": "https://github.com/seek-oss/skuba#readme",
|
|
@@ -65,25 +65,25 @@
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
"resolutions": {
|
|
68
|
-
"**/@types/node": ">=
|
|
68
|
+
"**/@types/node": ">=18.12"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@esbuild-plugins/tsconfig-paths": "^0.1.0",
|
|
72
72
|
"@jest/types": "^29.0.0",
|
|
73
|
-
"@octokit/graphql": "^
|
|
74
|
-
"@octokit/graphql-schema": "^
|
|
75
|
-
"@octokit/rest": "^
|
|
76
|
-
"@octokit/types": "^
|
|
73
|
+
"@octokit/graphql": "^7.0.0",
|
|
74
|
+
"@octokit/graphql-schema": "^14.5.0",
|
|
75
|
+
"@octokit/rest": "^20.0.0",
|
|
76
|
+
"@octokit/types": "^11.0.0",
|
|
77
77
|
"@types/jest": "^29.0.0",
|
|
78
|
-
"@types/node": ">=
|
|
78
|
+
"@types/node": ">=18.12",
|
|
79
79
|
"chalk": "^4.1.0",
|
|
80
|
-
"concurrently": "^
|
|
80
|
+
"concurrently": "^8.0.0",
|
|
81
81
|
"dotenv": "^16.0.0",
|
|
82
82
|
"ejs": "^3.1.6",
|
|
83
83
|
"enquirer": "^2.3.6",
|
|
84
|
-
"esbuild": "~0.
|
|
84
|
+
"esbuild": "~0.19.0",
|
|
85
85
|
"eslint": "^8.11.0",
|
|
86
|
-
"eslint-config-skuba": "
|
|
86
|
+
"eslint-config-skuba": "3.0.1",
|
|
87
87
|
"execa": "^5.0.0",
|
|
88
88
|
"fdir": "^6.0.0",
|
|
89
89
|
"fs-extra": "^11.0.0",
|
|
@@ -102,47 +102,47 @@
|
|
|
102
102
|
"npm-run-path": "^4.0.1",
|
|
103
103
|
"npm-which": "^3.0.1",
|
|
104
104
|
"picomatch": "^2.2.2",
|
|
105
|
-
"prettier": "~
|
|
105
|
+
"prettier": "~3.0.0",
|
|
106
106
|
"read-pkg-up": "^7.0.1",
|
|
107
107
|
"runtypes": "^6.0.0",
|
|
108
|
-
"semantic-release": "^
|
|
108
|
+
"semantic-release": "^21.0.0",
|
|
109
109
|
"serialize-error": "^8.0.1",
|
|
110
110
|
"simple-git": "^3.5.0",
|
|
111
111
|
"sort-package-json": "^1.57.0",
|
|
112
112
|
"strip-ansi": "^6.0.1",
|
|
113
113
|
"ts-dedent": "^2.2.0",
|
|
114
|
-
"ts-jest": "^29.0
|
|
114
|
+
"ts-jest": "^29.1.0",
|
|
115
115
|
"ts-node": "^10.7.0",
|
|
116
116
|
"ts-node-dev": "^2.0.0",
|
|
117
117
|
"tsconfig-paths": "^4.0.0",
|
|
118
|
-
"tsconfig-seek": "
|
|
119
|
-
"typescript": "~5.
|
|
118
|
+
"tsconfig-seek": "2.0.0",
|
|
119
|
+
"typescript": "~5.1.5",
|
|
120
120
|
"validate-npm-package-name": "^5.0.0"
|
|
121
121
|
},
|
|
122
122
|
"devDependencies": {
|
|
123
|
-
"@changesets/cli": "2.26.
|
|
123
|
+
"@changesets/cli": "2.26.2",
|
|
124
124
|
"@changesets/get-github-info": "0.5.2",
|
|
125
|
-
"@jest/reporters": "29.
|
|
125
|
+
"@jest/reporters": "29.6.2",
|
|
126
126
|
"@types/ejs": "3.1.2",
|
|
127
127
|
"@types/express": "4.17.17",
|
|
128
128
|
"@types/fs-extra": "11.0.1",
|
|
129
|
-
"@types/koa": "2.13.
|
|
129
|
+
"@types/koa": "2.13.8",
|
|
130
130
|
"@types/libnpmsearch": "2.0.3",
|
|
131
131
|
"@types/lodash.mergewith": "4.6.7",
|
|
132
|
-
"@types/module-alias": "2.0.
|
|
132
|
+
"@types/module-alias": "2.0.2",
|
|
133
133
|
"@types/npm-which": "3.0.1",
|
|
134
134
|
"@types/picomatch": "2.3.0",
|
|
135
135
|
"@types/supertest": "2.0.12",
|
|
136
136
|
"@types/validate-npm-package-name": "4.0.0",
|
|
137
|
-
"enhanced-resolve": "5.
|
|
137
|
+
"enhanced-resolve": "5.15.0",
|
|
138
138
|
"express": "4.18.2",
|
|
139
|
-
"fastify": "4.
|
|
139
|
+
"fastify": "4.21.0",
|
|
140
140
|
"jsonfile": "6.1.0",
|
|
141
|
-
"koa": "2.14.
|
|
142
|
-
"memfs": "
|
|
141
|
+
"koa": "2.14.2",
|
|
142
|
+
"memfs": "4.2.1",
|
|
143
143
|
"remark-cli": "11.0.0",
|
|
144
|
-
"remark-preset-lint-recommended": "6.1.
|
|
145
|
-
"semver": "7.
|
|
144
|
+
"remark-preset-lint-recommended": "6.1.3",
|
|
145
|
+
"semver": "7.5.4",
|
|
146
146
|
"supertest": "6.3.3",
|
|
147
147
|
"type-fest": "2.19.0"
|
|
148
148
|
},
|
|
@@ -155,7 +155,10 @@
|
|
|
155
155
|
}
|
|
156
156
|
},
|
|
157
157
|
"engines": {
|
|
158
|
-
"node": ">=
|
|
158
|
+
"node": ">=18.12"
|
|
159
|
+
},
|
|
160
|
+
"publishConfig": {
|
|
161
|
+
"provenance": true
|
|
159
162
|
},
|
|
160
163
|
"skuba": {
|
|
161
164
|
"build": "esbuild",
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
# managed by skuba
|
|
2
|
-
.idea/*
|
|
3
|
-
.vscode/*
|
|
4
|
-
|
|
5
|
-
.cdk.staging/
|
|
6
|
-
.serverless/
|
|
7
|
-
cdk.out/
|
|
8
|
-
node_modules*/
|
|
9
|
-
|
|
10
|
-
/coverage*/
|
|
11
|
-
/dist*/
|
|
12
|
-
/lib*/
|
|
13
|
-
/tmp*/
|
|
14
|
-
|
|
15
2
|
# Gantry resource files support non-standard template syntax
|
|
16
3
|
/.gantry/**/*.yaml
|
|
17
4
|
/.gantry/**/*.yml
|
|
18
5
|
gantry*.yaml
|
|
19
6
|
gantry*.yml
|
|
7
|
+
pnpm-lock.yaml
|
|
20
8
|
# end managed by skuba
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"test:watch": "skuba test --watch"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@seek/logger": "^
|
|
15
|
+
"@seek/logger": "^6.0.0",
|
|
16
16
|
"express": "^4.17.1",
|
|
17
17
|
"skuba-dive": "^2.0.0"
|
|
18
18
|
},
|
|
@@ -25,6 +25,6 @@
|
|
|
25
25
|
"supertest": "^6.1.6"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
28
|
-
"node": ">=18"
|
|
28
|
+
"node": ">=18.12"
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@koa/router": "^12.0.0",
|
|
16
16
|
"@opentelemetry/api": "^1.1.0",
|
|
17
|
-
"@opentelemetry/exporter-trace-otlp-grpc": "^0.
|
|
18
|
-
"@opentelemetry/instrumentation-aws-sdk": "^0.
|
|
19
|
-
"@opentelemetry/instrumentation-http": "^0.
|
|
20
|
-
"@opentelemetry/sdk-node": "^0.
|
|
21
|
-
"@seek/logger": "^
|
|
17
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "^0.41.0",
|
|
18
|
+
"@opentelemetry/instrumentation-aws-sdk": "^0.36.0",
|
|
19
|
+
"@opentelemetry/instrumentation-http": "^0.41.0",
|
|
20
|
+
"@opentelemetry/sdk-node": "^0.41.0",
|
|
21
|
+
"@seek/logger": "^6.0.0",
|
|
22
22
|
"aws-sdk": "^2.1039.0",
|
|
23
23
|
"hot-shots": "^10.0.0",
|
|
24
24
|
"koa": "^2.13.4",
|
|
25
25
|
"koa-bodyparser": "^4.3.0",
|
|
26
26
|
"koa-compose": "^4.2.0",
|
|
27
|
-
"seek-datadog-custom-metrics": "^4.
|
|
27
|
+
"seek-datadog-custom-metrics": "^4.2.1",
|
|
28
28
|
"seek-koala": "^6.0.0",
|
|
29
29
|
"skuba-dive": "^2.0.0",
|
|
30
30
|
"zod": "^3.19.1"
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"supertest": "^6.1.6"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
|
-
"node": ">=18"
|
|
45
|
+
"node": ">=18.12"
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { logger } from 'src/framework/logging';
|
|
2
2
|
import { metricsClient } from 'src/framework/metrics';
|
|
3
3
|
import * as storage from 'src/storage/jobs';
|
|
4
|
-
import { Middleware } from 'src/types/koa';
|
|
4
|
+
import type { Middleware } from 'src/types/koa';
|
|
5
5
|
|
|
6
6
|
export const getJobsHandler: Middleware = async (ctx) => {
|
|
7
7
|
const jobs = await storage.readJobs();
|
|
@@ -3,7 +3,7 @@ import { metricsClient } from 'src/framework/metrics';
|
|
|
3
3
|
import { validateRequestBody } from 'src/framework/validation';
|
|
4
4
|
import * as storage from 'src/storage/jobs';
|
|
5
5
|
import { JobInputSchema } from 'src/types/jobs';
|
|
6
|
-
import { Middleware } from 'src/types/koa';
|
|
6
|
+
import type { Middleware } from 'src/types/koa';
|
|
7
7
|
|
|
8
8
|
export const postJobHandler: Middleware = async (ctx) => {
|
|
9
9
|
const jobInput = validateRequestBody(ctx, JobInputSchema);
|
|
@@ -4,7 +4,7 @@ import { logger } from 'src/testing/logging';
|
|
|
4
4
|
import { metricsClient } from 'src/testing/metrics';
|
|
5
5
|
import { agentFromRouter } from 'src/testing/server';
|
|
6
6
|
import { chance } from 'src/testing/types';
|
|
7
|
-
import { Middleware } from 'src/types/koa';
|
|
7
|
+
import type { Middleware } from 'src/types/koa';
|
|
8
8
|
|
|
9
9
|
const middleware = jest.fn<void, Parameters<Middleware>>();
|
|
10
10
|
|
|
@@ -36,7 +36,7 @@ const version = VersionMiddleware.create({
|
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
export const createApp = <State, Context>(
|
|
39
|
-
...middleware: Koa.Middleware<State, Context
|
|
39
|
+
...middleware: Array<Koa.Middleware<State, Context>>
|
|
40
40
|
) =>
|
|
41
41
|
new Koa()
|
|
42
42
|
// TODO: consider using a middleware that adds secure HTTP headers.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Router from '@koa/router';
|
|
2
|
-
import Koa from 'koa';
|
|
1
|
+
import type Router from '@koa/router';
|
|
2
|
+
import type Koa from 'koa';
|
|
3
3
|
import request from 'supertest';
|
|
4
4
|
|
|
5
5
|
import { createApp } from 'src/framework/server';
|
|
@@ -14,7 +14,7 @@ export const agentFromApp = <State, Context>(app: Koa<State, Context>) =>
|
|
|
14
14
|
* Create a new SuperTest agent from a set of Koa middleware.
|
|
15
15
|
*/
|
|
16
16
|
export const agentFromMiddleware = <State, Context>(
|
|
17
|
-
...middleware: Koa.Middleware<State, Context
|
|
17
|
+
...middleware: Array<Koa.Middleware<State, Context>>
|
|
18
18
|
) => {
|
|
19
19
|
const app = createApp(...middleware);
|
|
20
20
|
|
|
@@ -32,7 +32,7 @@ configs:
|
|
|
32
32
|
- *aws-sm
|
|
33
33
|
- *private-npm
|
|
34
34
|
- *docker-ecr-cache
|
|
35
|
-
- docker-compose#v4.
|
|
35
|
+
- docker-compose#v4.14.0:
|
|
36
36
|
dependencies: false
|
|
37
37
|
run: app
|
|
38
38
|
retry:
|
|
@@ -60,7 +60,7 @@ steps:
|
|
|
60
60
|
- *aws-sm
|
|
61
61
|
- *private-npm
|
|
62
62
|
- *docker-ecr-cache
|
|
63
|
-
- docker-compose#v4.
|
|
63
|
+
- docker-compose#v4.14.0:
|
|
64
64
|
run: app
|
|
65
65
|
timeout_in_minutes: 10
|
|
66
66
|
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"test:watch": "skuba test --watch"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@aws-sdk/client-codedeploy": "^3.
|
|
18
|
-
"@aws-sdk/client-lambda": "^3.
|
|
19
|
-
"@aws-sdk/client-sns": "^3.
|
|
17
|
+
"@aws-sdk/client-codedeploy": "^3.363.0",
|
|
18
|
+
"@aws-sdk/client-lambda": "^3.363.0",
|
|
19
|
+
"@aws-sdk/client-sns": "^3.363.0",
|
|
20
20
|
"@aws-sdk/util-utf8-node": "^3.259.0",
|
|
21
|
-
"@seek/logger": "^
|
|
22
|
-
"datadog-lambda-js": "^
|
|
23
|
-
"dd-trace": "^
|
|
21
|
+
"@seek/logger": "^6.0.0",
|
|
22
|
+
"datadog-lambda-js": "^7.0.0",
|
|
23
|
+
"dd-trace": "^4.0.0",
|
|
24
24
|
"skuba-dive": "^2.0.0",
|
|
25
25
|
"zod": "^3.19.1"
|
|
26
26
|
},
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@types/aws-lambda": "^8.10.84",
|
|
29
29
|
"@types/chance": "^1.1.3",
|
|
30
30
|
"@types/node": "^18.11.9",
|
|
31
|
-
"aws-sdk-client-mock": "^
|
|
32
|
-
"aws-sdk-client-mock-jest": "^
|
|
31
|
+
"aws-sdk-client-mock": "^3.0.0",
|
|
32
|
+
"aws-sdk-client-mock-jest": "^3.0.0",
|
|
33
33
|
"chance": "^1.1.8",
|
|
34
34
|
"pino-pretty": "^10.0.0",
|
|
35
35
|
"serverless": "^3.25.0",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"skuba": "*"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
|
-
"node": ">=18"
|
|
42
|
+
"node": ">=18.12"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -47,7 +47,7 @@ describe('handler', () => {
|
|
|
47
47
|
|
|
48
48
|
expect(logger.error).not.toHaveBeenCalled();
|
|
49
49
|
|
|
50
|
-
expect(logger.
|
|
50
|
+
expect(logger.debug.mock.calls).toEqual([
|
|
51
51
|
[{ count: 1 }, 'Received jobs'],
|
|
52
52
|
[{ snsMessageId: expect.any(String) }, 'Scored job'],
|
|
53
53
|
['Function succeeded'],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'skuba-dive/register';
|
|
2
2
|
|
|
3
|
-
import { SQSEvent } from 'aws-lambda';
|
|
3
|
+
import type { SQSEvent } from 'aws-lambda';
|
|
4
4
|
|
|
5
5
|
import { createHandler } from 'src/framework/handler';
|
|
6
6
|
import { logger } from 'src/framework/logging';
|
|
@@ -20,7 +20,7 @@ const smokeTest = async () => {
|
|
|
20
20
|
export const handler = createHandler<SQSEvent>(async (event) => {
|
|
21
21
|
// Treat an empty object as our smoke test event.
|
|
22
22
|
if (!Object.keys(event).length) {
|
|
23
|
-
logger.
|
|
23
|
+
logger.debug('Received smoke test request');
|
|
24
24
|
return smokeTest();
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -30,23 +30,28 @@ export const handler = createHandler<SQSEvent>(async (event) => {
|
|
|
30
30
|
throw Error(`Received ${count} records`);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
logger.
|
|
33
|
+
logger.debug({ count }, 'Received jobs');
|
|
34
34
|
|
|
35
35
|
metricsClient.distribution('job.received', event.Records.length);
|
|
36
36
|
|
|
37
37
|
const record = event.Records[0];
|
|
38
|
+
if (!record) {
|
|
39
|
+
throw new Error('Malformed SQS event with no records');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const { body } = record;
|
|
38
43
|
|
|
39
44
|
// TODO: this throws an error, which will cause the Lambda function to retry
|
|
40
45
|
// the event and eventually send it to your dead-letter queue. If you don't
|
|
41
46
|
// trust your source to provide consistently well-formed input, consider
|
|
42
47
|
// catching and handling this error in code.
|
|
43
|
-
const publishedJob = validateJson(
|
|
48
|
+
const publishedJob = validateJson(body, JobPublishedEventSchema);
|
|
44
49
|
|
|
45
50
|
const scoredJob = await scoreJobPublishedEvent(publishedJob);
|
|
46
51
|
|
|
47
52
|
const snsMessageId = await sendPipelineEvent(scoredJob);
|
|
48
53
|
|
|
49
|
-
logger.
|
|
54
|
+
logger.debug({ snsMessageId }, 'Scored job');
|
|
50
55
|
|
|
51
56
|
metricsClient.distribution('job.scored', 1);
|
|
52
57
|
});
|
|
@@ -18,7 +18,7 @@ describe('createHandler', () => {
|
|
|
18
18
|
const handler = createHandler((event) => {
|
|
19
19
|
expect(event).toBe(input);
|
|
20
20
|
|
|
21
|
-
logger.
|
|
21
|
+
logger.debug('Handler invoked');
|
|
22
22
|
|
|
23
23
|
return Promise.resolve(output);
|
|
24
24
|
});
|
|
@@ -27,7 +27,7 @@ describe('createHandler', () => {
|
|
|
27
27
|
|
|
28
28
|
expect(logger.error).not.toHaveBeenCalled();
|
|
29
29
|
|
|
30
|
-
expect(logger.
|
|
30
|
+
expect(logger.debug.mock.calls).toEqual([
|
|
31
31
|
['Handler invoked'],
|
|
32
32
|
['Function succeeded'],
|
|
33
33
|
]);
|
|
@@ -42,7 +42,7 @@ describe('createHandler', () => {
|
|
|
42
42
|
|
|
43
43
|
expect(logger.error).toHaveBeenCalledWith({ err }, 'Function failed');
|
|
44
44
|
|
|
45
|
-
expect(logger.
|
|
45
|
+
expect(logger.debug).not.toHaveBeenCalled();
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
it('handles sync error', async () => {
|
|
@@ -56,6 +56,6 @@ describe('createHandler', () => {
|
|
|
56
56
|
|
|
57
57
|
expect(logger.error).toHaveBeenCalledWith({ err }, 'Function failed');
|
|
58
58
|
|
|
59
|
-
expect(logger.
|
|
59
|
+
expect(logger.debug).not.toHaveBeenCalled();
|
|
60
60
|
});
|
|
61
61
|
});
|