-
Notifications
You must be signed in to change notification settings - Fork 5
/
web_jsx.context.d.ts
206 lines (204 loc) · 6.18 KB
/
web_jsx.context.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*
* Copyright (c) 2018, SOW (https://www.safeonline.world). (https://github.com/RKTUXYN) All rights reserved.
* @author {SOW}
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
/**HTTP current request method*/
declare enum RequestMethod {
/**HTTP Request method `GET`*/
GET,
/**HTTP Request method `HEAD`*/
HEAD,
/**HTTP Request method `POST`*/
POST,
/**HTTP Request method `PUT`*/
PUT,
/**HTTP Request method `DELETE`*/
DELETE,
/**HTTP Request method `CONNECT`*/
CONNECT,
/**HTTP Request method `OPTIONS`*/
OPTIONS,
/**HTTP Request method `TRACE`*/
TRACE
}
//index.wjsx
//handler.wjsxh
interface ContextStatic {
/**
* Executor path shown here
* @type {string}
*/
app_path: string;
/**
* Containing Server environment Path variable(s)
* @type {string}
*/
env_path: string;
/**
* Containing host name here without protocol
* @type {string}
*/
host: string;
/**
* Request remote address
* @type {string}
*/
remote_addr: string;
/**
* Application root directory
* @type {string}
*/
root_dir: string;
server_protocol: string
/**
* Is secure connection request
* @type {boolean}
*/
https: boolean;
/**
* Host URL with protocol
* @type {string}
*/
host_url: string;
request: {
/**
* HTTP request accept type
* @type {string}
*/
accept: string;
/**
* HTTP request accept encoding type
* @type {string}
*/
accept_encoding: string;
/**
* HTTP request content type
* @type {string}
*/
content_type: string;
/**
* Current HTTP Request all cookie collection with ; seperator
* @type {string}
*/
cookie: string;
/**
* HTTP Request Mehtod GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE
* @type {RequestMethod}
*/
method: RequestMethod;
/**
* Current HTTP request page path
* @type {string}
*/
page_path: string;
/**
* Current HTTP request content
* @type {Array}
*/
pay_load: [];
/**
* Current HTTP request query string
* @type {Object}
*/
query_string: Object;
/**
* Current HTTP request user agent
* @type {string}
*/
user_agent: string;
/**
* Current HTTP request protocol
* @type {string}
*/
protocol: string;
/**
* Read from current HTTP Payload stream chunk
* ~@param func A function with @param buff as chunk reading buffer and @param count chunk buffer length
* ~@throws if Http requset method not POST
*/
read_payload( func: ( buff: string, count: number ) => any ): any;
};
response: {
/**
* Write string to HTTP Response body stream
* ~@param data A string containing chracter
*/
write( data: string ): any;
/**
* Set HTTP Response header collection
* ~@param name A string containing header key e.g. Content-Type
* ~@param description A string containing header description e.g. application/json
*/
header( name: string, description: string ): any;
/**
* Write HTTP Response body stream from server map file
* ~@param path A string containing file path
* ~@throws File not found exception
*/
write_from_file( path: string ): any;
/**HTTP response body*/
body: {
/**HTTP response flush, make sure this method execute end of response*/
flush(): any;
/**It'll write HTTP response body as pdf with default settings*/
write_as_pdf(): any;
};
/**HTTP response body stram will be clear*/
clear(): any;
/**
* Set HTTP response status code here and will be override privious given status code
* ~@param http_status should be HTTP status code. we will not verify given status code
* ~@param description HTTP status description
*/
status( http_status: string, description: string ): any;
/**
* Set HTTP cookie collection and if match, than it will be override privious given cookie
* ~@param cook should be like this `Set-Cookie:name=value;`
* ~@param description HTTP status description
*/
cookie( cook: string ): any;
/**
* Set HTTP status code 303 See Other
* ~@param url server url
* ~@param force if you set true than we'll set your url with http protocol
*/
redirect( url: string, force: boolean ): any;
/**HTTP response apply as zlib GZip stream compression.*/
as_gzip(): any;
};
}
interface IJsxFile {
/**
* File constructor.
* ~@param path server file path
* ~@param mood define read/write mood e.g. r|r+|w|w+|a|a+
* ~@throws Director Not Found|File Not Found|Permission denied
* ~Read more https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-s-wfopen-s
*/
new( path: string, mood: string ): IJsxFile;
/**
* Read file byte chunk if you define file mood read when create constructor
* ~@param count define the read length
* ~@returns Object {read character, character length}
*/
read( count: number ): {
/**Read character*/
data: string;
/**Read character length*/
read_length: number
};
/**
* Write chracter in File Stream which opened yet as read mood
* ~@param data define write character
* ~@throws The stream is not readable
*/
write( data: string ): any;
/**
* Release File Stream which opened yet as read or write mood
* ~If you open is write mood, than all buffer will be write to disk.
*/
flush(): any;
}
declare var context: ContextStatic;