@whook/gcp-functions 9.0.1 → 10.0.2

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.
Files changed (39) hide show
  1. package/README.md +8 -9
  2. package/dist/commands/testHTTPFunction.d.ts +1 -1
  3. package/dist/commands/testHTTPFunction.js +119 -150
  4. package/dist/commands/testHTTPFunction.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +182 -269
  7. package/dist/index.js.map +1 -1
  8. package/dist/libs/utils.js +16 -35
  9. package/dist/libs/utils.js.map +1 -1
  10. package/dist/services/_autoload.d.ts +3 -3
  11. package/dist/services/_autoload.js +83 -109
  12. package/dist/services/_autoload.js.map +1 -1
  13. package/dist/services/log.js +2 -12
  14. package/dist/services/log.js.map +1 -1
  15. package/dist/services/log.test.js +4 -9
  16. package/dist/services/log.test.js.map +1 -1
  17. package/dist/wrappers/googleHTTPFunction.js +246 -294
  18. package/dist/wrappers/googleHTTPFunction.js.map +1 -1
  19. package/package.json +47 -89
  20. package/src/commands/testHTTPFunction.ts +6 -13
  21. package/src/index.ts +36 -54
  22. package/src/libs/utils.ts +3 -4
  23. package/src/services/_autoload.ts +4 -3
  24. package/src/services/log.test.ts +1 -1
  25. package/src/wrappers/googleHTTPFunction.ts +6 -6
  26. package/dist/commands/testHTTPFunction.mjs +0 -136
  27. package/dist/commands/testHTTPFunction.mjs.map +0 -1
  28. package/dist/index.mjs +0 -265
  29. package/dist/index.mjs.map +0 -1
  30. package/dist/libs/utils.mjs +0 -27
  31. package/dist/libs/utils.mjs.map +0 -1
  32. package/dist/services/_autoload.mjs +0 -113
  33. package/dist/services/_autoload.mjs.map +0 -1
  34. package/dist/services/log.mjs +0 -4
  35. package/dist/services/log.mjs.map +0 -1
  36. package/dist/services/log.test.mjs +0 -7
  37. package/dist/services/log.test.mjs.map +0 -1
  38. package/dist/wrappers/googleHTTPFunction.mjs +0 -290
  39. package/dist/wrappers/googleHTTPFunction.mjs.map +0 -1
