@noxfly/noxus 3.0.0-dev.8 → 3.0.0
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/LICENSE +20 -20
- package/README.md +686 -686
- package/dist/child.d.mts +1 -1
- package/dist/child.d.ts +1 -1
- package/dist/child.js +39 -39
- package/dist/child.js.map +1 -1
- package/dist/child.mjs +39 -39
- package/dist/child.mjs.map +1 -1
- package/dist/main.d.mts +18 -7
- package/dist/main.d.ts +18 -7
- package/dist/main.js +188 -108
- package/dist/main.js.map +1 -1
- package/dist/main.mjs +189 -108
- package/dist/main.mjs.map +1 -1
- package/dist/preload.js.map +1 -1
- package/dist/preload.mjs.map +1 -1
- package/dist/renderer.js +40 -24
- package/dist/renderer.js.map +1 -1
- package/dist/renderer.mjs +40 -24
- package/dist/renderer.mjs.map +1 -1
- package/package.json +99 -94
- package/dist/app-injector-Bz3Upc0y.d.mts +0 -125
- package/dist/app-injector-Bz3Upc0y.d.ts +0 -125
- package/dist/request-BlTtiHbi.d.ts +0 -112
- package/dist/request-qJ9EiDZc.d.mts +0 -112
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { M as MaybeAsync, A as AppInjector } from './app-injector-Bz3Upc0y.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @copyright 2025 NoxFly
|
|
5
|
-
* @license MIT
|
|
6
|
-
* @author NoxFly
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A guard decides whether an incoming request should reach the handler.
|
|
11
|
-
* Implement this interface and pass the class to @Controller({ guards }) or @Get('path', { guards }).
|
|
12
|
-
*/
|
|
13
|
-
type Guard = (request: Request) => MaybeAsync<boolean>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* A middleware intercepts requests before they reach guards and the handler.
|
|
18
|
-
* Implement this interface and pass the class to @Controller({ middlewares }) or per-route options.
|
|
19
|
-
*/
|
|
20
|
-
type Middleware = (request: Request, response: IResponse, next: NextFunction) => MaybeAsync<void>;
|
|
21
|
-
type NextFunction = () => Promise<void>;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'BATCH';
|
|
25
|
-
type AtomicHttpMethod = Exclude<HttpMethod, 'BATCH'>;
|
|
26
|
-
declare function isAtomicHttpMethod(m: unknown): m is AtomicHttpMethod;
|
|
27
|
-
interface IRouteOptions {
|
|
28
|
-
/**
|
|
29
|
-
* Guards specific to this route (merged with controller guards).
|
|
30
|
-
*/
|
|
31
|
-
guards?: Guard[];
|
|
32
|
-
/**
|
|
33
|
-
* Middlewares specific to this route (merged with controller middlewares).
|
|
34
|
-
*/
|
|
35
|
-
middlewares?: Middleware[];
|
|
36
|
-
}
|
|
37
|
-
interface IRouteMetadata {
|
|
38
|
-
method: HttpMethod;
|
|
39
|
-
path: string;
|
|
40
|
-
handler: string;
|
|
41
|
-
guards: Guard[];
|
|
42
|
-
middlewares: Middleware[];
|
|
43
|
-
}
|
|
44
|
-
declare function getRouteMetadata(target: object): IRouteMetadata[];
|
|
45
|
-
declare const Get: (path: string, options?: IRouteOptions) => MethodDecorator;
|
|
46
|
-
declare const Post: (path: string, options?: IRouteOptions) => MethodDecorator;
|
|
47
|
-
declare const Put: (path: string, options?: IRouteOptions) => MethodDecorator;
|
|
48
|
-
declare const Patch: (path: string, options?: IRouteOptions) => MethodDecorator;
|
|
49
|
-
declare const Delete: (path: string, options?: IRouteOptions) => MethodDecorator;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* The Request class represents an HTTP request in the Noxus framework.
|
|
54
|
-
* It encapsulates the request data, including the event, ID, method, path, and body.
|
|
55
|
-
* It also provides a context for dependency injection through the AppInjector.
|
|
56
|
-
*/
|
|
57
|
-
declare class Request {
|
|
58
|
-
readonly event: Electron.MessageEvent;
|
|
59
|
-
readonly senderId: number;
|
|
60
|
-
readonly id: string;
|
|
61
|
-
readonly method: HttpMethod;
|
|
62
|
-
readonly path: string;
|
|
63
|
-
readonly body: any;
|
|
64
|
-
readonly context: AppInjector;
|
|
65
|
-
readonly params: Record<string, string>;
|
|
66
|
-
constructor(event: Electron.MessageEvent, senderId: number, id: string, method: HttpMethod, path: string, body: any);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* The IRequest interface defines the structure of a request object.
|
|
70
|
-
* It includes properties for the sender ID, request ID, path, method, and an optional body.
|
|
71
|
-
* This interface is used to standardize the request data across the application.
|
|
72
|
-
*/
|
|
73
|
-
interface IRequest<TBody = unknown> {
|
|
74
|
-
senderId: number;
|
|
75
|
-
requestId: string;
|
|
76
|
-
path: string;
|
|
77
|
-
method: HttpMethod;
|
|
78
|
-
body?: TBody;
|
|
79
|
-
}
|
|
80
|
-
interface IBatchRequestItem<TBody = unknown> {
|
|
81
|
-
requestId?: string;
|
|
82
|
-
path: string;
|
|
83
|
-
method: AtomicHttpMethod;
|
|
84
|
-
body?: TBody;
|
|
85
|
-
}
|
|
86
|
-
interface IBatchRequestPayload {
|
|
87
|
-
requests: IBatchRequestItem[];
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Creates a Request object from the IPC event data.
|
|
91
|
-
* This function extracts the necessary information from the IPC event and constructs a Request instance.
|
|
92
|
-
*/
|
|
93
|
-
interface IResponse<TBody = unknown> {
|
|
94
|
-
requestId: string;
|
|
95
|
-
status: number;
|
|
96
|
-
body?: TBody;
|
|
97
|
-
error?: string;
|
|
98
|
-
stack?: string;
|
|
99
|
-
}
|
|
100
|
-
interface IBatchResponsePayload {
|
|
101
|
-
responses: IResponse[];
|
|
102
|
-
}
|
|
103
|
-
declare const RENDERER_EVENT_TYPE = "noxus:event";
|
|
104
|
-
interface IRendererEventMessage<TPayload = unknown> {
|
|
105
|
-
type: typeof RENDERER_EVENT_TYPE;
|
|
106
|
-
event: string;
|
|
107
|
-
payload?: TPayload;
|
|
108
|
-
}
|
|
109
|
-
declare function createRendererEventMessage<TPayload = unknown>(event: string, payload?: TPayload): IRendererEventMessage<TPayload>;
|
|
110
|
-
declare function isRendererEventMessage(value: unknown): value is IRendererEventMessage;
|
|
111
|
-
|
|
112
|
-
export { type AtomicHttpMethod as A, Delete as D, type Guard as G, type HttpMethod as H, type IRendererEventMessage as I, type Middleware as M, type NextFunction as N, Patch as P, RENDERER_EVENT_TYPE as R, type IResponse as a, type IRequest as b, type IBatchRequestItem as c, type IBatchResponsePayload as d, type IBatchRequestPayload as e, Request as f, createRendererEventMessage as g, Get as h, isRendererEventMessage as i, type IRouteMetadata as j, type IRouteOptions as k, Post as l, Put as m, getRouteMetadata as n, isAtomicHttpMethod as o };
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { M as MaybeAsync, A as AppInjector } from './app-injector-Bz3Upc0y.mjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @copyright 2025 NoxFly
|
|
5
|
-
* @license MIT
|
|
6
|
-
* @author NoxFly
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A guard decides whether an incoming request should reach the handler.
|
|
11
|
-
* Implement this interface and pass the class to @Controller({ guards }) or @Get('path', { guards }).
|
|
12
|
-
*/
|
|
13
|
-
type Guard = (request: Request) => MaybeAsync<boolean>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* A middleware intercepts requests before they reach guards and the handler.
|
|
18
|
-
* Implement this interface and pass the class to @Controller({ middlewares }) or per-route options.
|
|
19
|
-
*/
|
|
20
|
-
type Middleware = (request: Request, response: IResponse, next: NextFunction) => MaybeAsync<void>;
|
|
21
|
-
type NextFunction = () => Promise<void>;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'BATCH';
|
|
25
|
-
type AtomicHttpMethod = Exclude<HttpMethod, 'BATCH'>;
|
|
26
|
-
declare function isAtomicHttpMethod(m: unknown): m is AtomicHttpMethod;
|
|
27
|
-
interface IRouteOptions {
|
|
28
|
-
/**
|
|
29
|
-
* Guards specific to this route (merged with controller guards).
|
|
30
|
-
*/
|
|
31
|
-
guards?: Guard[];
|
|
32
|
-
/**
|
|
33
|
-
* Middlewares specific to this route (merged with controller middlewares).
|
|
34
|
-
*/
|
|
35
|
-
middlewares?: Middleware[];
|
|
36
|
-
}
|
|
37
|
-
interface IRouteMetadata {
|
|
38
|
-
method: HttpMethod;
|
|
39
|
-
path: string;
|
|
40
|
-
handler: string;
|
|
41
|
-
guards: Guard[];
|
|
42
|
-
middlewares: Middleware[];
|
|
43
|
-
}
|
|
44
|
-
declare function getRouteMetadata(target: object): IRouteMetadata[];
|
|
45
|
-
declare const Get: (path: string, options?: IRouteOptions) => MethodDecorator;
|
|
46
|
-
declare const Post: (path: string, options?: IRouteOptions) => MethodDecorator;
|
|
47
|
-
declare const Put: (path: string, options?: IRouteOptions) => MethodDecorator;
|
|
48
|
-
declare const Patch: (path: string, options?: IRouteOptions) => MethodDecorator;
|
|
49
|
-
declare const Delete: (path: string, options?: IRouteOptions) => MethodDecorator;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* The Request class represents an HTTP request in the Noxus framework.
|
|
54
|
-
* It encapsulates the request data, including the event, ID, method, path, and body.
|
|
55
|
-
* It also provides a context for dependency injection through the AppInjector.
|
|
56
|
-
*/
|
|
57
|
-
declare class Request {
|
|
58
|
-
readonly event: Electron.MessageEvent;
|
|
59
|
-
readonly senderId: number;
|
|
60
|
-
readonly id: string;
|
|
61
|
-
readonly method: HttpMethod;
|
|
62
|
-
readonly path: string;
|
|
63
|
-
readonly body: any;
|
|
64
|
-
readonly context: AppInjector;
|
|
65
|
-
readonly params: Record<string, string>;
|
|
66
|
-
constructor(event: Electron.MessageEvent, senderId: number, id: string, method: HttpMethod, path: string, body: any);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* The IRequest interface defines the structure of a request object.
|
|
70
|
-
* It includes properties for the sender ID, request ID, path, method, and an optional body.
|
|
71
|
-
* This interface is used to standardize the request data across the application.
|
|
72
|
-
*/
|
|
73
|
-
interface IRequest<TBody = unknown> {
|
|
74
|
-
senderId: number;
|
|
75
|
-
requestId: string;
|
|
76
|
-
path: string;
|
|
77
|
-
method: HttpMethod;
|
|
78
|
-
body?: TBody;
|
|
79
|
-
}
|
|
80
|
-
interface IBatchRequestItem<TBody = unknown> {
|
|
81
|
-
requestId?: string;
|
|
82
|
-
path: string;
|
|
83
|
-
method: AtomicHttpMethod;
|
|
84
|
-
body?: TBody;
|
|
85
|
-
}
|
|
86
|
-
interface IBatchRequestPayload {
|
|
87
|
-
requests: IBatchRequestItem[];
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Creates a Request object from the IPC event data.
|
|
91
|
-
* This function extracts the necessary information from the IPC event and constructs a Request instance.
|
|
92
|
-
*/
|
|
93
|
-
interface IResponse<TBody = unknown> {
|
|
94
|
-
requestId: string;
|
|
95
|
-
status: number;
|
|
96
|
-
body?: TBody;
|
|
97
|
-
error?: string;
|
|
98
|
-
stack?: string;
|
|
99
|
-
}
|
|
100
|
-
interface IBatchResponsePayload {
|
|
101
|
-
responses: IResponse[];
|
|
102
|
-
}
|
|
103
|
-
declare const RENDERER_EVENT_TYPE = "noxus:event";
|
|
104
|
-
interface IRendererEventMessage<TPayload = unknown> {
|
|
105
|
-
type: typeof RENDERER_EVENT_TYPE;
|
|
106
|
-
event: string;
|
|
107
|
-
payload?: TPayload;
|
|
108
|
-
}
|
|
109
|
-
declare function createRendererEventMessage<TPayload = unknown>(event: string, payload?: TPayload): IRendererEventMessage<TPayload>;
|
|
110
|
-
declare function isRendererEventMessage(value: unknown): value is IRendererEventMessage;
|
|
111
|
-
|
|
112
|
-
export { type AtomicHttpMethod as A, Delete as D, type Guard as G, type HttpMethod as H, type IRendererEventMessage as I, type Middleware as M, type NextFunction as N, Patch as P, RENDERER_EVENT_TYPE as R, type IResponse as a, type IRequest as b, type IBatchRequestItem as c, type IBatchResponsePayload as d, type IBatchRequestPayload as e, Request as f, createRendererEventMessage as g, Get as h, isRendererEventMessage as i, type IRouteMetadata as j, type IRouteOptions as k, Post as l, Put as m, getRouteMetadata as n, isAtomicHttpMethod as o };
|