milkio 1.0.0-alpha.56 → 1.0.0-alpha.58
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 +2 -2
- package/bootstrap/index.ts +7 -0
- package/{events → event}/index.ts +1 -0
- package/exception/index.ts +1 -1
- package/handler/index.ts +7 -0
- package/index.ts +3 -1
- package/package.json +2 -2
- package/stream/index.ts +2 -2
- package/types/index.ts +1 -0
- package/world/index.ts +3 -1
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
|
|
10
|
+
export type ActionInit = {
|
|
11
11
|
meta?: $meta
|
|
12
12
|
handler: (context: $context, params: any) => Promise<unknown>
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export
|
|
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 }
|
package/exception/index.ts
CHANGED
|
@@ -21,7 +21,7 @@ export function reject<Code extends keyof $rejectCode, RejectData extends $rejec
|
|
|
21
21
|
return error
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export
|
|
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'
|
package/handler/index.ts
ADDED
package/index.ts
CHANGED
|
@@ -3,7 +3,9 @@ export * from '@southern-aurora/tson'
|
|
|
3
3
|
export * from './types'
|
|
4
4
|
export * from './config'
|
|
5
5
|
export * from './execute'
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './bootstrap'
|
|
7
|
+
export * from './event'
|
|
8
|
+
export * from './handler'
|
|
7
9
|
export * from './world'
|
|
8
10
|
export * from './command'
|
|
9
11
|
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.
|
|
4
|
+
"version": "1.0.0-alpha.58",
|
|
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.
|
|
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
|
|
10
|
+
export type StreamInit = {
|
|
11
11
|
meta?: $meta
|
|
12
12
|
handler: (context: $context, params: any) => AsyncGenerator<unknown>
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export
|
|
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
package/world/index.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface MilkioInit {
|
|
|
17
17
|
executeId?: (request: Request) => string | Promise<string>
|
|
18
18
|
onLoggerSubmitting?: LoggerSubmittingHandler
|
|
19
19
|
onLoggerInserting?: LoggerInsertingHandler
|
|
20
|
-
bootstraps?: Array<(world: MilkioWorld
|
|
20
|
+
bootstraps?: Array<(world: MilkioWorld) => Promise<void> | void>
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export type MilkioRuntimeInit<T extends MilkioInit> = Mixin<
|
|
@@ -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
|
|