package/package.json CHANGED
@@ -1,19 +1,18 @@
1
1
  {
2
2
  "name": "@whook/gcp-functions",
3
- "version": "9.0.1",
3
+ "version": "10.0.2",
4
4
  "description": "Build and deploy to GCP Cloud Functions with Whook.",
5
- "main": "dist/index",
6
- "module": "dist/index.mjs",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "metapak": {
9
9
  "configs": [
10
10
  "main",
11
11
  "readme",
12
+ "tsesm",
12
13
  "eslint",
13
- "babel",
14
14
  "jest",
15
- "jsdocs",
16
- "typescript"
15
+ "jsdocs"
17
16
  ],
18
17
  "data": {
19
18
  "childPackage": true,
@@ -50,50 +49,42 @@
50
49
  },
51
50
  "homepage": "https://github.com/nfroidure/whook",
52
51
  "dependencies": {
53
- "@whook/cli": "^9.0.1",
54
- "@whook/cors": "^9.0.1",
55
- "@whook/http-router": "^9.0.1",
56
- "@whook/whook": "^9.0.1",
52
+ "@whook/cli": "^10.0.2",
53
+ "@whook/cors": "^10.0.2",
54
+ "@whook/http-router": "^10.0.2",
55
+ "@whook/whook": "^10.0.2",
57
56
  "ajv": "^8.11.0",
58
57
  "ajv-formats": "^2.1.1",
59
- "camelcase": "^6.3.0",
60
- "common-services": "^10.0.2",
58
+ "camelcase": "^7.0.0",
59
+ "common-services": "^11.0.1",
61
60
  "cpr": "3.0.1",
62
- "knifecycle": "^12.0.4",
61
+ "knifecycle": "^14.0.0",
63
62
  "mkdirp": "^1.0.4",
64
- "openapi-types": "^11.0.1",
63
+ "openapi-types": "^12.0.0",
65
64
  "qs": "^6.10.3",
66
- "strict-qs": "^6.1.5",
67
- "yerror": "^6.0.2"
65
+ "strict-qs": "^7.0.0",
66
+ "yerror": "^6.1.1"
68
67
  },
69
68
  "devDependencies": {
70
- "@babel/cli": "^7.17.10",
71
- "@babel/core": "^7.18.2",
72
- "@babel/eslint-parser": "^7.18.2",
73
- "@babel/plugin-proposal-class-properties": "^7.17.12",
74
- "@babel/plugin-proposal-object-rest-spread": "^7.18.0",
75
- "@babel/plugin-syntax-dynamic-import": "^7.8.3",
76
- "@babel/plugin-syntax-import-meta": "^7.10.4",
77
- "@babel/preset-env": "^7.18.2",
78
- "@babel/preset-typescript": "^7.17.12",
79
- "@babel/register": "^7.17.7",
80
- "@types/jest": "^27.0.2",
81
- "@typescript-eslint/eslint-plugin": "^5.26.0",
82
- "@typescript-eslint/parser": "^5.26.0",
83
- "babel-plugin-knifecycle": "^5.0.3",
84
- "eslint": "^8.16.0",
69
+ "@types/jest": "^28.1.1",
70
+ "@typescript-eslint/eslint-plugin": "^5.27.0",
71
+ "@typescript-eslint/parser": "^5.27.0",
72
+ "esbuild": "^0.14.46",
73
+ "esbuild-jest": "^0.5.0",
74
+ "eslint": "^8.17.0",
75
+ "eslint-config-prettier": "^8.5.0",
85
76
  "eslint-plugin-prettier": "^4.0.0",
86
77
  "jest": "^28.1.0",
87
78
  "jsdoc-to-markdown": "^7.1.1",
88
79
  "metapak": "^4.0.4",
89
- "metapak-nfroidure": "11.2.1",
80
+ "metapak-nfroidure": "12.1.0",
90
81
  "prettier": "^2.6.2",
91
82
  "rimraf": "^3.0.2",
92
- "typescript": "^4.7.2"
83
+ "typescript": "^4.7.3"
93
84
  },
94
85
  "contributors": [],
95
86
  "engines": {
96
- "node": ">=12.19.0"
87
+ "node": ">=16.15.0"
97
88
  },
98
89
  "files": [
99
90
  "dist",
@@ -105,12 +96,13 @@
105
96
  "eslintConfig": {
106
97
  "extends": [
107
98
  "eslint:recommended",
99
+ "plugin:prettier/recommended",
108
100
  "plugin:@typescript-eslint/eslint-recommended",
109
101
  "plugin:@typescript-eslint/recommended"
110
102
  ],
111
103
  "parserOptions": {
112
104
  "ecmaVersion": 2018,
113
- "sourceType": "module",
105
+ "sourceType": "script",
114
106
  "modules": true
115
107
  },
116
108
  "env": {
@@ -137,53 +129,6 @@
137
129
  "trailingComma": "all",
138
130
  "proseWrap": "always"
139
131
  },
140
- "babel": {
141
- "presets": [
142
- "@babel/typescript",
143
- [
144
- "@babel/env",
145
- {
146
- "targets": {
147
- "node": "12.19.0"
148
- }
149
- }
150
- ]
151
- ],
152
- "plugins": [
153
- "@babel/proposal-class-properties",
154
- "@babel/plugin-proposal-object-rest-spread",
155
- "babel-plugin-knifecycle"
156
- ],
157
- "env": {
158
- "cjs": {
159
- "presets": [
160
- [
161
- "@babel/env",
162
- {
163
- "targets": {
164
- "node": "10"
165
- },
166
- "modules": "commonjs"
167
- }
168
- ]
169
- ]
170
- },
171
- "mjs": {
172
- "presets": [
173
- [
174
- "@babel/env",
175
- {
176
- "targets": {
177
- "node": "12"
178
- },
179
- "modules": false
180
- }
181
- ]
182
- ]
183
- }
184
- },
185
- "sourceMaps": true
186
- },
187
132
  "jest": {
188
133
  "coverageReporters": [
189
134
  "lcov",
@@ -194,22 +139,35 @@
194
139
  ],
195
140
  "roots": [
196
141
  "<rootDir>/src"
142
+ ],
143
+ "testEnvironment": "node",
144
+ "transform": {
145
+ "^.+\\.tsx?$": [
146
+ "esbuild-jest",
147
+ {
148
+ "sourcemap": true,
149
+ "format": "esm"
150
+ }
151
+ ]
152
+ },
153
+ "moduleNameMapper": {
154
+ "(.+)\\.js": "$1"
155
+ },
156
+ "extensionsToTreatAsEsm": [
157
+ ".ts"
197
158
  ]
198
159
  },
199
160
  "scripts": {
161
+ "build": "rimraf -f 'dist' && tsc --outDir dist",
200
162
  "cli": "env NODE_ENV=${NODE_ENV:-cli}",
201
- "compile": "rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs",
202
- "compile:cjs": "babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src",
203
- "compile:mjs": "babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src",
204
163
  "cover": "npm run jest -- --coverage",
205
164
  "doc": "echo \"# API\" > API.md; jsdoc2md 'dist/**/*.js' >> API.md && git add API.md",
206
165
  "genPackagelock": "npm i --package-lock-only",
207
- "jest": "NODE_ENV=test jest",
166
+ "jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
208
167
  "lint": "eslint 'src/**/*.ts'",
209
168
  "metapak": "metapak",
210
169
  "prettier": "prettier --write 'src/**/*.ts'",
211
- "test": "npm run jest",
212
- "types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist"
170
+ "test": "npm run jest"
213
171
  },
214
- "gitHead": "a5620b3eacf3b500a5db59db9997bf7ed60668d5"
172
+ "gitHead": "9a91f940bb084998baa83917bf143ec198bdf143"
215
173
  }
@@ -1,18 +1,14 @@
1
- import { loadLambda } from '../libs/utils';
1
+ import { loadLambda } from '../libs/utils.js';
2
2
  import { extra, autoService } from 'knifecycle';
3
3
  import { readArgs } from '@whook/cli';
4
- import YError from 'yerror';
4
+ import { YError } from 'yerror';
5
5
  import {
6
6
  dereferenceOpenAPIOperations,
7
7
  getOpenAPIOperations,
8
8
  } from '@whook/http-router';
9
9
  import stream from 'stream';
10
10
  import camelCase from 'camelcase';
11
- import type {
12
- WhookCommandArgs,
13
- WhookCommandDefinition,
14
- WhookCommandNamedArgs,
15
- } from '@whook/cli';
11
+ import type { WhookCommandArgs, WhookCommandDefinition } from '@whook/cli';
16
12
  import type { LogService } from 'common-services';
17
13
  import type { OpenAPIV3 } from 'openapi-types';
18
14
 
@@ -68,16 +64,13 @@ async function initTestHTTPLambdaCommand({
68
64
  }) {
69
65
  return async () => {
70
66
  const {
71
- name,
72
- type,
73
- contentType,
74
- parameters: rawParameters,
75
- }: WhookCommandNamedArgs = readArgs(definition.arguments, args) as {
67
+ namedArguments: { name, type, contentType, parameters: rawParameters },
68
+ } = readArgs<{
76
69
  name: string;
77
70
  type: string;
78
71
  contentType: string;
79
72
  parameters: string;
80
- };
73
+ }>(definition.arguments, args);
81
74
  const handler = await loadLambda(
82
75
  { PROJECT_DIR, log },
83
76
  NODE_ENV,
package/src/index.ts CHANGED
@@ -4,14 +4,16 @@ import util from 'util';
4
4
  import path from 'path';
5
5
  import mkdirp from 'mkdirp';
6
6
  import cpr from 'cpr';
7
- import YError from 'yerror';
8
- import Knifecycle, {
7
+ import { YError } from 'yerror';
8
+ import { createRequire } from 'module';
9
+ import {
10
+ Knifecycle,
9
11
  SPECIAL_PROPS,
10
12
  constant,
11
13
  initInitializerBuilder,
12
14
  } from 'knifecycle';
13
- import { DEFAULT_BUILD_OPTIONS, initCompiler } from '@whook/whook';
14
- import initBuildAutoloader from './services/_autoload';
15
+ import { initCompiler } from '@whook/whook';
16
+ import initBuildAutoloader from './services/_autoload.js';
15
17
  import {
16
18
  dereferenceOpenAPIOperations,
17
19
  getOpenAPIOperations,
@@ -25,7 +27,6 @@ import type {
25
27
  } from 'knifecycle';
26
28
  import type {
27
29
  WhookOperation,
28
- WhookCompilerConfig,
29
30
  WhookCompilerOptions,
30
31
  WhookCompilerService,
31
32
  } from '@whook/whook';
@@ -61,6 +62,9 @@ const cprAsync = util.promisify(cpr) as (
61
62
  options: CprOptions,
62
63
  ) => Promise<string[]>;
63
64
 
65
+ // TODO: Use import.meta when Jest will support it
66
+ const require = createRequire(path.join(process.cwd(), 'src', 'index.ts'));
67
+
64
68
  const BUILD_DEFINITIONS: Record<
65
69
  NonNullable<WhookAPIOperationGCPFunctionConfig['type']>,
66
70
  {
@@ -73,7 +77,10 @@ const BUILD_DEFINITIONS: Record<
73
77
  type: 'HTTP',
74
78
  wrapper: {
75
79
  name: 'wrapHandlerForGoogleHTTPFunction',
76
- path: path.join(__dirname, 'wrappers', 'googleHTTPFunction'),
80
+ path: path.join(
81
+ path.dirname(require.resolve('@whook/gcp-function')),
82
+ 'wrappers/googleHTTPFunction.js',
83
+ ),
77
84
  },
78
85
  suffix: 'Wrapped',
79
86
  },
@@ -85,7 +92,7 @@ export async function prepareBuildEnvironment<T extends Knifecycle>(
85
92
  $.register(
86
93
  constant('INITIALIZER_PATH_MAP', {
87
94
  ENV: '@whook/whook/dist/services/ProxyedENV',
88
- log: __dirname + '/services/log',
95
+ log: '@whook/gcp-functions/dist/services/log',
89
96
  time: 'common-services/dist/time',
90
97
  delay: 'common-services/dist/delay',
91
98
  }),
@@ -108,26 +115,23 @@ export async function runBuild(
108
115
  const {
109
116
  NODE_ENV,
110
117
  BUILD_PARALLELISM,
111
- BUILD_OPTIONS,
112
118
  PROJECT_DIR,
113
119
  compiler,
114
120
  log,
115
121
  $autoload,
116
122
  API,
117
123
  buildInitializer,
118
- }: WhookGCPBuildConfig &
119
- Pick<WhookCompilerConfig, 'BUILD_OPTIONS'> & {
120
- NODE_ENV: string;
121
- PROJECT_DIR: string;
122
- compiler: WhookCompilerService;
123
- log: LogService;
124
- $autoload: Autoloader<Initializer<Dependencies, Service>>;
125
- API: OpenAPIV3.Document;
126
- buildInitializer: BuildInitializer;
127
- } = await $.run([
124
+ }: WhookGCPBuildConfig & {
125
+ NODE_ENV: string;
126
+ PROJECT_DIR: string;
127
+ compiler: WhookCompilerService;
128
+ log: LogService;
129
+ $autoload: Autoloader<Initializer<Dependencies, Service>>;
130
+ API: OpenAPIV3.Document;
131
+ buildInitializer: BuildInitializer;
132
+ } = await $.run([
128
133
  'NODE_ENV',
129
134
  '?BUILD_PARALLELISM',
130
- '?BUILD_OPTIONS',
131
135
  'PROJECT_DIR',
132
136
  'process',
133
137
  'compiler',
@@ -161,7 +165,6 @@ export async function runBuild(
161
165
  await processOperations(
162
166
  {
163
167
  NODE_ENV,
164
- BUILD_OPTIONS: BUILD_OPTIONS || DEFAULT_BUILD_OPTIONS,
165
168
  BUILD_PARALLELISM: BUILD_PARALLELISM || DEFAULT_BUILD_PARALLELISM,
166
169
  PROJECT_DIR,
167
170
  compiler,
@@ -187,15 +190,13 @@ async function processOperations(
187
190
  {
188
191
  NODE_ENV,
189
192
  BUILD_PARALLELISM,
190
- BUILD_OPTIONS,
191
193
  PROJECT_DIR,
192
194
  compiler,
193
195
  log,
194
196
  $autoload,
195
197
  buildInitializer,
196
- }: Required<Pick<WhookCompilerConfig, 'BUILD_OPTIONS'>> & {
198
+ }: WhookGCPBuildConfig & {
197
199
  NODE_ENV: string;
198
- BUILD_PARALLELISM: number;
199
200
  PROJECT_DIR: string;
200
201
  compiler: WhookCompilerService;
201
202
  log: LogService;
@@ -212,7 +213,6 @@ async function processOperations(
212
213
  {
213
214
  NODE_ENV,
214
215
  PROJECT_DIR,
215
- BUILD_OPTIONS,
216
216
  compiler,
217
217
  log,
218
218
  $autoload,
@@ -229,7 +229,6 @@ async function processOperations(
229
229
  {
230
230
  NODE_ENV,
231
231
  BUILD_PARALLELISM,
232
- BUILD_OPTIONS,
233
232
  PROJECT_DIR,
234
233
  compiler,
235
234
  log,
@@ -246,12 +245,11 @@ async function buildAnyLambda(
246
245
  {
247
246
  NODE_ENV,
248
247
  PROJECT_DIR,
249
- BUILD_OPTIONS,
250
248
  compiler,
251
249
  log,
252
250
  $autoload,
253
251
  buildInitializer,
254
- }: Required<Pick<WhookCompilerConfig, 'BUILD_OPTIONS'>> & {
252
+ }: {
255
253
  NODE_ENV: string;
256
254
  PROJECT_DIR: string;
257
255
  compiler: WhookCompilerService;
@@ -264,8 +262,9 @@ async function buildAnyLambda(
264
262
  const { operationId } = operation;
265
263
 
266
264
  try {
267
- const whookConfig: WhookAPIOperationGCPFunctionConfig =
268
- operation['x-whook'] || {};
265
+ const whookConfig: WhookAPIOperationGCPFunctionConfig = operation[
266
+ 'x-whook'
267
+ ] || { type: 'http' };
269
268
  const operationType = whookConfig.type || 'http';
270
269
  const sourceOperationId = whookConfig.sourceOperationId;
271
270
  const entryPoint = operationId;
@@ -275,7 +274,7 @@ async function buildAnyLambda(
275
274
  log('warning', `Building ${operationType} "${finalEntryPoint}"...`);
276
275
  const buildDefinition = BUILD_DEFINITIONS[operationType];
277
276
  // eslint-disable-next-line
278
- const applyWrapper = require(buildDefinition.wrapper.path).default;
277
+ const applyWrapper = (await import(buildDefinition.wrapper.path)).default;
279
278
  const rootNode = await $autoload(
280
279
  entryPoint + (buildDefinition.suffix || ''),
281
280
  );
@@ -293,16 +292,11 @@ async function buildAnyLambda(
293
292
  ? `OPERATION_API>OPERATION_API_${finalEntryPoint}`
294
293
  : name,
295
294
  ),
296
- BUILD_OPTIONS,
297
- );
298
- const indexContent = await buildLambdaIndex(
299
- rootNode,
300
- {
301
- name: buildDefinition.wrapper.name,
302
- path: buildDefinition.wrapper.path,
303
- },
304
- BUILD_OPTIONS,
305
295
  );
296
+ const indexContent = await buildLambdaIndex(rootNode, {
297
+ name: buildDefinition.wrapper.name,
298
+ path: buildDefinition.wrapper.path,
299
+ });
306
300
 
307
301
  await mkdirp(lambdaPath);
308
302
  await Promise.all([
@@ -330,18 +324,10 @@ async function buildAnyLambda(
330
324
  async function buildLambdaIndex(
331
325
  rootNode: { path: string },
332
326
  buildWrapper: { name: string; path: string },
333
- options: NonNullable<WhookCompilerConfig['BUILD_OPTIONS']>,
334
327
  ): Promise<string> {
335
- return `${
336
- options.modules === 'commonjs'
337
- ? `const pickModule = (m) => { return m && m.default || m; }
338
- const initHandler = pickModule(require('${rootNode.path}'));
339
- const ${buildWrapper.name} = pickModule(require('${buildWrapper.path}'));
340
- const { initialize } = require('./initialize');`
341
- : `import initHandler from '${rootNode.path}';
328
+ return `import initHandler from '${rootNode.path}';
342
329
  import ${buildWrapper.name} from '${buildWrapper.path}';
343
- import { initialize } from './initialize';`
344
- }
330
+ import { initialize } from './initialize.js';
345
331
 
346
332
  const handlerInitializer = ${buildWrapper.name}(
347
333
  initHandler
@@ -350,11 +336,7 @@ const handlerInitializer = ${buildWrapper.name}(
350
336
  const handlerPromise = initialize()
351
337
  .then(handlerInitializer);
352
338
 
353
- ${
354
- options.modules === 'commonjs'
355
- ? 'module.exports = {}; module.exports.default = '
356
- : 'export default '
357
- }function handler (req, res) {
339
+ export default function handler (req, res) {
358
340
  return handlerPromise
359
341
  .then(handler => handler(req, res));
360
342
  };
package/src/libs/utils.ts CHANGED
@@ -1,4 +1,4 @@
1
- import YError from 'yerror';
1
+ import { YError } from 'yerror';
2
2
  import path from 'path';
3
3
  import type { LogService } from 'common-services';
4
4
 
@@ -19,14 +19,13 @@ export async function loadLambda(
19
19
  'builds',
20
20
  target,
21
21
  operationId,
22
- type,
22
+ type + '.js',
23
23
  );
24
24
 
25
25
  log('debug', `⛏️ - Loading lambda module at path "${modulePath}".`);
26
26
 
27
27
  try {
28
- // eslint-disable-next-line
29
- const module = require(modulePath);
28
+ const module = await import(modulePath);
30
29
 
31
30
  if (!module) {
32
31
  throw new YError('E_MODULE_NOT_FOUND', module);
@@ -1,11 +1,12 @@
1
1
  import { initAutoload, noop, cleanupOpenAPI } from '@whook/whook';
2
- import Knifecycle, {
2
+ import {
3
+ Knifecycle,
3
4
  SPECIAL_PROPS,
4
5
  wrapInitializer,
5
6
  constant,
6
7
  alsoInject,
7
8
  } from 'knifecycle';
8
- import YError from 'yerror';
9
+ import { YError } from 'yerror';
9
10
  import {
10
11
  dereferenceOpenAPIOperations,
11
12
  getOpenAPIOperations,
@@ -22,7 +23,7 @@ import type { WhookBuildConstantsService } from '@whook/whook';
22
23
  import type { WhookRawOperation } from '@whook/http-router';
23
24
  import type { LogService } from 'common-services';
24
25
  import type { OpenAPIV3 } from 'openapi-types';
25
- import type { WhookAPIOperationGCPFunctionConfig } from '..';
26
+ import type { WhookAPIOperationGCPFunctionConfig } from '../index.js';
26
27
 
27
28
  const initializerWrapper: ServiceInitializerWrapper<
28
29
  Autoloader<Initializer<Dependencies, Service>>,
@@ -1,4 +1,4 @@
1
- import initLogService from './log';
1
+ import initLogService from './log.js';
2
2
 
3
3
  describe('initLogService', () => {
4
4
  it('should work', async () => {
@@ -9,10 +9,10 @@ import {
9
9
  castParameters,
10
10
  } from '@whook/http-router';
11
11
  import { reuseSpecialProps, alsoInject } from 'knifecycle';
12
- import Ajv from 'ajv';
13
- import addAJVFormats from 'ajv-formats';
12
+ import { default as Ajv } from 'ajv';
13
+ import { default as addAJVFormats } from 'ajv-formats';
14
14
  import bytes from 'bytes';
15
- import HTTPError from 'yhttperror';
15
+ import { YHTTPError } from 'yhttperror';
16
16
  import {
17
17
  prepareParametersValidators,
18
18
  prepareBodyValidator,
@@ -328,7 +328,7 @@ async function handleForAWSHTTPFunction(
328
328
  ...('undefined' !== typeof body ? { body } : {}),
329
329
  };
330
330
  } catch (err) {
331
- throw HTTPError.cast(err as Error, 400);
331
+ throw YHTTPError.cast(err as Error, 400);
332
332
  }
333
333
 
334
334
  response = await executeHandler(operation, handler, parameters);
@@ -354,7 +354,7 @@ async function handleForAWSHTTPFunction(
354
354
  (responseSchema.type !== 'string' || responseSchema.format !== 'binary');
355
355
 
356
356
  if (responseHasSchema && !STRINGIFYERS[response.headers['content-type']]) {
357
- throw new HTTPError(
357
+ throw new YHTTPError(
358
358
  500,
359
359
  'E_STRINGIFYER_LACK',
360
360
  response.headers['content-type'],
@@ -370,7 +370,7 @@ async function handleForAWSHTTPFunction(
370
370
  };
371
371
  log?.('debug', JSON.stringify(responseLog));
372
372
  } catch (err) {
373
- const castedError = HTTPError.cast(err as Error);
373
+ const castedError = YHTTPError.cast(err as Error);
374
374
 
375
375
  responseLog = {
376
376
  type: 'error',