tezx 1.0.5 → 1.0.6
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.ts +9 -87
- package/dist/index.js +326 -445
- package/dist/index.mjs +327 -445
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -138,85 +138,6 @@ declare class Request$1 {
|
|
|
138
138
|
formData(options?: FormDataOptions): Promise<Record<string, any>>;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
declare class TezResponse {
|
|
142
|
-
/**
|
|
143
|
-
* Sends a JSON response.
|
|
144
|
-
* @param body - The response data.
|
|
145
|
-
* @param status - (Optional) HTTP status code (default: 200).
|
|
146
|
-
* @param headers - (Optional) Additional response headers.
|
|
147
|
-
* @returns Response object with JSON data.
|
|
148
|
-
*/
|
|
149
|
-
static json(body: any, status?: number, headers?: ResponseHeaders): Response;
|
|
150
|
-
static json(body: any, headers?: ResponseHeaders): Response;
|
|
151
|
-
static json(body: any, status?: number): Response;
|
|
152
|
-
/**
|
|
153
|
-
* Sends an HTML response.
|
|
154
|
-
* @param data - The HTML content as a string.
|
|
155
|
-
* @param status - (Optional) HTTP status code (default: 200).
|
|
156
|
-
* @param headers - (Optional) Additional response headers.
|
|
157
|
-
* @returns Response object with HTML data.
|
|
158
|
-
*/
|
|
159
|
-
static html(data: string, status?: number, headers?: ResponseHeaders): Response;
|
|
160
|
-
static html(data: string, headers?: ResponseHeaders): Response;
|
|
161
|
-
static html(data: string, status?: number): Response;
|
|
162
|
-
/**
|
|
163
|
-
* Sends a plain text response.
|
|
164
|
-
* @param data - The text content.
|
|
165
|
-
* @param status - (Optional) HTTP status code (default: 200).
|
|
166
|
-
* @param headers - (Optional) Additional response headers.
|
|
167
|
-
* @returns Response object with plain text data.
|
|
168
|
-
*/
|
|
169
|
-
static text(data: string, status?: number, headers?: ResponseHeaders): Response;
|
|
170
|
-
static text(data: string, headers?: ResponseHeaders): Response;
|
|
171
|
-
static text(data: string, status?: number): Response;
|
|
172
|
-
/**
|
|
173
|
-
* Sends an XML response.
|
|
174
|
-
* @param data - The XML content.
|
|
175
|
-
* @param status - (Optional) HTTP status code (default: 200).
|
|
176
|
-
* @param headers - (Optional) Additional response headers.
|
|
177
|
-
* @returns Response object with XML data.
|
|
178
|
-
*/
|
|
179
|
-
static xml(data: string, status?: number, headers?: ResponseHeaders): Response;
|
|
180
|
-
static xml(data: string, headers?: ResponseHeaders): Response;
|
|
181
|
-
static xml(data: string, status?: number): Response;
|
|
182
|
-
/**
|
|
183
|
-
* Sends a response with any content type.
|
|
184
|
-
* Automatically determines content type if not provided.
|
|
185
|
-
* @param body - The response body.
|
|
186
|
-
* @param status - (Optional) HTTP status code.
|
|
187
|
-
* @param headers - (Optional) Additional response headers.
|
|
188
|
-
* @returns Response object.
|
|
189
|
-
*/
|
|
190
|
-
static send(body: any, status?: number, headers?: ResponseHeaders): Response;
|
|
191
|
-
static send(body: any, headers?: ResponseHeaders): Response;
|
|
192
|
-
static send(body: any, status?: number): Response;
|
|
193
|
-
/**
|
|
194
|
-
* Redirects to a given URL.
|
|
195
|
-
* @param url - The target URL.
|
|
196
|
-
* @param status - (Optional) HTTP status code (default: 302).
|
|
197
|
-
* @param headers - (Optional) Additional headers.
|
|
198
|
-
* @returns Response object with redirect.
|
|
199
|
-
*/
|
|
200
|
-
static redirect(url: string, status?: number, headers?: ResponseHeaders): Response;
|
|
201
|
-
/**
|
|
202
|
-
* Handles file downloads.
|
|
203
|
-
* @param filePath - The path to the file.
|
|
204
|
-
* @param fileName - The name of the downloaded file.
|
|
205
|
-
* @returns Response object for file download.
|
|
206
|
-
*/
|
|
207
|
-
static download(filePath: string, fileName: string): Promise<Response>;
|
|
208
|
-
/**
|
|
209
|
-
* Serves a file to the client.
|
|
210
|
-
* @param filePath - Absolute or relative path to the file.
|
|
211
|
-
* @param fileName - (Optional) The name of the send file.
|
|
212
|
-
* @param headers - (Optional) Additional headers.
|
|
213
|
-
* @returns Response object with the file stream.
|
|
214
|
-
*/
|
|
215
|
-
static sendFile(filePath: string, fileName?: string, headers?: ResponseHeaders): Promise<Response>;
|
|
216
|
-
static sendFile(filePath: string, headers?: ResponseHeaders): Promise<Response>;
|
|
217
|
-
static sendFile(filePath: string, fileName?: string): Promise<Response>;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
141
|
/**
|
|
221
142
|
* A simple key-value storage class using Map.
|
|
222
143
|
*/
|
|
@@ -366,9 +287,9 @@ declare class Context<T extends Record<string, any> = {}> {
|
|
|
366
287
|
* @param headers - (Optional) Additional response headers.
|
|
367
288
|
* @returns Response object with JSON data.
|
|
368
289
|
*/
|
|
369
|
-
json(body: any, status?: number, headers?: ResponseHeaders):
|
|
370
|
-
json(body: any, headers?: ResponseHeaders):
|
|
371
|
-
json(body: any, status?: number):
|
|
290
|
+
json(body: any, status?: number, headers?: ResponseHeaders): Response;
|
|
291
|
+
json(body: any, headers?: ResponseHeaders): Response;
|
|
292
|
+
json(body: any, status?: number): Response;
|
|
372
293
|
/**
|
|
373
294
|
* Sends a response with any content type.
|
|
374
295
|
* Automatically determines content type if not provided.
|
|
@@ -416,14 +337,15 @@ declare class Context<T extends Record<string, any> = {}> {
|
|
|
416
337
|
* @returns Response object with context all method.
|
|
417
338
|
*/
|
|
418
339
|
status: (status: number) => this;
|
|
340
|
+
set setStatus(status: number);
|
|
341
|
+
get getStatus(): number;
|
|
419
342
|
/**
|
|
420
343
|
* Redirects to a given URL.
|
|
421
344
|
* @param url - The target URL.
|
|
422
345
|
* @param status - (Optional) HTTP status code (default: 302).
|
|
423
|
-
* @param headers - (Optional) Additional headers.
|
|
424
346
|
* @returns Response object with redirect.
|
|
425
347
|
*/
|
|
426
|
-
redirect(url: string, status?: number
|
|
348
|
+
redirect(url: string, status?: number): Response;
|
|
427
349
|
/**
|
|
428
350
|
* Handles file downloads.
|
|
429
351
|
* @param filePath - The path to the file.
|
|
@@ -493,8 +415,8 @@ declare class MiddlewareConfigure<T extends Record<string, any> = {}> extends Co
|
|
|
493
415
|
|
|
494
416
|
type NextCallback = () => Promise<any>;
|
|
495
417
|
type ctx<T extends Record<string, any> = {}> = Context<T> & T;
|
|
496
|
-
type Callback<T extends Record<string, any> = {}> = (ctx: ctx<T>) => Promise<
|
|
497
|
-
type Middleware<T extends Record<string, any> = {}> = (ctx: ctx<T>, next: NextCallback) => NextCallback | Promise<
|
|
418
|
+
type Callback<T extends Record<string, any> = {}> = (ctx: ctx<T>) => Promise<Response> | Response;
|
|
419
|
+
type Middleware<T extends Record<string, any> = {}> = (ctx: ctx<T>, next: NextCallback) => NextCallback | Promise<Response> | Response;
|
|
498
420
|
type RouterConfig = {
|
|
499
421
|
/**
|
|
500
422
|
* `env` allows you to define environment variables for the router.
|
|
@@ -789,4 +711,4 @@ type CorsOptions = {
|
|
|
789
711
|
};
|
|
790
712
|
declare function cors(option?: CorsOptions): (ctx: ctx, next: () => Promise<any>) => Promise<any>;
|
|
791
713
|
|
|
792
|
-
export { type Callback, type ctx as Context, type CorsOptions, type LogLevel, type LoggerFnType, type Middleware, type NextCallback, Router, type RouterConfig, type StaticServeOption,
|
|
714
|
+
export { type Callback, type ctx as Context, type CorsOptions, type LogLevel, type LoggerFnType, type Middleware, type NextCallback, Router, type RouterConfig, type StaticServeOption, TezX, type TezXConfig, type UrlRef, bunAdapter, cors, denoAdapter, loadEnv, logger, nodeAdapter, useParams };
|