@orion-js/http 4.0.0-next.3 → 4.0.0-next.5

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.d.cts CHANGED
@@ -1,7 +1,6 @@
1
- import * as connect from 'connect';
2
- import * as body_parser from 'body-parser';
3
- import express from 'express';
1
+ import express, { RequestHandler } from 'express';
4
2
  export { Request, Response, default as express } from 'express';
3
+ import { OptionsJson, OptionsText, OptionsUrlencoded } from 'body-parser';
5
4
 
6
5
  type onErrorFunction = (req: express.Request, res: express.Response, error: any) => Promise<void>;
7
6
  declare const onError: onErrorFunction;
@@ -25,7 +24,7 @@ interface RouteResponseObject {
25
24
  body: string | object;
26
25
  }
27
26
  type RouteResponse = Promise<RouteResponseObject | void>;
28
- type RouteResolve = (req: express.Request, res: express.Response, viewer: any) => RouteResponse;
27
+ type RouteResolve = (req?: express.Request, res?: express.Response, viewer?: any) => RouteResponse;
29
28
  interface OrionRouteOptions {
30
29
  /**
31
30
  * The http method of the requests to match.
@@ -42,7 +41,7 @@ interface OrionRouteOptions {
42
41
  /**
43
42
  * Selected body parser options.
44
43
  */
45
- bodyParserOptions?: body_parser.OptionsJson | body_parser.OptionsText | body_parser.OptionsUrlencoded;
44
+ bodyParserOptions?: OptionsJson | OptionsText | OptionsUrlencoded;
46
45
  /**
47
46
  * Add a middleware to the route.
48
47
  * See https://expressjs.com/en/4x/api.html#middleware
@@ -67,15 +66,17 @@ declare function registerRoute(route: RouteType): void;
67
66
 
68
67
  declare function registerRoutes(routesMap: RoutesMap): void;
69
68
 
70
- declare function Routes(): ClassDecorator;
71
- declare function Route(options: Omit<OrionRouteOptions, 'resolve'>): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<RouteResolve>) => void;
69
+ declare function Routes(): (target: any, context: ClassDecoratorContext<any>) => void;
70
+ declare function Route<This, TArgs extends Parameters<OrionRouteOptions['resolve']>, TReturn extends ReturnType<OrionRouteOptions['resolve']>>(options: Omit<OrionRouteOptions, 'resolve'>): (method: (this: This, ...args: TArgs) => TReturn, context: ClassMethodDecoratorContext<This, typeof method>) => (this: This, ...args: TArgs) => TReturn;
72
71
  declare function getServiceRoutes(target: any): RoutesMap;
73
72
 
74
73
  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;
74
+ json: () => RequestHandler;
75
+ raw: () => RequestHandler;
76
+ text: () => RequestHandler;
77
+ urlencoded: (options?: {
78
+ extended: boolean;
79
+ }) => RequestHandler;
79
80
  };
80
81
 
81
82
  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,7 +1,6 @@
1
- import * as connect from 'connect';
2
- import * as body_parser from 'body-parser';
3
- import express from 'express';
1
+ import express, { RequestHandler } from 'express';
4
2
  export { Request, Response, default as express } from 'express';
3
+ import { OptionsJson, OptionsText, OptionsUrlencoded } from 'body-parser';
5
4
 
6
5
  type onErrorFunction = (req: express.Request, res: express.Response, error: any) => Promise<void>;
7
6
  declare const onError: onErrorFunction;
@@ -25,7 +24,7 @@ interface RouteResponseObject {
25
24
  body: string | object;
26
25
  }
27
26
  type RouteResponse = Promise<RouteResponseObject | void>;
28
- type RouteResolve = (req: express.Request, res: express.Response, viewer: any) => RouteResponse;
27
+ type RouteResolve = (req?: express.Request, res?: express.Response, viewer?: any) => RouteResponse;
29
28
  interface OrionRouteOptions {
30
29
  /**
31
30
  * The http method of the requests to match.
@@ -42,7 +41,7 @@ interface OrionRouteOptions {
42
41
  /**
43
42
  * Selected body parser options.
44
43
  */
45
- bodyParserOptions?: body_parser.OptionsJson | body_parser.OptionsText | body_parser.OptionsUrlencoded;
44
+ bodyParserOptions?: OptionsJson | OptionsText | OptionsUrlencoded;
46
45
  /**
47
46
  * Add a middleware to the route.
48
47
  * See https://expressjs.com/en/4x/api.html#middleware
@@ -67,15 +66,17 @@ declare function registerRoute(route: RouteType): void;
67
66
 
68
67
  declare function registerRoutes(routesMap: RoutesMap): void;
69
68
 
70
- declare function Routes(): ClassDecorator;
71
- declare function Route(options: Omit<OrionRouteOptions, 'resolve'>): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<RouteResolve>) => void;
69
+ declare function Routes(): (target: any, context: ClassDecoratorContext<any>) => void;
70
+ declare function Route<This, TArgs extends Parameters<OrionRouteOptions['resolve']>, TReturn extends ReturnType<OrionRouteOptions['resolve']>>(options: Omit<OrionRouteOptions, 'resolve'>): (method: (this: This, ...args: TArgs) => TReturn, context: ClassMethodDecoratorContext<This, typeof method>) => (this: This, ...args: TArgs) => TReturn;
72
71
  declare function getServiceRoutes(target: any): RoutesMap;
73
72
 
74
73
  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;
74
+ json: () => RequestHandler;
75
+ raw: () => RequestHandler;
76
+ text: () => RequestHandler;
77
+ urlencoded: (options?: {
78
+ extended: boolean;
79
+ }) => RequestHandler;
79
80
  };
80
81
 
81
82
  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 };