vovk 3.0.0-draft.338 → 3.0.0-draft.339

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/cjs/VovkApp.js CHANGED
@@ -125,9 +125,9 @@ class VovkApp {
125
125
  const handlers = {};
126
126
  const headersList = await (0, headers_1.headers)();
127
127
  const xMeta = headersList.get('x-meta');
128
- const meta = xMeta && JSON.parse(xMeta);
129
- if (meta)
130
- (0, reqMeta_1.default)(req, { clientMetaHeader: meta });
128
+ const xMetaHeader = xMeta && JSON.parse(xMeta);
129
+ if (xMetaHeader)
130
+ (0, reqMeta_1.default)(req, { xMetaHeader });
131
131
  controllers.forEach((staticMethods, controller) => {
132
132
  const prefix = controller._prefix ?? '';
133
133
  Object.entries(staticMethods ?? {}).forEach(([path, staticMethod]) => {
@@ -21,6 +21,12 @@ function progressive(fn, ...args) {
21
21
  }
22
22
  }
23
23
  }
24
+ Object.keys(reg).forEach((key) => {
25
+ if (reg[key].isSettled)
26
+ return;
27
+ reg[key].isSettled = true;
28
+ reg[key].reject(new Error(`The connection was closed without sending a value for "${key}"`));
29
+ });
24
30
  return result;
25
31
  })
26
32
  .catch((error) => {
@@ -26,10 +26,17 @@ const assignSchema = ({ controller, propertyKey, path, options, httpMethod, vovk
26
26
  }
27
27
  const methods = vovkApp.routes[httpMethod].get(controller) ?? {};
28
28
  vovkApp.routes[httpMethod].set(controller, methods);
29
+ if (options?.cors) {
30
+ const optionsMethods = vovkApp.routes.OPTIONS.get(controller) ?? {};
31
+ optionsMethods[path] = (() => { });
32
+ optionsMethods[path]._options = options;
33
+ vovkApp.routes.OPTIONS.set(controller, optionsMethods);
34
+ }
29
35
  const originalMethod = controller[propertyKey];
30
36
  originalMethod._controller = controller;
31
37
  originalMethod._sourceMethod = originalMethod._sourceMethod ?? originalMethod;
32
38
  const schema = originalMethod._sourceMethod._getSchema?.(controller);
39
+ // TODO: Some of these assignments probably not needed anymore
33
40
  originalMethod.schema = schema;
34
41
  originalMethod.fn = originalMethod._sourceMethod?.fn;
35
42
  originalMethod.models = originalMethod._sourceMethod?.models;
package/mjs/VovkApp.js CHANGED
@@ -125,9 +125,9 @@ class VovkApp {
125
125
  const handlers = {};
126
126
  const headersList = await (0, headers_1.headers)();
127
127
  const xMeta = headersList.get('x-meta');
128
- const meta = xMeta && JSON.parse(xMeta);
129
- if (meta)
130
- (0, reqMeta_1.default)(req, { clientMetaHeader: meta });
128
+ const xMetaHeader = xMeta && JSON.parse(xMeta);
129
+ if (xMetaHeader)
130
+ (0, reqMeta_1.default)(req, { xMetaHeader });
131
131
  controllers.forEach((staticMethods, controller) => {
132
132
  const prefix = controller._prefix ?? '';
133
133
  Object.entries(staticMethods ?? {}).forEach(([path, staticMethod]) => {
@@ -21,6 +21,12 @@ function progressive(fn, ...args) {
21
21
  }
22
22
  }
23
23
  }
24
+ Object.keys(reg).forEach((key) => {
25
+ if (reg[key].isSettled)
26
+ return;
27
+ reg[key].isSettled = true;
28
+ reg[key].reject(new Error(`The connection was closed without sending a value for "${key}"`));
29
+ });
24
30
  return result;
25
31
  })
26
32
  .catch((error) => {
@@ -26,10 +26,17 @@ const assignSchema = ({ controller, propertyKey, path, options, httpMethod, vovk
26
26
  }
27
27
  const methods = vovkApp.routes[httpMethod].get(controller) ?? {};
28
28
  vovkApp.routes[httpMethod].set(controller, methods);
29
+ if (options?.cors) {
30
+ const optionsMethods = vovkApp.routes.OPTIONS.get(controller) ?? {};
31
+ optionsMethods[path] = (() => { });
32
+ optionsMethods[path]._options = options;
33
+ vovkApp.routes.OPTIONS.set(controller, optionsMethods);
34
+ }
29
35
  const originalMethod = controller[propertyKey];
30
36
  originalMethod._controller = controller;
31
37
  originalMethod._sourceMethod = originalMethod._sourceMethod ?? originalMethod;
32
38
  const schema = originalMethod._sourceMethod._getSchema?.(controller);
39
+ // TODO: Some of these assignments probably not needed anymore
33
40
  originalMethod.schema = schema;
34
41
  originalMethod.fn = originalMethod._sourceMethod?.fn;
35
42
  originalMethod.models = originalMethod._sourceMethod?.models;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "3.0.0-draft.338",
3
+ "version": "3.0.0-draft.339",
4
4
  "main": "./cjs/index.js",
5
5
  "module": "./mjs/index.js",
6
6
  "types": "./mjs/index.d.ts",