@ooneex/http-request 0.13.0 → 0.15.0

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.js CHANGED
@@ -1,62 +1,3 @@
1
- // src/HttpRequest.ts
2
- import { Header } from "@ooneex/http-header";
3
- import { RequestFile } from "@ooneex/http-request-file";
4
- import { Url } from "@ooneex/url";
5
- import parser from "accept-language-parser";
1
+ import{Header as n}from"@ooneex/http-header";import{RequestFile as s}from"@ooneex/http-request-file";import{Url as i}from"@ooneex/url";import p from"accept-language-parser";class a{native;path;url;method;header;userAgent;params={};payload={};queries={};form;files={};ip;host;language;constructor(l,e){this.native=l;if(this.url=new i(this.native.url),this.path=this.url.getPath(),this.method=this.native.method.toUpperCase(),this.header=new n(l.headers),this.queries=this.url.getQueries(),this.payload=e?.payload||{},this.params=e?.params||{},this.form=e?.form||null,this.userAgent=this.header.getUserAgent(),e?.form)e.form.forEach((r,t)=>{if(r instanceof File)this.files[t]=new s(r)});this.ip=e?.ip||null,this.host=this.header.getHost()||"";let o=this.url.getQuery("lang")||this.url.getQuery("locale")||this.header.get("X-Custom-Lang");if(o)this.language={code:o,region:null};else{let t=p.parse(this.header.get("Accept-Language")??"en-US")[0];this.language={code:t?.code,region:t?.region??null}}}}export{a as HttpRequest};
6
2
 
7
- class HttpRequest {
8
- native;
9
- path;
10
- url;
11
- method;
12
- header;
13
- userAgent;
14
- params = {};
15
- payload = {};
16
- queries = {};
17
- form;
18
- files = {};
19
- ip;
20
- host;
21
- language;
22
- constructor(native, config) {
23
- this.native = native;
24
- this.url = new Url(this.native.url);
25
- this.path = this.url.getPath();
26
- this.method = this.native.method.toUpperCase();
27
- this.header = new Header(native.headers);
28
- this.queries = this.url.getQueries();
29
- this.payload = config?.payload || {};
30
- this.params = config?.params || {};
31
- this.form = config?.form || null;
32
- this.userAgent = this.header.getUserAgent();
33
- if (config?.form) {
34
- config.form.forEach((value, key) => {
35
- if (value instanceof File) {
36
- this.files[key] = new RequestFile(value);
37
- }
38
- });
39
- }
40
- this.ip = config?.ip || null;
41
- this.host = this.header.getHost() || "";
42
- const customLang = this.url.getQuery("lang") || this.url.getQuery("locale") || this.header.get("X-Custom-Lang");
43
- if (customLang) {
44
- this.language = {
45
- code: customLang,
46
- region: null
47
- };
48
- } else {
49
- const languages = parser.parse(this.header.get("Accept-Language") ?? "en-US");
50
- const language = languages[0];
51
- this.language = {
52
- code: language?.code,
53
- region: language?.region ?? null
54
- };
55
- }
56
- }
57
- }
58
- export {
59
- HttpRequest
60
- };
61
-
62
- //# debugId=4D868DC43B9DFAA464756E2164756E21
3
+ //# debugId=0A38759E9735862264756E2164756E21
package/dist/index.js.map CHANGED
@@ -4,7 +4,7 @@
4
4
  "sourcesContent": [
5
5
  "import { Header, type IUserAgent } from \"@ooneex/http-header\";\nimport { type IRequestFile, RequestFile } from \"@ooneex/http-request-file\";\nimport type { LocaleInfoType, LocaleType } from \"@ooneex/translation\";\nimport type { HttpMethodType, ScalarType } from \"@ooneex/types\";\nimport { type IUrl, Url } from \"@ooneex/url\";\nimport parser from \"accept-language-parser\";\nimport type { IRequest, RequestConfigType } from \"./types\";\n\nexport class HttpRequest<Config extends RequestConfigType = RequestConfigType> implements IRequest<Config> {\n public readonly path: string;\n public readonly url: IUrl;\n public readonly method: HttpMethodType;\n public readonly header: Header;\n public readonly userAgent: IUserAgent | null;\n public readonly params: Config[\"params\"] = {};\n public readonly payload: Config[\"payload\"] = {};\n public readonly queries: Config[\"queries\"] = {};\n public readonly form: FormData | null;\n public readonly files: Record<string, IRequestFile> = {};\n public readonly ip: string | null;\n public readonly host: string;\n public readonly language: LocaleInfoType;\n\n constructor(\n public readonly native: Readonly<Request>,\n config?: {\n params?: Record<string, ScalarType>;\n form?: FormData | null;\n payload?: Record<string, unknown>;\n ip?: string | null;\n },\n ) {\n this.url = new Url(this.native.url);\n this.path = this.url.getPath();\n this.method = this.native.method.toUpperCase() as HttpMethodType;\n this.header = new Header(native.headers);\n this.queries = this.url.getQueries();\n this.payload = config?.payload || {};\n this.params = config?.params || {};\n this.form = config?.form || null;\n this.userAgent = this.header.getUserAgent();\n\n if (config?.form) {\n config.form.forEach((value, key) => {\n if (value instanceof File) {\n this.files[key] = new RequestFile(value);\n }\n });\n }\n\n this.ip = config?.ip || null;\n this.host = this.header.getHost() || \"\";\n\n const customLang = this.url.getQuery(\"lang\") || this.url.getQuery(\"locale\") || this.header.get(\"X-Custom-Lang\");\n if (customLang) {\n this.language = {\n code: customLang as LocaleType,\n region: null,\n };\n } else {\n const languages = parser.parse(this.header.get(\"Accept-Language\") ?? \"en-US\");\n const language = languages[0];\n this.language = {\n code: language?.code as LocaleType,\n region: language?.region ?? null,\n };\n }\n }\n}\n"
6
6
  ],
