vortez 4.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.
Files changed (86) hide show
  1. package/.gitignore +13 -0
  2. package/LICENSE +201 -0
  3. package/Notes.md +12 -0
  4. package/README.md +372 -0
  5. package/build/Beta/JwtManager.d.ts +114 -0
  6. package/build/Beta/JwtManager.js +249 -0
  7. package/build/Beta/JwtManager.js.map +1 -0
  8. package/build/Beta/Mail.d.ts +60 -0
  9. package/build/Beta/Mail.js +192 -0
  10. package/build/Beta/Mail.js.map +1 -0
  11. package/build/Config.d.ts +39 -0
  12. package/build/Config.js +33 -0
  13. package/build/Config.js.map +1 -0
  14. package/build/ConsoleUI.d.ts +57 -0
  15. package/build/ConsoleUI.js +110 -0
  16. package/build/ConsoleUI.js.map +1 -0
  17. package/build/Debug.d.ts +154 -0
  18. package/build/Debug.js +256 -0
  19. package/build/Debug.js.map +1 -0
  20. package/build/LoggerManager/Logger.d.ts +23 -0
  21. package/build/LoggerManager/Logger.js +23 -0
  22. package/build/LoggerManager/Logger.js.map +1 -0
  23. package/build/LoggerManager/LoggerManager.d.ts +18 -0
  24. package/build/LoggerManager/LoggerManager.js +30 -0
  25. package/build/LoggerManager/LoggerManager.js.map +1 -0
  26. package/build/Server/BodyParser.d.ts +125 -0
  27. package/build/Server/BodyParser.js +162 -0
  28. package/build/Server/BodyParser.js.map +1 -0
  29. package/build/Server/Cookie.d.ts +72 -0
  30. package/build/Server/Cookie.js +102 -0
  31. package/build/Server/Cookie.js.map +1 -0
  32. package/build/Server/Request.d.ts +61 -0
  33. package/build/Server/Request.js +79 -0
  34. package/build/Server/Request.js.map +1 -0
  35. package/build/Server/Response.d.ts +90 -0
  36. package/build/Server/Response.js +241 -0
  37. package/build/Server/Response.js.map +1 -0
  38. package/build/Server/Rule.d.ts +81 -0
  39. package/build/Server/Rule.js +146 -0
  40. package/build/Server/Rule.js.map +1 -0
  41. package/build/Server/Server.d.ts +157 -0
  42. package/build/Server/Server.js +330 -0
  43. package/build/Server/Server.js.map +1 -0
  44. package/build/Server/Session.d.ts +66 -0
  45. package/build/Server/Session.js +97 -0
  46. package/build/Server/Session.js.map +1 -0
  47. package/build/Server/WebSocket/Chunk.d.ts +36 -0
  48. package/build/Server/WebSocket/Chunk.js +81 -0
  49. package/build/Server/WebSocket/Chunk.js.map +1 -0
  50. package/build/Server/WebSocket/WebSocket.d.ts +70 -0
  51. package/build/Server/WebSocket/WebSocket.js +184 -0
  52. package/build/Server/WebSocket/WebSocket.js.map +1 -0
  53. package/build/Template.d.ts +32 -0
  54. package/build/Template.js +69 -0
  55. package/build/Template.js.map +1 -0
  56. package/build/Utilities/Env.d.ts +75 -0
  57. package/build/Utilities/Env.js +123 -0
  58. package/build/Utilities/Env.js.map +1 -0
  59. package/build/Utilities/Path.d.ts +18 -0
  60. package/build/Utilities/Path.js +27 -0
  61. package/build/Utilities/Path.js.map +1 -0
  62. package/build/Utilities/Utilities.d.ts +147 -0
  63. package/build/Utilities/Utilities.js +110 -0
  64. package/build/Utilities/Utilities.js.map +1 -0
  65. package/build/Vortez.d.ts +20 -0
  66. package/build/Vortez.js +22 -0
  67. package/build/Vortez.js.map +1 -0
  68. package/changes.md +89 -0
  69. package/examples/in-docs.js +96 -0
  70. package/global/Source/Logo_960.png +0 -0
  71. package/global/Source/Logo_SM_960.png +0 -0
  72. package/global/Style/Template/Error.css +30 -0
  73. package/global/Style/Template/Folder.css +77 -0
  74. package/global/Style/Template/Template.css +128 -0
  75. package/global/Template/Error.vhtml +29 -0
  76. package/global/Template/Folder.vhtml +41 -0
  77. package/package.json +47 -0
  78. package/tests/Template/template.js +18 -0
  79. package/tests/Template/template.txt +13 -0
  80. package/tests/Template/template.vhtml +23 -0
  81. package/tests/debug.js +28 -0
  82. package/tests/jwtManager/jwtManager.js +110 -0
  83. package/tests/test.js +129 -0
  84. package/tests/test.vhtml +14 -0
  85. package/tests/utilities.js +28 -0
  86. package/tests/websocket.vhtml +86 -0
