@orion-js/http 4.0.0-next.0 → 4.0.0-next.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.
- package/dist/index.cjs +6041 -38930
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +81 -0
- package/dist/index.d.ts +71 -69
- package/dist/index.js +6000 -38896
- package/dist/index.js.map +1 -0
- package/package.json +17 -17
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as connect from 'connect';
|
|
2
|
+
import * as body_parser from 'body-parser';
|
|
3
|
+
import express from 'express';
|
|
4
|
+
export { Request, Response, default as express } from 'express';
|
|
5
|
+
|
|
6
|
+
type onErrorFunction = (req: express.Request, res: express.Response, error: any) => Promise<void>;
|
|
7
|
+
declare const onError: onErrorFunction;
|
|
8
|
+
declare const setOnError: (onErrorFunc: onErrorFunction) => void;
|
|
9
|
+
|
|
10
|
+
declare const getViewer: (req: express.Request) => Promise<any>;
|
|
11
|
+
declare const setGetViewer: (getViewerFunc: (req: express.Request) => any) => void;
|
|
12
|
+
|
|
13
|
+
interface StartOrionOptions {
|
|
14
|
+
keepAliveTimeout?: number;
|
|
15
|
+
}
|
|
16
|
+
declare const startServer: (port?: number, otherOptions?: StartOrionOptions) => express.Express;
|
|
17
|
+
declare const getApp: () => express.Express;
|
|
18
|
+
declare const getServer: () => any;
|
|
19
|
+
|
|
20
|
+
interface RouteResponseObject {
|
|
21
|
+
statusCode?: number;
|
|
22
|
+
headers?: {
|
|
23
|
+
[key: string]: string;
|
|
24
|
+
};
|
|
25
|
+
body: string | object;
|
|
26
|
+
}
|
|
27
|
+
type RouteResponse = Promise<RouteResponseObject | void>;
|
|
28
|
+
type RouteResolve = (req: express.Request, res: express.Response, viewer: any) => RouteResponse;
|
|
29
|
+
interface OrionRouteOptions {
|
|
30
|
+
/**
|
|
31
|
+
* The http method of the requests to match.
|
|
32
|
+
*/
|
|
33
|
+
method: 'get' | 'post' | 'put' | 'delete' | 'all';
|
|
34
|
+
/**
|
|
35
|
+
* The path of the requests to match.
|
|
36
|
+
*/
|
|
37
|
+
path: string;
|
|
38
|
+
/**
|
|
39
|
+
* Select the body parser to use for this route.
|
|
40
|
+
*/
|
|
41
|
+
bodyParser?: 'json' | 'text' | 'urlencoded';
|
|
42
|
+
/**
|
|
43
|
+
* Selected body parser options.
|
|
44
|
+
*/
|
|
45
|
+
bodyParserOptions?: body_parser.OptionsJson | body_parser.OptionsText | body_parser.OptionsUrlencoded;
|
|
46
|
+
/**
|
|
47
|
+
* Add a middleware to the route.
|
|
48
|
+
* See https://expressjs.com/en/4x/api.html#middleware
|
|
49
|
+
* for more information.
|
|
50
|
+
*/
|
|
51
|
+
middlewares?: Array<express.RequestHandler>;
|
|
52
|
+
resolve: RouteResolve;
|
|
53
|
+
/**
|
|
54
|
+
* Pass another express app
|
|
55
|
+
*/
|
|
56
|
+
app?: express.Application;
|
|
57
|
+
}
|
|
58
|
+
interface RouteType extends OrionRouteOptions {
|
|
59
|
+
}
|
|
60
|
+
interface RoutesMap {
|
|
61
|
+
[key: string]: RouteType;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare function route(options: OrionRouteOptions): RouteType;
|
|
65
|
+
|
|
66
|
+
declare function registerRoute(route: RouteType): void;
|
|
67
|
+
|
|
68
|
+
declare function registerRoutes(routesMap: RoutesMap): void;
|
|
69
|
+
|
|
70
|
+
declare function Routes(): ClassDecorator;
|
|
71
|
+
declare function Route(options: Omit<OrionRouteOptions, 'resolve'>): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<RouteResolve>) => void;
|
|
72
|
+
declare function getServiceRoutes(target: any): RoutesMap;
|
|
73
|
+
|
|
74
|
+
declare const bodyParser: {
|
|
75
|
+
json: (options?: body_parser.OptionsJson) => connect.NextHandleFunction;
|
|
76
|
+
raw: (options?: body_parser.Options) => connect.NextHandleFunction;
|
|
77
|
+
text: (options?: body_parser.OptionsText) => connect.NextHandleFunction;
|
|
78
|
+
urlencoded: (options?: body_parser.OptionsUrlencoded) => connect.NextHandleFunction;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export { type OrionRouteOptions, Route, type RouteResolve, type RouteResponse, type RouteResponseObject, type RouteType, Routes, type RoutesMap, bodyParser, getApp, getServer, getServiceRoutes, getViewer, onError, registerRoute, registerRoutes, route, setGetViewer, setOnError, startServer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,79 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as connect from 'connect';
|
|
2
|
+
import * as body_parser from 'body-parser';
|
|
3
3
|
import express from 'express';
|
|
4
|
-
|
|
4
|
+
export { Request, Response, default as express } from 'express';
|
|
5
|
+
|
|
6
|
+
type onErrorFunction = (req: express.Request, res: express.Response, error: any) => Promise<void>;
|
|
7
|
+
declare const onError: onErrorFunction;
|
|
8
|
+
declare const setOnError: (onErrorFunc: onErrorFunction) => void;
|
|
9
|
+
|
|
10
|
+
declare const getViewer: (req: express.Request) => Promise<any>;
|
|
11
|
+
declare const setGetViewer: (getViewerFunc: (req: express.Request) => any) => void;
|
|
5
12
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare const setOnError: (onErrorFunc: onErrorFunction) => void;
|
|
9
|
-
export declare const getViewer: (req: express.Request) => Promise<any>;
|
|
10
|
-
export declare const setGetViewer: (getViewerFunc: (req: express.Request) => any) => void;
|
|
11
|
-
export interface StartOrionOptions {
|
|
12
|
-
keepAliveTimeout?: number;
|
|
13
|
+
interface StartOrionOptions {
|
|
14
|
+
keepAliveTimeout?: number;
|
|
13
15
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
declare const startServer: (port?: number, otherOptions?: StartOrionOptions) => express.Express;
|
|
17
|
+
declare const getApp: () => express.Express;
|
|
18
|
+
declare const getServer: () => any;
|
|
19
|
+
|
|
20
|
+
interface RouteResponseObject {
|
|
21
|
+
statusCode?: number;
|
|
22
|
+
headers?: {
|
|
23
|
+
[key: string]: string;
|
|
24
|
+
};
|
|
25
|
+
body: string | object;
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
27
|
+
type RouteResponse = Promise<RouteResponseObject | void>;
|
|
28
|
+
type RouteResolve = (req: express.Request, res: express.Response, viewer: any) => RouteResponse;
|
|
29
|
+
interface OrionRouteOptions {
|
|
30
|
+
/**
|
|
31
|
+
* The http method of the requests to match.
|
|
32
|
+
*/
|
|
33
|
+
method: 'get' | 'post' | 'put' | 'delete' | 'all';
|
|
34
|
+
/**
|
|
35
|
+
* The path of the requests to match.
|
|
36
|
+
*/
|
|
37
|
+
path: string;
|
|
38
|
+
/**
|
|
39
|
+
* Select the body parser to use for this route.
|
|
40
|
+
*/
|
|
41
|
+
bodyParser?: 'json' | 'text' | 'urlencoded';
|
|
42
|
+
/**
|
|
43
|
+
* Selected body parser options.
|
|
44
|
+
*/
|
|
45
|
+
bodyParserOptions?: body_parser.OptionsJson | body_parser.OptionsText | body_parser.OptionsUrlencoded;
|
|
46
|
+
/**
|
|
47
|
+
* Add a middleware to the route.
|
|
48
|
+
* See https://expressjs.com/en/4x/api.html#middleware
|
|
49
|
+
* for more information.
|
|
50
|
+
*/
|
|
51
|
+
middlewares?: Array<express.RequestHandler>;
|
|
52
|
+
resolve: RouteResolve;
|
|
53
|
+
/**
|
|
54
|
+
* Pass another express app
|
|
55
|
+
*/
|
|
56
|
+
app?: express.Application;
|
|
54
57
|
}
|
|
55
|
-
|
|
58
|
+
interface RouteType extends OrionRouteOptions {
|
|
56
59
|
}
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
interface RoutesMap {
|
|
61
|
+
[key: string]: RouteType;
|
|
59
62
|
}
|
|
60
|
-
export function route(options: OrionRouteOptions): RouteType;
|
|
61
|
-
export function registerRoute(route: RouteType): void;
|
|
62
|
-
export function registerRoutes(routesMap: RoutesMap): void;
|
|
63
|
-
export declare function Routes(): ClassDecorator;
|
|
64
|
-
export declare function Route(options: Omit<OrionRouteOptions, "resolve">): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<RouteResolve>) => void;
|
|
65
|
-
export declare function getServiceRoutes(target: any): RoutesMap;
|
|
66
|
-
export declare const bodyParser: {
|
|
67
|
-
json: (options?: import("body-parser").OptionsJson) => import("connect").NextHandleFunction;
|
|
68
|
-
raw: (options?: import("body-parser").Options) => import("connect").NextHandleFunction;
|
|
69
|
-
text: (options?: import("body-parser").OptionsText) => import("connect").NextHandleFunction;
|
|
70
|
-
urlencoded: (options?: import("body-parser").OptionsUrlencoded) => import("connect").NextHandleFunction;
|
|
71
|
-
};
|
|
72
63
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
declare function route(options: OrionRouteOptions): RouteType;
|
|
65
|
+
|
|
66
|
+
declare function registerRoute(route: RouteType): void;
|
|
67
|
+
|
|
68
|
+
declare function registerRoutes(routesMap: RoutesMap): void;
|
|
69
|
+
|
|
70
|
+
declare function Routes(): ClassDecorator;
|
|
71
|
+
declare function Route(options: Omit<OrionRouteOptions, 'resolve'>): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<RouteResolve>) => void;
|
|
72
|
+
declare function getServiceRoutes(target: any): RoutesMap;
|
|
73
|
+
|
|
74
|
+
declare const bodyParser: {
|
|
75
|
+
json: (options?: body_parser.OptionsJson) => connect.NextHandleFunction;
|
|
76
|
+
raw: (options?: body_parser.Options) => connect.NextHandleFunction;
|
|
77
|
+
text: (options?: body_parser.OptionsText) => connect.NextHandleFunction;
|
|
78
|
+
urlencoded: (options?: body_parser.OptionsUrlencoded) => connect.NextHandleFunction;
|
|
77
79
|
};
|
|
78
80
|
|
|
79
|
-
export {};
|
|
81
|
+
export { type OrionRouteOptions, Route, type RouteResolve, type RouteResponse, type RouteResponseObject, type RouteType, Routes, type RoutesMap, bodyParser, getApp, getServer, getServiceRoutes, getViewer, onError, registerRoute, registerRoutes, route, setGetViewer, setOnError, startServer };
|