securequ 1.1.0 → 1.1.1

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/server/types.d.ts CHANGED
@@ -1,65 +1,68 @@
1
1
  import { MatchFunction } from 'path-to-regexp';
2
2
 
3
- type ServerClientSecret = string;
4
- type ServerClient = {
5
- origin: string;
6
- secret: ServerClientSecret;
7
- };
8
- type UploadFileMeta = {
9
- filename: string;
10
- filesize: number;
11
- filetype: string;
12
- fileid: string;
13
- chunkIndex: number;
14
- totalChunks: number;
15
- };
16
- type UploadFilePath = string;
17
- type ArgsInfo = {
18
- [key: string]: any;
19
- };
20
- type SecurequServerConfig = {
21
- basepath: string;
22
- clients: ServerClient[];
23
- upload?: {
24
- chunk: (chunk: Uint8Array, meta: UploadFileMeta, args?: ArgsInfo) => Promise<boolean>;
25
- complete: (meta: UploadFileMeta, args?: ArgsInfo) => Promise<UploadFilePath>;
26
- failed?: (meta: UploadFileMeta, args?: ArgsInfo) => Promise<boolean>;
27
- };
28
- accept?: (info: HandlerInfo, args?: ArgsInfo) => boolean | Promise<boolean>;
29
- };
30
- type HTTPMethods = "GET" | "POST" | "PUT" | "DELETE";
31
- type ListenerInfo = {
32
- signeture: string;
33
- path: string;
34
- body: any;
35
- method: HTTPMethods;
36
- origin: string;
37
- };
38
- type HandlerInfo = {
39
- path: string;
40
- body: object;
41
- method: HTTPMethods;
42
- searchParams: {
43
- [key: string]: any;
44
- };
45
- params: {
46
- [key: string]: any;
47
- };
48
- };
49
- type ServerResponse = {
50
- content: Uint8Array;
51
- status: number;
52
- };
53
- type HandlerFunction = (info: HandlerInfo, args?: any) => (any | void) | Promise<Partial<any> | void>;
54
- type RouteFactory = {
55
- [key in HTTPMethods]: {
56
- [path: string]: {
57
- handler: HandlerFunction;
58
- test: MatchFunction<{
59
- [key: string]: string;
60
- }>;
61
- };
62
- };
3
+ type ServerClientSecret = string;
4
+ type ServerClient = {
5
+ origin: string;
6
+ secret: ServerClientSecret;
7
+ };
8
+ type UploadFileMeta = {
9
+ filename: string;
10
+ filesize: number;
11
+ filetype: string;
12
+ fileid: string;
13
+ chunkIndex: number;
14
+ totalChunks: number;
15
+ };
16
+ type UploadFilePath = string;
17
+ type ArgsInfo = {
18
+ [key: string]: any;
19
+ };
20
+ type SecurequServerConfig = {
21
+ mode: "production" | "development";
22
+ basepath: string;
23
+ clients: ServerClient[];
24
+ upload?: {
25
+ maxFilesize?: number;
26
+ checkFileType?: boolean;
27
+ chunk: (chunk: Uint8Array, meta: UploadFileMeta, args?: ArgsInfo) => Promise<boolean>;
28
+ complete: (meta: UploadFileMeta, args?: ArgsInfo) => Promise<UploadFilePath>;
29
+ failed?: (meta: UploadFileMeta, args?: ArgsInfo) => Promise<boolean>;
30
+ };
31
+ accept?: (info: HandlerInfo, args?: ArgsInfo) => boolean | Promise<boolean>;
32
+ };
33
+ type HTTPMethods = "GET" | "POST" | "PUT" | "DELETE";
34
+ type ListenerInfo = {
35
+ signeture: string;
36
+ path: string;
37
+ body: any;
38
+ method: HTTPMethods;
39
+ origin: string;
40
+ };
41
+ type HandlerInfo = {
42
+ path: string;
43
+ body: object;
44
+ method: HTTPMethods;
45
+ searchParams: {
46
+ [key: string]: any;
47
+ };
48
+ params: {
49
+ [key: string]: any;
50
+ };
51
+ };
52
+ type ServerResponse = {
53
+ content: Uint8Array | string;
54
+ status: number;
55
+ };
56
+ type HandlerFunction = (info: HandlerInfo, args?: any) => (any | void) | Promise<Partial<any> | void>;
57
+ type RouteFactory = {
58
+ [key in HTTPMethods]: {
59
+ [path: string]: {
60
+ handler: HandlerFunction;
61
+ test: MatchFunction<{
62
+ [key: string]: string;
63
+ }>;
64
+ };
65
+ };
63
66
  };
64
67
 
65
68
  export type { ArgsInfo, HTTPMethods, HandlerFunction, HandlerInfo, ListenerInfo, RouteFactory, SecurequServerConfig, ServerClient, ServerClientSecret, ServerResponse, UploadFileMeta, UploadFilePath };