milkio 0.1.1 → 0.1.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 (2) hide show
  1. package/kernel/milkio.ts +4 -4
  2. package/package.json +1 -1
package/kernel/milkio.ts CHANGED
@@ -5,7 +5,7 @@ import type { Context } from "../../../src/context"
5
5
  import { failCode } from "../../../src/fail-code"
6
6
  import type { MilkioContext } from "./context"
7
7
  import { headerToPlainObject } from "../utils/header-to-plain-object"
8
- import { type Mixin, type ExecuteId, type Fail, type FailEnumerates, loggerPushTags, loggerSubmit, runtime, TSON, type Logger, useLogger } from ".."
8
+ import { type Mixin, type ExecuteId, type Fail, type FailEnumerates, loggerPushTags, loggerSubmit, runtime, TSON, type Logger, useLogger, reject } from ".."
9
9
  import { hanldeCatchError } from "../utils/handle-catch-error"
10
10
  import { createUlid } from "../utils/create-ulid"
11
11
  import { _validate } from "./validate"
@@ -167,7 +167,7 @@ async function _executeCore<Path extends keyof (typeof schema)["apiMethodsTypeSc
167
167
  // check type
168
168
  // @ts-ignore
169
169
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
170
- try { fn = await schema.apiValidator.validate[path]() } catch (error) { exit(439913) }
170
+ try { fn = await schema.apiValidator.validate[path]() } catch (error) { throw reject('BUSINESS_FAIL', 'This is the new API, which takes effect after restarting the server or saving any changes.') }
171
171
 
172
172
  params = _validate(await fn.validateParams(params))
173
173
 
@@ -204,7 +204,7 @@ async function _executeCore<Path extends keyof (typeof schema)["apiMethodsTypeSc
204
204
  async function _executeToJson<Path extends keyof (typeof schema)["apiMethodsTypeSchema"]>(path: Path, params: Parameters<(typeof schema)["apiMethodsTypeSchema"][Path]["api"]["action"]>[0] | string, headersInit: Record<string, string> | Headers = {}, options?: ExecuteOptions): Promise<string> {
205
205
  const resultsRaw = await _execute(path, params, headersInit, options)
206
206
  let fn: any
207
- try { fn = await schema.apiValidator.validate[path]() } catch (error) { exit(439913) }
207
+ try { fn = await schema.apiValidator.validate[path]() } catch (error) { throw reject('BUSINESS_FAIL', 'This is the new API, which takes effect after restarting the server or saving any changes.') }
208
208
  const results = await fn.validateResults(TSON.encode(resultsRaw))
209
209
  return results
210
210
  }
@@ -212,7 +212,7 @@ async function _executeToJson<Path extends keyof (typeof schema)["apiMethodsType
212
212
  async function _executeCoreToJson<Path extends keyof (typeof schema)["apiMethodsTypeSchema"]>(path: Path, params: Parameters<(typeof schema)["apiMethodsTypeSchema"][Path]["api"]["action"]>[0] | string, headersInit: Record<string, string> | Headers = {}, options: ExecuteCoreOptions): Promise<string> {
213
213
  const resultsRaw = await _executeCore(path, params, headersInit, options)
214
214
  let fn: any
215
- try { fn = await schema.apiValidator.validate[path]() } catch (error) { exit(439913) }
215
+ try { fn = await schema.apiValidator.validate[path]() } catch (error) { throw reject('BUSINESS_FAIL', 'This is the new API, which takes effect after restarting the server or saving any changes.') }
216
216
  const results = await fn.validateResults(TSON.encode(resultsRaw))
217
217
  return results
218
218
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "milkio",
3
3
  "type": "module",
4
4
  "module": "index.ts",
5
- "version": "0.1.1",
5
+ "version": "0.1.2",
6
6
  "peerDependencies": {
7
7
  "typescript": "^5.4.2"
8
8
  },