@@ -0,0 +1,23 @@
1
+ import Debug from "../Debug.js";
2
+ export declare class Logger {
3
+ private prefix;
4
+ private format;
5
+ private debug;
6
+ constructor(options: Logger.Options);
7
+ get save(): boolean;
8
+ set save(value: boolean);
9
+ get show(): boolean;
10
+ set show(value: boolean);
11
+ log(...data: any[]): void;
12
+ warn(...data: any[]): void;
13
+ info(...data: any[]): void;
14
+ error(...data: any[]): void;
15
+ }
16
+ export declare namespace Logger {
17
+ interface Options {
18
+ prefix: string;
19
+ format?: string;
20
+ debug?: Debug;
21
+ }
22
+ }
23
+ export default Logger;
@@ -0,0 +1,23 @@
1
+ import ConsoleUI from "../ConsoleUI.js";
2
+ import Debug from "../Debug.js";
3
+ export class Logger {
4
+ prefix;
5
+ format;
6
+ debug;
7
+ constructor(options) {
8
+ const { prefix, format = '&R&C7', debug } = options;
9
+ this.prefix = prefix;
10
+ this.format = format;
11
+ this.debug = debug ?? Debug.getInstance(ConsoleUI.cleanFormat(prefix));
12
+ }
13
+ get save() { return this.debug.save; }
14
+ set save(value) { this.debug.save = value; }
15
+ get show() { return this.debug.show; }
16
+ set show(value) { this.debug.show = value; }
17
+ log(...data) { this.debug.log(`&C2[${this.prefix}&C2]:${this.format}`, ...data); }
18
+ warn(...data) { this.debug.warn(`&C3[${this.prefix}&C3]:${this.format}`, ...data); }
19
+ info(...data) { this.debug.info(`&C6[${this.prefix}&C6]:${this.format}`, ...data); }
20
+ error(...data) { this.debug.error(`&C1[${this.prefix}&C1]:${this.format}`, ...data); }
21
+ }
22
+ export default Logger;
23
+ //# sourceMappingURL=Logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/LoggerManager/Logger.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,aAAa,CAAC;AAEhC,MAAM,OAAO,MAAM;IACP,MAAM,CAAS;IACf,MAAM,CAAS;IACf,KAAK,CAAQ;IACrB,Y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AAK,CAAC,OAAO,IAAI,CAAC,MAAM,QAAQ,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;CACxG;AAQD,eAAe,MAAM,CAAC"}
@@ -0,0 +1,18 @@
1
+ import _Logger from "./Logger.js";
2
+ export declare class LoggerManager {
3
+ private static instance;
4
+ static getInstance(): LoggerManager;
5
+ server: LoggerManager.Logger;
6
+ request: LoggerManager.Logger;
7
+ response: LoggerManager.Logger;
8
+ webSocket: LoggerManager.Logger;
9
+ private constructor();
10
+ log(...data: any[]): void;
11
+ info(...data: any[]): void;
12
+ warn(...data: any[]): void;
13
+ error(...data: any[]): void;
14
+ }
15
+ export declare namespace LoggerManager {
16
+ export import Logger = _Logger;
17
+ }
18
+ export default LoggerManager;
@@ -0,0 +1,30 @@
1
+ import Debug from "../Debug.js";
2
+ import _Logger from "./Logger.js";
3
+ export class LoggerManager {
4
+ static instance;
5
+ static getInstance() {
6
+ if (!LoggerManager.instance)
7
+ LoggerManager.instance = new LoggerManager();
8
+ return LoggerManager.instance;
9
+ }
10
+ server;
11
+ request;
12
+ response;
13
+ webSocket;
14
+ constructor() {
15
+ const $debug = Debug.getInstance();
16
+ this.server = new LoggerManager.Logger({ prefix: 'Server', debug: $debug });
17
+ this.request = new LoggerManager.Logger({ prefix: 'Request', debug: $debug });
18
+ this.response = new LoggerManager.Logger({ prefix: 'Response', debug: $debug });
19
+ this.webSocket = new LoggerManager.Logger({ prefix: 'WebSocket', debug: $debug });
20
+ }
21
+ log(...data) { this.server.log(...data); }
22
+ info(...data) { this.server.info(...data); }
23
+ warn(...data) { this.server.warn(...data); }
24
+ error(...data) { this.server.error(...data); }
25
+ }
26
+ (function (LoggerManager) {
27
+ LoggerManager.Logger = _Logger;
28
+ })(LoggerManager || (LoggerManager = {}));
29
+ export default LoggerManager;
30
+ //# sourceMappingURL=LoggerManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoggerManager.js","sourceRoot":"","sources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GAAG,IAAW,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACnD,KAAK,CAAC,GAAG,IAAW,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;CAC/D;AACD,WAAiB,aAAa;IACZ,oBAAM,GAAG,OAAO,CAAC;AACnC,CAAC,EAFgB,aAAa,KAAb,aAAa,QAE7B;AACD,eAAe,aAAa,CAAC"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * @author NetFeez <codefeez.dev@gmail.com>
3
+ * @description Adds the POST parser form of `Vortez`.
4
+ * @license Apache-2.0
5
+ */
6
+ import HTTP from 'http';
7
+ export declare class BodyParser {
8
+ protected readonly headers: HTTP.IncomingHttpHeaders;
9
+ protected readonly httpRequest: HTTP.IncomingMessage;
10
+ private static FORMDATA_VAR_INFO_REGEX;
11
+ constructor(headers: HTTP.IncomingHttpHeaders, httpRequest: HTTP.IncomingMessage);
12
+ /**
13
+ * Parses the HTTP request body based on its `Content-Type`.
14
+ * Supports JSON, plain text, URL-encoded forms, and multipart forms.
15
+ * @returns A structured object containing the parsed content and optional files.
16
+ */
17
+ parse(): Promise<BodyParser.Body>;
18
+ /**
19
+ * Extracts the request body as a Buffer.
20
+ * @throws if the body stream fails.
21
+ * @returns The full request body as a Buffer.
22
+ */
23
+ private extractBody;
24
+ /**
25
+ * Processes a `text/plain` body.
26
+ * @param body - The raw body buffer.
27
+ * @returns Object with MIME type, decoded text content, and no files.
28
+ */
29
+ private processText;
30
+ /**
31
+ * Processes an `application/json` body.
32
+ * @param body - The raw body buffer.
33
+ * @returns Object with MIME type, parsed JSON content, and no files.
34
+ * @throws If the JSON is invalid.
35
+ */
36
+ private processJson;
37
+ /**
38
+ * Processes an `application/x-www-form-urlencoded` body.
39
+ * @param body - The raw body buffer.
40
+ * @returns Object with MIME type, key-value content, and no files.
41
+ */
42
+ private processUrlEncoded;
43
+ /**
44
+ * Processes a `multipart/form-data` body.
45
+ * Extracts both field values and uploaded files.
46
+ * @param body - The raw body buffer.
47
+ * @param options - Header options (usually includes the boundary).
48
+ * @returns Object with MIME type, form fields, and files.
49
+ */
50
+ private processFormData;
51
+ /**
52
+ * Extracts multipart field or file information from a raw string fragment.
53
+ * @param data - The individual multipart fragment.
54
+ * @returns Parsed multipart info or `null` if parsing fails.
55
+ */
56
+ private getMultiPartInfo;
57
+ /**
58
+ * Tries to infer the boundary from the first line of the request body.
59
+ * @param body - The request body.
60
+ */
61
+ private inferBoundary;
62
+ }
63
+ export declare namespace BodyParser {
64
+ namespace Body {
65
+ namespace Mimes {
66
+ interface Base {
67
+ mimeType: string;
68
+ content: any;
69
+ files: FileList | null;
70
+ }
71
+ interface Json extends Base {
72
+ mimeType: 'application/json';
73
+ content: any;
74
+ files: null;
75
+ }
76
+ interface Text extends Base {
77
+ mimeType: 'text/plain';
78
+ content: string;
79
+ files: null;
80
+ }
81
+ interface UrlEncoded extends Base {
82
+ mimeType: 'application/x-www-form-urlencoded';
83
+ content: Body.VarList;
84
+ files: null;
85
+ }
86
+ interface FormData extends Base {
87
+ mimeType: 'multipart/form-data';
88
+ content: Body.VarList;
89
+ files: Body.FileList;
90
+ }
91
+ interface None extends Base {
92
+ mimeType: 'none';
93
+ content: VarList;
94
+ files: null;
95
+ }
96
+ interface Unknown extends Base {
97
+ mimeType: 'unknown';
98
+ content: Buffer;
99
+ files: null;
100
+ }
101
+ }
102
+ interface File {
103
+ content: Buffer;
104
+ name: string;
105
+ size: number;
106
+ mimeType: string;
107
+ }
108
+ interface FileList {
109
+ [name: string]: File | undefined;
110
+ }
111
+ interface VarList {
112
+ [name: string]: string | undefined;
113
+ }
114
+ }
115
+ namespace MultiPart {
116
+ interface Info {
117
+ varName: string;
118
+ fileName: string | null;
119
+ mimeType: string | null;
120
+ content: Buffer;
121
+ }
122
+ }
123
+ type Body = (Body.Mimes.Json | Body.Mimes.UrlEncoded | Body.Mimes.Text | Body.Mimes.Unknown | Body.Mimes.None | Body.Mimes.FormData);
124
+ }
125
+ export default BodyParser;
@@ -0,0 +1,162 @@
1
+ /**
2
+ * @author NetFeez <codefeez.dev@gmail.com>
3
+ * @description Adds the POST parser form of `Vortez`.
4
+ * @license Apache-2.0
5
+ */
6
+ export class BodyParser {
7
+ headers;
8
+ httpRequest;
9
+ static FORMDATA_VAR_INFO_REGEX = /Content-Disposition: ?form-data;? ?name="(.*?)?";? ?(?:filename="(.*?)?")?(?:\s*)?(?:Content-Type: ?(.*)?)?([^]*)/i;
10
+ constructor(headers, httpRequest) {
11
+ this.headers = headers;
12
+ this.httpRequest = httpRequest;
13
+ }
14
+ /**
15
+ * Parses the HTTP request body based on its `Content-Type`.
16
+ * Supports JSON, plain text, URL-encoded forms, and multipart forms.
17
+ * @returns A structured object containing the parsed content and optional files.
18
+ */
19
+ async parse() {
20
+ const contentType = this.headers['content-type'] || null;
21
+ if (!contentType)
22
+ return { mimeType: 'none', content: {}, files: null };
23
+ const body = await this.extractBody();
24
+ const [format, ...options] = contentType.trim().split(';');
25
+ switch (format) {
26
+ case 'text/plain': return this.processText(body);
27
+ case 'application/json': return this.processJson(body);
28
+ case 'application/x-www-form-urlencoded': return this.processUrlEncoded(body);
29
+ case 'multipart/form-data': return this.processFormData(body, options);
30
+ default: return { mimeType: 'unknown', content: body, files: null };
31
+ }
32
+ }
33
+ /**
34
+ * Extracts the request body as a Buffer.
35
+ * @throws if the body stream fails.
36
+ * @returns The full request body as a Buffer.
37
+ */
38
+ async extractBody() {
39
+ const chunks = [];
40
+ return new Promise((resolve, reject) => {
41
+ this.httpRequest.on('end', () => resolve(Buffer.concat(chunks)));
42
+ this.httpRequest.on('error', (error) => reject(Error('fail parsing request body', { cause: error })));
43
+ this.httpRequest.on('data', (chunk) => {
44
+ if (chunks.length > 1e+8)
45
+ return void this.httpRequest.destroy();
46
+ chunks.push(chunk);
47
+ });
48
+ });
49
+ }
50
+ /**
51
+ * Processes a `text/plain` body.
52
+ * @param body - The raw body buffer.
53
+ * @returns Object with MIME type, decoded text content, and no files.
54
+ */
55
+ processText(body) {
56
+ const text = body.toString('utf-8');
57
+ return {
58
+ mimeType: 'text/plain',
59
+ content: text,
60
+ files: null
61
+ };
62
+ }
63
+ /**
64
+ * Processes an `application/json` body.
65
+ * @param body - The raw body buffer.
66
+ * @returns Object with MIME type, parsed JSON content, and no files.
67
+ * @throws If the JSON is invalid.
68
+ */
69
+ processJson(body) {
70
+ try {
71
+ const text = body.toString('utf-8');
72
+ return {
73
+ mimeType: 'application/json',
74
+ content: JSON.parse(text),
75
+ files: null
76
+ };
77
+ }
78
+ catch (error) {
79
+ throw new Error('fail extracting json body', { cause: error });
80
+ }
81
+ }
82
+ /**
83
+ * Processes an `application/x-www-form-urlencoded` body.
84
+ * @param body - The raw body buffer.
85
+ * @returns Object with MIME type, key-value content, and no files.
86
+ */
87
+ processUrlEncoded(body) {
88
+ const content = {};
89
+ const decoded = body.toString('latin1');
90
+ const fragments = decoded.split('&');
91
+ fragments.forEach((pair) => {
92
+ const [key, value] = pair.split('=');
93
+ content[decodeURIComponent(key)] = decodeURIComponent(value);
94
+ });
95
+ return {
96
+ mimeType: 'application/x-www-form-urlencoded',
97
+ content: content,
98
+ files: null
99
+ };
100
+ }
101
+ /**
102
+ * Processes a `multipart/form-data` body.
103
+ * Extracts both field values and uploaded files.
104
+ * @param body - The raw body buffer.
105
+ * @param options - Header options (usually includes the boundary).
106
+ * @returns Object with MIME type, form fields, and files.
107
+ */
108
+ processFormData(body, options = []) {
109
+ const content = {};
110
+ const files = {};
111
+ const boundary = options.join(';').replace(/.*boundary=(.*)/gi, (result, boundary) => boundary);
112
+ const separator = '--' + (boundary !== '' ? boundary : this.inferBoundary(body) ?? '');
113
+ const decoded = body.toString('latin1').trim();
114
+ const fragments = decoded.split(separator);
115
+ fragments.forEach((fragment) => {
116
+ const info = this.getMultiPartInfo(fragment);
117
+ if (info == null)
118
+ return;
119
+ if (info.fileName == null)
120
+ return void (content[info.varName] = info.content.toString());
121
+ files[info.varName] = {
122
+ name: info.fileName,
123
+ size: info.content.length,
124
+ mimeType: info.mimeType || 'unknown',
125
+ content: info.content
126
+ };
127
+ });
128
+ return {
129
+ mimeType: 'multipart/form-data',
130
+ content, files
131
+ };
132
+ }
133
+ /**
134
+ * Extracts multipart field or file information from a raw string fragment.
135
+ * @param data - The individual multipart fragment.
136
+ * @returns Parsed multipart info or `null` if parsing fails.
137
+ */
138
+ getMultiPartInfo(data) {
139
+ const info = BodyParser.FORMDATA_VAR_INFO_REGEX.exec(data.trim());
140
+ if (info == null)
141
+ return null;
142
+ const [varName = "", fileName = null, mimeType = null, content = ""] = info.splice(1);
143
+ return {
144
+ varName: Buffer.from(varName.trim(), 'binary').toString(),
145
+ content: Buffer.from(content.trim(), 'binary'),
146
+ fileName: fileName !== null ? Buffer.from(fileName.trim(), 'binary').toString() : null,
147
+ mimeType: mimeType !== null ? Buffer.from(mimeType.trim(), 'binary').toString() : null
148
+ };
149
+ }
150
+ /**
151
+ * Tries to infer the boundary from the first line of the request body.
152
+ * @param body - The request body.
153
+ */
154
+ inferBoundary(body) {
155
+ const result = body.toString('latin1').match(/^--([^\r\n]+)/);
156
+ if (result == null)
157
+ return null;
158
+ return result[1];
159
+ }
160
+ }
161
+ export default BodyParser;
162
+ //# sourceMappingURL=BodyParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BodyParser.js","sourceRoot":"","sources":["../../src/Server/BodyParser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,OAAO,UAAU;IAGI;IACA;IAHf,MAAM,CAAC,uBAAuB,GAAG,oHAAoH,CAAC;IAC9J,YACuB,OAAiC,EACjC,WAAiC;QADjC,YAAO,GAAP,OAAO,CAA0B;QACjC,gBAAW,GAAX,WAAW,CAAsB;IACrD,CAAC;IACJ;;;;OAIA;IACO,KAAK,CAAC,KAAK;QACd,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,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,EAAE,CAAC,CAAC,CAAC,IAAI;SACzF,CAAC;IACN,CAAC;IACJ;;;OAGG;IACK,aAAa,CAAC,IAAY;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC9D,IAAI,MAAM,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;QAChC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;;AAuEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @author NetFeez <codefeez.dev@gmail.com>
3
+ * @description Adds a cookie system to `Vortez`.
4
+ * @license Apache-2.0
5
+ */
6
+ export declare class Cookie {
7
+ /** Contains the all the data of the session */
8
+ private data;
9
+ /** Contains the news data of the session */
10
+ private news;
11
+ /**
12
+ * Parses cookies from the "Cookie" header.
13
+ * @param cookieHeader - The Cookie header string.
14
+ */
15
+ constructor(cookieHeader?: string);
16
+ /**
17
+ * Checks if a cookie exists.
18
+ * @param name - The name of the cookie to check.
19
+ * @returns True if the cookie exists, otherwise false.
20
+ */
21
+ has(name: string): boolean;
22
+ /**
23
+ * Retrieves a cookie by name.
24
+ * @param name - The name of the cookie to retrieve.
25
+ * @returns The cookie value or undefined if not found.
26
+ */
27
+ get(name: string): string | undefined;
28
+ /**
29
+ * Returns an object with all parsed cookies.
30
+ * - This object is not reactive: changes will not be reflected.
31
+ * @returns A plain object of cookies.
32
+ */
33
+ getAll(): Cookie.CookieObject;
34
+ /**
35
+ * Returns an array of "Set-Cookie" header strings.
36
+ * @returns An array of formatted Set-Cookie strings.
37
+ */
38
+ getSetters(): string[];
39
+ /**
40
+ * Sets or replaces a cookie.
41
+ * @param name - The name of the cookie to set.
42
+ * @param value - The value to assign to the cookie.
43
+ * @param options - Optional settings for the cookie.
44
+ */
45
+ set(name: string, value: string, options?: Cookie.SetOptions): void;
46
+ /**
47
+ * Deletes a cookie.
48
+ * @param name - The name of the cookie to delete.
49
+ */
50
+ delete(name: string): void;
51
+ }
52
+ export declare namespace Cookie {
53
+ interface CookieObject {
54
+ [key: string]: string | undefined;
55
+ }
56
+ interface SetOptions {
57
+ domain?: string;
58
+ expires?: Date;
59
+ httpOnly?: boolean;
60
+ path?: string;
61
+ sameSite?: 'Strict' | 'Lax' | 'None';
62
+ maxAge?: number;
63
+ secure?: boolean;
64
+ }
65
+ type SetData = (SetOptions & {
66
+ delete: false;
67
+ value: string;
68
+ }) | {
69
+ delete: true;
70
+ };
71
+ }
72
+ export default Cookie;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * @author NetFeez <codefeez.dev@gmail.com>
3
+ * @description Adds a cookie system to `Vortez`.
4
+ * @license Apache-2.0
5
+ */
6
+ export class Cookie {
7
+ /** Contains the all the data of the session */
8
+ data;
9
+ /** Contains the news data of the session */
10
+ news;
11
+ /**
12
+ * Parses cookies from the "Cookie" header.
13
+ * @param cookieHeader - The Cookie header string.
14
+ */
15
+ constructor(cookieHeader) {
16
+ this.data = new Map();
17
+ this.news = new Map();
18
+ if (!cookieHeader)
19
+ return;
20
+ const cookies = cookieHeader.split(';');
21
+ for (const cookie of cookies) {
22
+ const [name, ...value] = cookie.split('=');
23
+ this.data.set(name.trim(), value.join('=').trim());
24
+ }
25
+ }
26
+ /**
27
+ * Checks if a cookie exists.
28
+ * @param name - The name of the cookie to check.
29
+ * @returns True if the cookie exists, otherwise false.
30
+ */
31
+ has(name) { return this.data.has(name); }
32
+ /**
33
+ * Retrieves a cookie by name.
34
+ * @param name - The name of the cookie to retrieve.
35
+ * @returns The cookie value or undefined if not found.
36
+ */
37
+ get(name) { return this.data.get(name); }
38
+ /**
39
+ * Returns an object with all parsed cookies.
40
+ * - This object is not reactive: changes will not be reflected.
41
+ * @returns A plain object of cookies.
42
+ */
43
+ getAll() {
44
+ const cookies = {};
45
+ this.data.forEach((value, key) => cookies[key] = value);
46
+ return cookies;
47
+ }
48
+ /**
49
+ * Returns an array of "Set-Cookie" header strings.
50
+ * @returns An array of formatted Set-Cookie strings.
51
+ */
52
+ getSetters() {
53
+ const setStrings = [];
54
+ this.news.forEach((value, name) => {
55
+ if (value.delete) {
56
+ setStrings.push(`${name}=None;Path=/;Expires=${(new Date).toUTCString()}`);
57
+ }
58
+ else {
59
+ let setter = `${name}=${value.value}`;
60
+ setter += value.domain ? `;Domain=${value.domain}` : '';
61
+ setter += value.expires ? `;Expires=${value.expires.toUTCString()}` : '';
62
+ setter += value.httpOnly ? ';HttpOnly' : '';
63
+ setter += value.maxAge ? `;Max-Age=${value.maxAge}` : '';
64
+ setter += value.path ? `;Path=${value.path}` : '';
65
+ setter += value.sameSite ? `;SameSite=${value.sameSite}` : '';
66
+ setter += value.secure ? ';Secure' : '';
67
+ setStrings.push(setter);
68
+ }
69
+ });
70
+ return setStrings;
71
+ }
72
+ /**
73
+ * Sets or replaces a cookie.
74
+ * @param name - The name of the cookie to set.
75
+ * @param value - The value to assign to the cookie.
76
+ * @param options - Optional settings for the cookie.
77
+ */
78
+ set(name, value, options = {}) {
79
+ this.news.set(name, {
80
+ delete: false,
81
+ domain: options.domain ?? undefined,
82
+ expires: options.expires ?? undefined,
83
+ httpOnly: options.httpOnly ?? undefined,
84
+ maxAge: options.maxAge ?? undefined,
85
+ path: options.path ?? undefined,
86
+ sameSite: options.sameSite ?? undefined,
87
+ secure: options.secure ?? undefined,
88
+ value: value
89
+ });
90
+ this.data.set(name, value);
91
+ }
92
+ /**
93
+ * Deletes a cookie.
94
+ * @param name - The name of the cookie to delete.
95
+ */
96
+ delete(name) {
97
+ this.data.delete(name);
98
+ this.news.set(name, { delete: true });
99
+ }
100
+ }
101
+ export default Cookie;
102
+ //# sourceMappingURL=Cookie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cookie.js","sourceRoot":"","sources":["../../src/Server/Cookie.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,OAAO,MAAM;IACf,+CAA+C;IACvC,IAAI,CAAsB;IA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,CAAC,IAAI,EAAE;YAChB,MAAM,EAAE,KAAK;YACb,MAAM,EAAI,OAAO,CAAC,MAAM,IAAM,SAAS;YACvC,OAAO,EAAG,OAAO,CAAC,OAAO,IAAK,SAAS;YACvC,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS;YACvC,MAAM,EAAI,OAAO,CAAC,MAAM,IAAM,SAAS;YACvC,IAAI,EAAM,OAAO,CAAC,IAAI,IAAQ,SAAS;YACvC,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS;YACvC,MAAM,EAAI,OAAO,CAAC,MAAM,IAAM,SAAS;YACvC,KAAK,EAAE,KAAK;SACf,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,IAAY;QACtB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;CACJ;AAuBD,eAAe,MAAM,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @author NetFeez <codefeez.dev@gmail.com>
3
+ * @description Adds the Request form of `Vortez`.
4
+ * @license Apache-2.0
5
+ */
6
+ import HTTP from 'http';
7
+ import Cookie from './Cookie.js';
8
+ import Session from './Session.js';
9
+ import _BodyParser, { BodyParser } from './BodyParser.js';
10
+ export declare class Request {
11
+ /** Contains the request headers. */
12
+ headers: Request.Headers;
13
+ /** Contains the request cookies. */
14
+ cookies: Cookie;
15
+ /** Contains the POST data sent. */
16
+ searchParams: Request.SearchParams;
17
+ /** Contains the IP address of the requester. */
18
+ ip?: string | string[];
19
+ /** Contains the request method. */
20
+ method: Request.Method;
21
+ /** Contains the POSTParser. */
22
+ session: Session;
23
+ /** Contains the session of the device that made the request. */
24
+ private body;
25
+ /** Contains the HTTP request received by the server. */
26
+ private httpRequest;
27
+ /** Contains the request URL. */
28
+ url: string;
29
+ /** The UrlRule parameters */
30
+ ruleParams: Request.RuleParams;
31
+ /**
32
+ * Creates the request form for `NetFeez-Labs/Server`.
33
+ * @param httpRequest - The HTTP request received by the server.
34
+ */
35
+ constructor(httpRequest: HTTP.IncomingMessage);
36
+ get post(): Promise<BodyParser.Body>;
37
+ /**
38
+ * Defines which method was used to make the request.
39
+ * @param method - The method used for the request.
40
+ */
41
+ private getMethod;
42
+ /**
43
+ * Retrieves the data sent via URL QUERY.
44
+ * @param Url - The URL received from the HTTP request.
45
+ */
46
+ private getSearchParams;
47
+ }
48
+ export declare namespace Request {
49
+ export import BodyParser = _BodyParser;
50
+ interface Document {
51
+ [name: string]: string | undefined;
52
+ }
53
+ interface RuleParams extends Document {
54
+ }
55
+ interface Headers extends HTTP.IncomingHttpHeaders {
56
+ }
57
+ interface SearchParams extends Document {
58
+ }
59
+ type Method = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'ALL';
60
+ }
61
+ export default Request;