7
- "mappings": ";AAAA;AACA;AAGA;AACA;AAAA;AAGO,MAAM,YAA8F;AAAA,EAgBvF;AAAA,EAfF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAA2B,CAAC;AAAA,EAC5B,UAA6B,CAAC;AAAA,EAC9B,UAA6B,CAAC;AAAA,EAC9B;AAAA,EACA,QAAsC,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EAEhB,WAAW,CACO,QAChB,QAMA;AAAA,IAPgB;AAAA,IAQhB,KAAK,MAAM,IAAI,IAAI,KAAK,OAAO,GAAG;AAAA,IAClC,KAAK,OAAO,KAAK,IAAI,QAAQ;AAAA,IAC7B,KAAK,SAAS,KAAK,OAAO,OAAO,YAAY;AAAA,IAC7C,KAAK,SAAS,IAAI,OAAO,OAAO,OAAO;AAAA,IACvC,KAAK,UAAU,KAAK,IAAI,WAAW;AAAA,IACnC,KAAK,UAAU,QAAQ,WAAW,CAAC;AAAA,IACnC,KAAK,SAAS,QAAQ,UAAU,CAAC;AAAA,IACjC,KAAK,OAAO,QAAQ,QAAQ;AAAA,IAC5B,KAAK,YAAY,KAAK,OAAO,aAAa;AAAA,IAE1C,IAAI,QAAQ,MA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CAAC,EACnC,KAAK,OAAS,GAAQ,QAAU,CAAC,EACjC,KAAK,KAAO,GAAQ,MAAQ,KAC5B,KAAK,UAAY,KAAK,OAAO,aAAa,EAEtC,GAAQ,KACV,EAAO,KAAK,QAAQ,CAAC,EAAO,IAAQ,CAClC,GAAI,aAAiB,KACnB,KAAK,MAAM,GAAO,IAAI,EAAY,CAAK,EAE1C,EAGH,KAAK,GAAK,GAAQ,IAAM,KACxB,KAAK,KAAO,KAAK,OAAO,QAAQ,GAAK,GAErC,IAAM,EAAa,KAAK,IAAI,SAAS,MAAM,GAAK,KAAK,IAAI,SAAS,QAAQ,GAAK,KAAK,OAAO,IAAI,eAAe,EAC9G,GAAI,EACF,KAAK,SAAW,CACd,KAAM,EACN,OAAQ,IACV,EACK,KAEL,IAAM,EADY,EAAO,MAAM,KAAK,OAAO,IAAI,iBAAiB,GAAK,OAAO,EACjD,GAC3B,KAAK,SAAW,CACd,KAAM,GAAU,KAChB,OAAQ,GAAU,QAAU,IAC9B,GAGN",
8
+ "debugId": "0A38759E9735862264756E2164756E21",
9
9
  "names": []
10
10
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ooneex/http-request",
3
3
  "description": "HTTP request handling with URL parsing, language detection, headers, and file upload support",
4
- "version": "0.13.0",
4
+ "version": "0.15.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -28,14 +28,14 @@
28
28
  "npm:publish": "bun publish --tolerate-republish --access public"
29
29
  },
30
30
  "dependencies": {
31
- "@ooneex/http-header": "0.12.0",
32
- "@ooneex/http-request-file": "0.12.0",
33
- "@ooneex/url": "0.12.0",
31
+ "@ooneex/http-header": "0.15.0",
32
+ "@ooneex/http-request-file": "0.15.0",
33
+ "@ooneex/url": "0.15.0",
34
34
  "accept-language-parser": "^1.5.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@ooneex/translation": "0.0.13",
38
- "@ooneex/types": "0.0.13",
37
+ "@ooneex/translation": "0.0.16",
38
+ "@ooneex/types": "0.0.16",
39
39
  "@types/accept-language-parser": "^1.5.8"
40
40
  },
41
41
  "keywords": [