@innet/server 2.0.0-beta.25 → 2.0.0-beta.26

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.
@@ -2,5 +2,5 @@ import { type ApiEndpoints, type TEndpoint } from '../../types';
2
2
  type KeysWithField<F extends string> = {
3
3
  [K in keyof ApiEndpoints]: F extends keyof ApiEndpoints[K] ? K : never;
4
4
  }[keyof ApiEndpoints];
5
- export declare function useData<F extends Exclude<keyof TEndpoint, 'response'>, K extends KeysWithField<F> = KeysWithField<F>, T extends boolean = false>(from: F, path?: K, withThrow?: T): T extends true ? ApiEndpoints[K][F] : ApiEndpoints[K][F] | undefined;
5
+ export declare function useData<F extends Exclude<keyof TEndpoint, 'response'>, K extends KeysWithField<F> = KeysWithField<F>, T extends boolean = false>(from: F, path?: K, preventThrow?: T): T extends true ? ApiEndpoints[K][F] | undefined : ApiEndpoints[K][F];
6
6
  export {};
@@ -8,16 +8,16 @@ import { useThrow } from '../useThrow/useThrow.es6.js';
8
8
  import { useAction } from '../useAction/useAction.es6.js';
9
9
  import { paramsContext } from '../useParams/useParams.es6.js';
10
10
 
11
- function useData(from, path, withThrow) {
11
+ function useData(from, path, preventThrow) {
12
12
  if (path) {
13
13
  const endpoint = useEndpoint();
14
14
  const endpointKey = `${endpoint.props.method.toUpperCase()}:${endpoint.props.path}`;
15
15
  if (endpointKey !== path) {
16
- if (withThrow) {
17
- useThrow(`<{type}> MUST be in <endpoint> of ${path}`);
16
+ if (preventThrow) {
17
+ return undefined;
18
18
  }
19
19
  else {
20
- return undefined;
20
+ useThrow(`<{type}> MUST be in <endpoint> of ${path}`);
21
21
  }
22
22
  }
23
23
  }
@@ -12,16 +12,16 @@ var useThrow = require('../useThrow/useThrow.js');
12
12
  var useAction = require('../useAction/useAction.js');
13
13
  var useParams = require('../useParams/useParams.js');
14
14
 
15
- function useData(from, path, withThrow) {
15
+ function useData(from, path, preventThrow) {
16
16
  if (path) {
17
17
  const endpoint = useEndpoint.useEndpoint();
18
18
  const endpointKey = `${endpoint.props.method.toUpperCase()}:${endpoint.props.path}`;
19
19
  if (endpointKey !== path) {
20
- if (withThrow) {
21
- useThrow.useThrow(`<{type}> MUST be in <endpoint> of ${path}`);
20
+ if (preventThrow) {
21
+ return undefined;
22
22
  }
23
23
  else {
24
- return undefined;
24
+ useThrow.useThrow(`<{type}> MUST be in <endpoint> of ${path}`);
25
25
  }
26
26
  }
27
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innet/server",
3
- "version": "2.0.0-beta.25",
3
+ "version": "2.0.0-beta.26",
4
4
  "description": "Create server-side application with innet",
5
5
  "main": "index.js",
6
6
  "module": "index.es6.js",