@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.
@@ -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
- // Generated by dts-bundle-generator v9.5.1
2
-
1
+ import * as connect from 'connect';
2
+ import * as body_parser from 'body-parser';
3
3
  import express from 'express';
4
- import { Request as Request$1, Response as Response$1 } 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;
5
12
 
6
- export type onErrorFunction = (req: express.Request, res: express.Response, error: any) => Promise<void>;
7
- export declare const onError: onErrorFunction;
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
- export declare const startServer: (port?: number, otherOptions?: StartOrionOptions) => express.Express;
15
- export declare const getApp: () => express.Express;
16
- export declare const getServer: () => any;
17
- export interface RouteResponseObject {
18
- statusCode?: number;
19
- headers?: {
20
- [key: string]: string;
21
- };
22
- body: string | object;
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
- export type RouteResponse = Promise<RouteResponseObject | void>;
25
- export type RouteResolve = (req: express.Request, res: express.Response, viewer: any) => RouteResponse;
26
- export interface OrionRouteOptions {
27
- /**
28
- * The http method of the requests to match.
29
- */
30
- method: "get" | "post" | "put" | "delete" | "all";
31
- /**
32
- * The path of the requests to match.
33
- */
34
- path: string;
35
- /**
36
- * Select the body parser to use for this route.
37
- */
38
- bodyParser?: "json" | "text" | "urlencoded";
39
- /**
40
- * Selected body parser options.
41
- */
42
- bodyParserOptions?: bodyParser.OptionsJson | bodyParser.OptionsText | bodyParser.OptionsUrlencoded;
43
- /**
44
- * Add a middleware to the route.
45
- * See https://expressjs.com/en/4x/api.html#middleware
46
- * for more information.
47
- */
48
- middlewares?: Array<express.RequestHandler>;
49
- resolve: RouteResolve;
50
- /**
51
- * Pass another express app
52
- */
53
- app?: express.Application;
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
- export interface RouteType extends OrionRouteOptions {
58
+ interface RouteType extends OrionRouteOptions {
56
59
  }
57
- export interface RoutesMap {
58
- [key: string]: RouteType;
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
- export {
74
- Request$1 as Request,
75
- Response$1 as Response,
76
- express,
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 };