soonjs 0.0.20 → 0.0.21

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/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Config, defineApi, defineConfig, Meta, Platform, ServiceContext, SoonApp, UserContext } from '.';
1
+ import { Config, defineApi, defineConfig, Meta, Namespace, Platform, ServiceContext, SoonApp, UserContext } from '.';
2
2
  import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
3
3
 
4
4
  type Method = 'get' | 'head' | 'post' | 'put' | 'delete' | 'options' | 'patch' | 'all';
@@ -31,6 +31,14 @@ export type APIOptionsBase = {
31
31
  * api扩展信息
32
32
  */
33
33
  meta?: Meta;
34
+ /**
35
+ * api中间件
36
+ */
37
+ middlewares?: Middleware[];
38
+ /**
39
+ * 命名空间
40
+ */
41
+ namespace?: keyof Namespace;
34
42
  };
35
43
  export type APIOptions = ReturnType<typeof defineApi>;
36
44
  export type Request = {
@@ -46,6 +54,7 @@ export type Request = {
46
54
  reqId: string;
47
55
  requestId: string;
48
56
  ip: string;
57
+ namespace?: keyof Namespace;
49
58
  };
50
59
  export type Response<Body = any> = {
51
60
  headers: OutgoingHttpHeaders;
@@ -75,6 +84,7 @@ export type SoonFetchOptions = {
75
84
  query?: Record<string, string>;
76
85
  ip?: string;
77
86
  platform?: Context['platform'];
87
+ namespace?: keyof Namespace;
78
88
  };
79
89
  export type Middleware = (context: Context, next: () => any) => Promise<void> | void;
80
90
  export type SoonAppOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "soonjs",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",