@ublitzjs/core 0.1.1 → 1.0.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.
@@ -0,0 +1,43 @@
1
+ import type { HttpResponse as uwsHttpResponse } from "uWebSockets.js";
2
+ import type { HttpRequest, HttpMethods } from "./index.ts";
3
+ /**
4
+ * If something wrong is to content-length, sends 411 code and throws error with a "cause" == { CL : string}, sets res.finished = true
5
+ */
6
+ export declare function checkContentLength(res: uwsHttpResponse, req: HttpRequest): number;
7
+ /**
8
+ * sends http 400 and throws an Error with "causeForYou", sets res.finished = true
9
+ */
10
+ export declare function badRequest(res: uwsHttpResponse, error: string, causeForYou: string): void;
11
+ /**
12
+ * sends http 413, but doesn't throw an Error, sets res.finished = true
13
+ */
14
+ export declare function tooLargeBody(res: uwsHttpResponse, limit: number): void;
15
+ /**
16
+ * Constructs function, which sends http 405 and sets http Allow header with all methods you passed.
17
+ * It ignores "ws" and replaces "del" on "DELETE"
18
+ */
19
+ export declare function seeOtherMethods(methodsArr: HttpMethods[]): (res: uwsHttpResponse, req: any) => any;
20
+ /**
21
+ * Constructs the function, which sets 404 http code and sends the message you have specified
22
+ */
23
+ export declare function notFoundConstructor(message?: string): (res: uwsHttpResponse, req: any) => any;
24
+ /**
25
+ * code: required content length
26
+ */
27
+ export declare var c411: ArrayBuffer;
28
+ /**
29
+ * code: bad request
30
+ */
31
+ export declare var c400: ArrayBuffer;
32
+ /**
33
+ * code: payload too large
34
+ */
35
+ export declare var c413: ArrayBuffer;
36
+ /**
37
+ * code: method not allowed
38
+ */
39
+ export declare var c405: ArrayBuffer;
40
+ /**
41
+ * code: not found
42
+ */
43
+ export declare var c404: ArrayBuffer;