@moostjs/event-http 0.2.14 → 0.2.15

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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  var eventHttp = require('@wooksjs/event-http');
4
4
  var moost = require('moost');
5
+ var http = require('http');
6
+ var https = require('https');
5
7
  var eventCore = require('@wooksjs/event-core');
6
8
 
7
9
  /******************************************************************************
@@ -65,7 +67,7 @@ class MoostHttp {
65
67
  return this.httpApp.listen(...args);
66
68
  }
67
69
  getProvideRegistry() {
68
- return createProvideRegistry([eventHttp.WooksHttp, () => this.getHttpApp()], ['WooksHttp', () => this.getHttpApp()]);
70
+ return createProvideRegistry([eventHttp.WooksHttp, () => this.getHttpApp()], ['WooksHttp', () => this.getHttpApp()], [http.Server, () => this.getHttpApp().getServer()], [https.Server, () => this.getHttpApp().getServer()]);
69
71
  }
70
72
  bindHandler(opts) {
71
73
  let fn;
@@ -873,6 +875,17 @@ function SetCookie(...args) {
873
875
  return Intercept(setCookieInterceptor(...args));
874
876
  }
875
877
 
878
+ function httpValidatePipe(opts) {
879
+ return moost.validatePipe(Object.assign({ errorCb: (message, details) => {
880
+ throw new eventHttp.HttpError(400, {
881
+ statusCode: 400,
882
+ message,
883
+ error: 'Validation Error',
884
+ details,
885
+ });
886
+ } }, opts[0]));
887
+ }
888
+
876
889
  exports.All = All;
877
890
  exports.Authorization = Authorization;
878
891
  exports.Body = Body;
@@ -900,3 +913,4 @@ exports.SetCookie = SetCookie;
900
913
  exports.SetHeader = SetHeader;
901
914
  exports.StatusHook = StatusHook;
902
915
  exports.Url = Url;
916
+ exports.httpValidatePipe = httpValidatePipe;
package/dist/index.d.ts CHANGED
@@ -6,10 +6,12 @@ import { TCookieAttributesInput } from '@wooksjs/event-http';
6
6
  import { TInterceptorFn } from '@moostjs/moost';
7
7
  import { TMoostAdapter } from 'moost';
8
8
  import { TMoostAdapterOptions } from 'moost';
9
+ import { TPipeFn } from 'moost';
9
10
  import { TProstoRouterPathBuilder } from '@prostojs/router';
10
11
  import { TProvideRegistry } from '@prostojs/infact';
11
12
  import { TWooksHttpOptions } from '@wooksjs/event-http';
12
13
  import { useSetCookies } from '@wooksjs/event-http';
14
+ import { validatePipe } from 'moost';
13
15
  import { WooksHttp } from '@wooksjs/event-http';
14
16
 
15
17
  export declare const All: (path?: string) => MethodDecorator;
@@ -76,6 +78,8 @@ export declare const HeaderHook: (name: string) => ParameterDecorator & Property
76
78
 
77
79
  export declare function HttpMethod(method: '*' | 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS', path?: string): MethodDecorator;
78
80
 
81
+ export declare function httpValidatePipe(opts: Parameters<typeof validatePipe>): TPipeFn<TEmpty>;
82
+
79
83
  /**
80
84
  * Get Request IP Address
81
85
  * @decorator
@@ -183,6 +187,9 @@ export declare const StatusHook: () => ParameterDecorator & PropertyDecorator;
183
187
 
184
188
  export { TCookieAttributesInput }
185
189
 
190
+ declare interface TEmpty {
191
+ }
192
+
186
193
  export declare interface THttpHandlerMeta {
187
194
  method: string;
188
195
  path: string;
package/dist/index.mjs CHANGED
@@ -1,5 +1,7 @@
1
1
  import { WooksHttp, createHttpApp, useHttpContext, useRequest, useHeaders, HttpError, EHttpStatusCode, WooksURLSearchParams, useStatus, useSetHeader, useSetCookie, useAuthorization, useCookies, useSearchParams, useResponse, useSetCookies } from '@wooksjs/event-http';
2
- import { getMoostMate as getMoostMate$1, Resolve } from 'moost';
2
+ import { getMoostMate as getMoostMate$1, Resolve, validatePipe } from 'moost';
3
+ import { Server as Server$1 } from 'http';
4
+ import { Server } from 'https';
3
5
  import { attachHook } from '@wooksjs/event-core';
4
6
 
5
7
  /******************************************************************************
@@ -63,7 +65,7 @@ class MoostHttp {
63
65
  return this.httpApp.listen(...args);
64
66
  }
65
67
  getProvideRegistry() {
66
- return createProvideRegistry([WooksHttp, () => this.getHttpApp()], ['WooksHttp', () => this.getHttpApp()]);
68
+ return createProvideRegistry([WooksHttp, () => this.getHttpApp()], ['WooksHttp', () => this.getHttpApp()], [Server$1, () => this.getHttpApp().getServer()], [Server, () => this.getHttpApp().getServer()]);
67
69
  }
68
70
  bindHandler(opts) {
69
71
  let fn;
@@ -871,4 +873,15 @@ function SetCookie(...args) {
871
873
  return Intercept(setCookieInterceptor(...args));
872
874
  }
873
875
 
874
- export { All, Authorization, Body, Cookie, CookieAttrsHook, CookieHook, Delete, Get, Header, HeaderHook, HttpMethod, Ip, IpList, Method, MoostHttp, Patch, Post, Put, Query, RawBody, Req, ReqId, Res, SetCookie, SetHeader, StatusHook, Url };
876
+ function httpValidatePipe(opts) {
877
+ return validatePipe(Object.assign({ errorCb: (message, details) => {
878
+ throw new HttpError(400, {
879
+ statusCode: 400,
880
+ message,
881
+ error: 'Validation Error',
882
+ details,
883
+ });
884
+ } }, opts[0]));
885
+ }
886
+
887
+ export { All, Authorization, Body, Cookie, CookieAttrsHook, CookieHook, Delete, Get, Header, HeaderHook, HttpMethod, Ip, IpList, Method, MoostHttp, Patch, Post, Put, Query, RawBody, Req, ReqId, Res, SetCookie, SetHeader, StatusHook, Url, httpValidatePipe };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moostjs/event-http",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "@moostjs/event-http",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -28,11 +28,11 @@
28
28
  },
29
29
  "homepage": "https://github.com/moostjs/moostjs/tree/main/packages/event-http#readme",
30
30
  "peerDependencies": {
31
- "moost": "0.2.14",
32
- "wooks": "^0.2.7",
33
- "@wooksjs/event-core": "^0.2.7"
31
+ "moost": "0.2.15",
32
+ "wooks": "^0.2.8",
33
+ "@wooksjs/event-core": "^0.2.8"
34
34
  },
35
35
  "dependencies": {
36
- "@wooksjs/event-http": "^0.2.7"
36
+ "@wooksjs/event-http": "^0.2.8"
37
37
  }
38
38
  }