@orion-js/http 3.2.4 → 3.2.10
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/lib/service/index.d.ts +2 -5
- package/lib/service/index.js +2 -2
- package/lib/types.d.ts +4 -2
- package/package.json +3 -3
package/lib/service/index.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { OrionRouteOptions, RoutesMap } from '../types';
|
|
1
|
+
import { OrionRouteOptions, RouteResolve, RoutesMap } from '../types';
|
|
2
2
|
export declare function Routes(): ClassDecorator;
|
|
3
|
-
export
|
|
4
|
-
value?: OrionRouteOptions['resolve'];
|
|
5
|
-
}
|
|
6
|
-
export declare function Route(options: Omit<OrionRouteOptions, 'resolve'>): (target: any, propertyKey: string, descriptor: RoutesPropertyDescriptor) => void;
|
|
3
|
+
export declare function Route(options: Omit<OrionRouteOptions, 'resolve'>): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<RouteResolve>) => void;
|
|
7
4
|
export declare function getServiceRoutes(target: any): RoutesMap;
|
package/lib/service/index.js
CHANGED
|
@@ -20,9 +20,9 @@ function Route(options) {
|
|
|
20
20
|
target.routes = target.routes || {};
|
|
21
21
|
target.routes[propertyKey] = (0, route_1.default)({
|
|
22
22
|
...options,
|
|
23
|
-
resolve: async (
|
|
23
|
+
resolve: async (req, res, viewer) => {
|
|
24
24
|
const instance = (0, services_1.getInstance)(target.service);
|
|
25
|
-
return await instance[propertyKey](
|
|
25
|
+
return await instance[propertyKey](req, res, viewer);
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
};
|
package/lib/types.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import * as bodyParser from 'body-parser';
|
|
3
|
-
export interface
|
|
3
|
+
export interface RouteResponseObject {
|
|
4
4
|
statusCode?: number;
|
|
5
5
|
headers?: {
|
|
6
6
|
[key: string]: string;
|
|
7
7
|
};
|
|
8
8
|
body: string | object;
|
|
9
9
|
}
|
|
10
|
+
export declare type RouteResponse = Promise<RouteResponseObject | void>;
|
|
11
|
+
export declare type RouteResolve = (req: express.Request, res: express.Response, viewer: any) => RouteResponse;
|
|
10
12
|
export interface OrionRouteOptions {
|
|
11
13
|
/**
|
|
12
14
|
* The http method of the requests to match.
|
|
@@ -30,7 +32,7 @@ export interface OrionRouteOptions {
|
|
|
30
32
|
* for more information.
|
|
31
33
|
*/
|
|
32
34
|
middlewares?: Array<express.RequestHandler>;
|
|
33
|
-
resolve:
|
|
35
|
+
resolve: RouteResolve;
|
|
34
36
|
/**
|
|
35
37
|
* Pass another express app
|
|
36
38
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/http",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.10",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@orion-js/helpers": "^3.2.0",
|
|
22
22
|
"@orion-js/resolvers": "^3.2.0",
|
|
23
23
|
"@orion-js/schema": "^3.2.0",
|
|
24
|
-
"@orion-js/services": "^3.2.
|
|
24
|
+
"@orion-js/services": "^3.2.10",
|
|
25
25
|
"body-parser": "1.19.0",
|
|
26
26
|
"express": "4.17.1",
|
|
27
27
|
"reflect-metadata": "^0.1.13"
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "cae0afccac10f4b9bdbdeb1faaac3884eaef730c"
|
|
46
46
|
}
|