tachyon-rs 0.2.11 → 0.2.13
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 +1 -1
- package/dist/response.d.ts +4 -0
- package/dist/response.d.ts.map +1 -1
- package/dist/tachyon.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{TachyonRawServer as
|
|
1
|
+
import{TachyonRawServer as M}from"@tachyon-rs/server";class i{method;path;body;_headers;constructor(d){this.method=d.method,this.path=d.path,this.body=d.body,this._headers=new Map(d.headers.map((t)=>[t.name.toLowerCase(),t.value]))}header(d){return this._headers.get(d.toLowerCase())}get headers(){return this._headers}}class m{status;body;headers=[];_contentType="json";constructor(d,t){this.status=d;this.body=t}header(d,t){return this.headers.push({name:d,value:t}),this}text(){return this._contentType="text",this}json(){return{status:this.status,body:this.body,contentType:this._contentType,headers:this.headers.length>0?this.headers:void 0}}}class b{routes;plugins=[];config;constructor(d){this.routes=new Map,this.config=d??{}}use(d){return this.plugins.push(d),this}transformToResponse(d){if(typeof d==="string")return()=>new m(200,d).text();else if(typeof d==="function")return d;else{let t=JSON.stringify(d);return()=>new m(200,t)}}get(d,t){return this.routes.set("GET@"+d,this.transformToResponse(t)),this}post(d,t){return this.routes.set("POST@"+d,this.transformToResponse(t)),this}put(d,t){return this.routes.set("PUT@"+d,this.transformToResponse(t)),this}delete(d,t){return this.routes.set("DELETE@"+d,this.transformToResponse(t)),this}listen(d){new M({bindAddr:"0.0.0.0:"+d,workers:this.config.workers??4,security:this.config.security??"basic",compressionThreshold:this.config.compressionThreshold}).start((C)=>{let f=new i(C);for(let y of this.plugins){let g=y.pre?.(f);if(g)return g.json()}let _=this.routes.get(f.method+"@"+f.path),x=_?_(f):new m(404,"Not Found");for(let y of this.plugins){let g=y.pos?.(f,x);if(g)x=g}return x.json()})}}export{m as TachyonResponse,i as TachyonRequest,b as Tachyon};
|
package/dist/response.d.ts
CHANGED
|
@@ -2,11 +2,15 @@ declare class TachyonResponse {
|
|
|
2
2
|
status: number;
|
|
3
3
|
body: string;
|
|
4
4
|
private headers;
|
|
5
|
+
private _contentType;
|
|
5
6
|
constructor(status: number, body: string);
|
|
6
7
|
header(name: string, value: string): this;
|
|
8
|
+
/** Set response content type to plain text. */
|
|
9
|
+
text(): this;
|
|
7
10
|
json(): {
|
|
8
11
|
status: number;
|
|
9
12
|
body: string;
|
|
13
|
+
contentType: "json" | "text";
|
|
10
14
|
headers: {
|
|
11
15
|
name: string;
|
|
12
16
|
value: string;
|
package/dist/response.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../src/response.ts"],"names":[],"mappings":"AAAA,cAAM,eAAe;
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../src/response.ts"],"names":[],"mappings":"AAAA,cAAM,eAAe;IAIA,MAAM,EAAE,MAAM;IAAS,IAAI,EAAE,MAAM;IAHtD,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,YAAY,CAA0B;gBAE3B,MAAM,EAAE,MAAM,EAAS,IAAI,EAAE,MAAM;IAEtD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAKlC,+CAA+C;IAC/C,IAAI;IAKJ,IAAI;;;;;kBAhBqB,MAAM;mBAAS,MAAM;;;CAwB/C;AAED,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
package/dist/tachyon.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tachyon.d.ts","sourceRoot":"","sources":["../src/tachyon.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,C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yon-rs/server && tsc"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@tachyon-rs/server": "0.2.
|
|
20
|
+
"@tachyon-rs/server": "0.2.13"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/bun": "latest",
|
|
24
24
|
"typescript": "^5"
|
|
25
25
|
},
|
|
26
|
-
"version": "0.2.
|
|
26
|
+
"version": "0.2.13"
|
|
27
27
|
}
|