@faasjs/http 0.0.2-beta.26 → 0.0.2-beta.260

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.
@@ -7,36 +7,52 @@ export interface ValidatorRuleOptions {
7
7
  default?: any;
8
8
  config?: Partial<ValidatorOptions>;
9
9
  }
10
- export interface ValidatorOptions {
10
+ export interface ValidatorOptions<Content = {
11
+ [key: string]: any;
12
+ }> {
11
13
  whitelist?: 'error' | 'ignore';
12
14
  rules: {
13
- [key: string]: ValidatorRuleOptions;
15
+ [k in keyof Content]?: ValidatorRuleOptions;
14
16
  };
15
17
  onError?: (type: string, key: string | string[], value?: any) => {
16
18
  statusCode?: number;
17
- headers?: {
18
- [key: string]: any;
19
- };
20
19
  message: any;
21
20
  } | void;
22
21
  }
23
- export declare class Validator {
24
- paramsConfig?: ValidatorOptions;
25
- cookieConfig?: ValidatorOptions;
26
- sessionConfig?: ValidatorOptions;
27
- private request?;
28
- private logger;
22
+ interface Request<P, C, S> {
23
+ headers: {
24
+ [key: string]: string;
25
+ };
26
+ params?: P;
27
+ cookie?: Cookie<C, S>;
28
+ session?: Session<S, C>;
29
+ }
30
+ export declare type BeforeOption<P = any, C = any, S = any> = (request: Request<P, C, S>) => Promise<void | {
31
+ statusCode?: number;
32
+ message: string;
33
+ }>;
34
+ export interface ValidatorConfig<P, C, S> {
35
+ params?: ValidatorOptions<P>;
36
+ cookie?: ValidatorOptions<C>;
37
+ session?: ValidatorOptions<S>;
38
+ before?: BeforeOption;
39
+ }
40
+ export declare class Validator<P, C, S> {
41
+ before?: BeforeOption<P, C, S>;
42
+ paramsConfig?: ValidatorOptions<P>;
43
+ cookieConfig?: ValidatorOptions<C>;
44
+ sessionConfig?: ValidatorOptions<S>;
45
+ private request;
46
+ private readonly logger;
29
47
  constructor(config: {
30
- params?: ValidatorOptions;
31
- cookie?: ValidatorOptions;
32
- session?: ValidatorOptions;
48
+ params?: ValidatorOptions<P>;
49
+ cookie?: ValidatorOptions<C>;
50
+ session?: ValidatorOptions<S>;
51
+ before?: BeforeOption<P, C, S>;
33
52
  });
34
- valid({ params, cookie, session }: {
35
- params?: any;
36
- cookie?: Cookie;
37
- session?: Session;
38
- }): void;
53
+ valid(request: Request<P, C, S>): Promise<void>;
39
54
  validContent(type: string, params: {
40
55
  [key: string]: any;
41
56
  }, baseKey: string, config: ValidatorOptions): void;
42
57
  }
58
+ export {};
package/package.json CHANGED
@@ -1,10 +1,16 @@
1
1
  {
2
2
  "name": "@faasjs/http",
3
- "version": "0.0.2-beta.26",
3
+ "version": "0.0.2-beta.260",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.es.js",
7
7
  "types": "lib/index.d.ts",
8
+ "homepage": "https://faasjs.com/docs/http",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/faasjs/faasjs.git",
12
+ "directory": "packages/http"
13
+ },
8
14
  "scripts": {
9
15
  "prepack": "rm -rf ./lib && rollup -c && mv lib/*/src/* lib/"
10
16
  },
@@ -12,7 +18,7 @@
12
18
  "lib"
13
19
  ],
14
20
  "devDependencies": {
15
- "@faasjs/func": "^0.0.2-beta.26",
21
+ "@faasjs/func": "^0.0.2-beta.260",
16
22
  "@types/debug": "*",
17
23
  "@types/jest": "*",
18
24
  "@types/node": "*",
@@ -20,5 +26,5 @@
20
26
  "rollup-plugin-typescript2": "*",
21
27
  "typescript": "*"
22
28
  },
23
- "gitHead": "b977b51f3a240deabab503780e7231d1c152b2db"
29
+ "gitHead": "4863d76f065e4ca18a3ec4131a630ef37c742fcf"
24
30
  }