milkio 1.0.0-alpha.56 → 1.0.0-alpha.57

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/action/index.ts CHANGED
@@ -7,12 +7,12 @@ export function action<ActionInitT extends ActionInit>(init: ActionInitT): Actio
7
7
  return action
8
8
  }
9
9
 
10
- export interface ActionInit {
10
+ export type ActionInit = {
11
11
  meta?: $meta
12
12
  handler: (context: $context, params: any) => Promise<unknown>
13
13
  }
14
14
 
15
- export interface Action<ActionInitT extends ActionInit> {
15
+ export type Action<ActionInitT extends ActionInit> = {
16
16
  $milkioType: 'action'
17
17
  meta: ActionInitT['meta'] extends undefined ? {} : ActionInitT['meta']
18
18
  handler: ActionInitT['handler']
@@ -1,5 +1,6 @@
1
1
  import type { $context, ContextHttp, Results, Logger, $meta } from '..'
2
2
 
3
+
3
4
  export interface $events {
4
5
  'milkio:httpRequest': { executeId: string, path: string, logger: Logger, http: ContextHttp<Record<string, any>> }
5
6
  'milkio:httpResponse': { executeId: string, path: string, logger: Logger, http: ContextHttp<Record<string, any>>, context: $context }
@@ -21,7 +21,7 @@ export function reject<Code extends keyof $rejectCode, RejectData extends $rejec
21
21
  return error
22
22
  }
23
23
 
24
- export interface MilkioRejectError<Code extends keyof $rejectCode = keyof $rejectCode, RejectData extends $rejectCode[Code] = $rejectCode[Code]> { code: Code, data: RejectData, stack: string, $milkioReject: true }
24
+ export type MilkioRejectError<Code extends keyof $rejectCode = keyof $rejectCode, RejectData extends $rejectCode[Code] = $rejectCode[Code]> = { code: Code, data: RejectData, stack: string, $milkioReject: true }
25
25
 
26
26
  export function exceptionHandler(executeId: string, logger: Logger, error: MilkioRejectError<any, any> | any): MilkioResponseReject {
27
27
  const name = error?.code ?? error?.name ?? error?.constructor?.name ?? 'Unnamed Exception'
@@ -0,0 +1,7 @@
1
+ import type { $context, ContextHttp, Results, Logger, $meta, MilkioWorld } from '..'
2
+
3
+ export function handler<HandlerInitT extends HandlerInit>(init: HandlerInitT): HandlerInitT {
4
+ return init
5
+ }
6
+
7
+ export type HandlerInit = (world: MilkioWorld) => Promise<void> | void
package/index.ts CHANGED
@@ -3,7 +3,8 @@ export * from '@southern-aurora/tson'
3
3
  export * from './types'
4
4
  export * from './config'
5
5
  export * from './execute'
6
- export * from './events'
6
+ export * from './event'
7
+ export * from './handler'
7
8
  export * from './world'
8
9
  export * from './command'
9
10
  export * from './action'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "milkio",
3
3
  "type": "module",
4
- "version": "1.0.0-alpha.56",
4
+ "version": "1.0.0-alpha.57",
5
5
  "module": "index.ts",
6
6
  "scripts": {},
7
7
  "peerDependencies": {
@@ -12,7 +12,7 @@
12
12
  "@southern-aurora/tson": "*",
13
13
  "chalk": "^5.3.0",
14
14
  "date-fns": "^4.1.0",
15
- "milkid": "2.0.6",
15
+ "milkid": "2.0.7",
16
16
  "typia": "6.11.3"
17
17
  },
18
18
  "devDependencies": {
package/stream/index.ts CHANGED
@@ -7,12 +7,12 @@ export function stream<StreamInitT extends StreamInit>(init: StreamInitT): Strea
7
7
  return stream
8
8
  }
9
9
 
10
- export interface StreamInit {
10
+ export type StreamInit = {
11
11
  meta?: $meta
12
12
  handler: (context: $context, params: any) => AsyncGenerator<unknown>
13
13
  }
14
14
 
15
- export interface Stream<StreamInitT extends StreamInit> {
15
+ export type Stream<StreamInitT extends StreamInit> = {
16
16
  $milkioType: 'stream'
17
17
  meta: StreamInitT['meta'] extends undefined ? {} : StreamInitT['meta']
18
18
  handler: StreamInitT['handler']
package/types/index.ts CHANGED
@@ -28,6 +28,7 @@ export type ExecuteId = string | 'global'
28
28
  export interface GeneratedInit {
29
29
  routeSchema: any
30
30
  commandSchema: any
31
+ handlerSchema: any
31
32
  }
32
33
 
33
34
  export interface Results<T> {
package/world/index.ts CHANGED
@@ -82,6 +82,8 @@ export async function createWorld<MilkioOptions extends MilkioInit>(generated: G
82
82
  }
83
83
  }
84
84
 
85
+ await Promise.all(generated.handlerSchema.loadHandlers(world))
86
+
85
87
  return world as MilkioWorld<MilkioOptions>
86
88
  }
87
89