@alwatr/nanotron-api-server 9.11.2 → 9.16.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.
@@ -1,7 +1,8 @@
1
1
  import { NanotronServerResponse } from './api-server-response.js';
2
2
  import type { DefineRouteOption, HttpRequestHeaders, NativeClientRequest, NativeServerResponse } from './type.js';
3
3
  import type { NanotronUrl } from './url.js';
4
- export declare class NanotronClientRequest<TSharedMeta extends DictionaryOpt = DictionaryOpt> {
4
+ import type { DictionaryOpt } from '@alwatr/type-helper';
5
+ export declare class NanotronClientRequest<TSharedMeta extends DictionaryOpt<any> = DictionaryOpt<any>> {
5
6
  readonly url: NanotronUrl;
6
7
  readonly serverResponse: NanotronServerResponse;
7
8
  readonly routeOption: Required<DefineRouteOption> | null;
@@ -1 +1 @@
1
- {"version":3,"file":"api-client-request.d.ts","sourceRoot":"","sources":["../src/api-client-request.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAGhE,OAAO,KAAK,EAAC,iBAAiB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,oBAAoB,EAAC,MAAM,WAAW,CAAC;AAChH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,UAAU,CAAC;AAE1C,qBAAa,qBAAqB,CAAC,WAAW,SAAS,aAAa,GAAG,aAAa;IAClF,SAAgB,GAAG,EAAE,WAAW,CAAC;IAEjC,SAAgB,cAAc,EAAE,sBAAsB,CAAC;IAEvD,SAAgB,WAAW,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;IAEhE;;;;;;;;;;;OAWG;IACI,kBAAkB,CAAC,EAAE,IAAI,CAAC;IAEjC,SAAgB,UAAU,EAAE,WAAW,CAAqB;IAE5D,SAAgB,IAAI,EAAE,mBAAmB,CAAC;IAE1C,SAAS,CAAC,QAAQ,CAAC,OAAO,wCAAC;IAE3B,SAAgB,aAAa,EAAE,MAAM,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AAkB,CAEvC;IAED,OAAO,CAAC,aAAa,CAAC,CAAwB;IAC9C,IAAW,WAAW,IAAI,aAAa,CAAC,MAAM,CAAC,CAQ9C;gBAGC,GAAG,EAAE,WAAW,EAChB,mBAAmB,EAAE,mBAAmB,EACxC,oBAAoB,EAAE,oBAAoB,EAC1C,WAAW,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAkB1C,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAwEpC,OAAO,CAAC,kBAAkB;CAG3B"}
@@ -1,6 +1,7 @@
1
1
  import { type HttpStatusCode } from './const.js';
2
2
  import type { NanotronClientRequest } from './api-client-request.js';
3
3
  import type { HttpResponseHeaders, ErrorResponse, NativeServerResponse } from './type.js';
4
+ import type { JsonObject } from '@alwatr/type-helper';
4
5
  /**
5
6
  * Configuration options for the Nanotron Api Server Response.
6
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"api-server-response.d.ts","sourceRoot":"","sources":["../src/api-server-response.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,cAAc,EAAsC,MAAM,YAAY,CAAC;AAEpF,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAC,mBAAmB,EAAE,aAAa,EAAE,oBAAoB,EAAC,MAAM,WAAW,CAAC;AAExF;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,aAAa,EAAE,qBAAqB,CAAC;CACtC;AAED,qBAAa,sBAAsB;IACjC,SAAgB,aAAa,EAAE,qBAAqB,CAAC;IAErD,SAAgB,IAAI,EAAE,oBAAoB,CAAC;IAE3C,SAAgB,OAAO,EAAE,mBAAmB,CAAC;IAE7C,SAAS,CAAC,QAAQ,CAAC,OAAO,wCAAC;IAE3B,SAAS,CAAC,YAAY,UAAS;IAC/B,IAAW,WAAW,IAAI,OAAO,CAEhC;gBAEW,qBAAqB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,oBAAoB;IAw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aAAa,EAAE,aAAa,GAAG,IAAI;IAiBtD,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,IAAI;IAmC/D,SAAS,CAAC,YAAY,EAAE,UAAU,GAAG,IAAI;IAqBzC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAkC7C"}
@@ -1,6 +1,7 @@
1
1
  import { NanotronUrl } from './url.js';
2
2
  import type { DefineRouteOption, MatchType, NativeClientRequest, NativeServerResponse } from './type.js';
3
3
  import type { Duplex } from 'node:stream';
4
+ import type { DictionaryOpt } from '@alwatr/type-helper';
4
5
  /**
5
6
  * Configuration options for the NanotronApiServer.
6
7
  */
@@ -78,7 +79,7 @@ export declare class NanotronApiServer {
78
79
  close(): void;
79
80
  protected getRouteOption_(url: NanotronUrl): Required<DefineRouteOption> | null;
80
81
  protected setRouteOption_(option: Required<DefineRouteOption>): void;
81
- defineRoute<TSharedMeta extends DictionaryOpt = DictionaryOpt>(option: DefineRouteOption<TSharedMeta>): void;
82
+ defineRoute<TSharedMeta extends DictionaryOpt<any> = DictionaryOpt<any>>(option: DefineRouteOption<TSharedMeta>): void;
82
83
  protected handleServerError_(error: NodeJS.ErrnoException): void;
83
84
  protected handleClientError_(err: NodeJS.ErrnoException, socket: Duplex): void;
84
85
  protected handleClientRequest_(nativeClientRequest: NativeClientRequest, nativeServerResponse: NativeServerResponse): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"api-server.d.ts","sourceRoot":"","sources":["../src/api-server.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,WAAW,EAAC,MAAM,UAAU,CAAC;AAErC,OAAO,KAAK,EAAC,iBAAiB,EAAE,SAAS,EAAE,mBAAmB,EAAE,oBAAoB,EAAC,MAAM,WAAW,CAAC;AACvG,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACt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,IAAI;IAQhE,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;cAoB9D,oBAAoB,CAClC,mBAAmB,EAAE,mBAAmB,EACxC,oBAAoB,EAAE,oBAAoB,GACzC,OAAO,CAAC,IAAI,CAAC;IA4ChB,SAAS,CAAC,kBAAkB,IAAI,IAAI;IAgBpC,SAAS,CAAC,gBAAgB,IAAI,IAAI;CAqBnC"}
package/dist/main.js CHANGED
@@ -1,7 +1,7 @@
1
- /* 📦 @alwatr/nanotron-api-server v9.11.2 */
1
+ /* 📦 @alwatr/nanotron-api-server v9.16.0 */
2
2
  import{createServer as N}from"node:http";import{createLogger as x}from"@alwatr/logger";import{createLogger as _}from"@alwatr/logger";import{createLogger as Z}from"@alwatr/logger";var m={GET:"GET",HEAD:"HEAD",POST:"POST",PUT:"PUT",DELETE:"DELETE",CONNECT:"CONNECT",OPTIONS:"OPTIONS",TRACE:"TRACE",PATCH:"PATCH"},U={Info_100_Continue:100,Info_101_Switching_Protocols:101,Info_102_Processing:102,Info_103_Early_Hints:103,Success_200_OK:200,Success_201_Created:201,Success_202_Accepted:202,Success_203_Non_Authoritative_Information:203,Success_204_No_Content:204,Success_205_Reset_Content:205,Success_206_Partial_Content:206,Success_207_Multi_Status:207,Success_208_Already_Reported:208,Success_226_IM_Used:226,Redirect_300_Multiple_Choices:300,Redirect_301_Moved_Permanently:301,Redirect_302_Found:302,Redirect_303_See_Other:303,Redirect_304_Not_Modified:304,Redirect_305_Use_Proxy:305,Redirect_306_Switch_Proxy:306,Redirect_307_Temporary_Redirect:307,Redirect_308_Permanent_Redirect:308,Error_Client_400_Bad_Request:400,Error_Client_401_Unauthorized:401,Error_Client_402_Payment_Required:402,Error_Client_403_Forbidden:403,Error_Client_404_Not_Found:404,Error_Client_405_Method_Not_Allowed:405,Error_Client_406_Not_Acceptable:406,Error_Client_407_Proxy_Authentication_Required:407,Error_Client_408_Request_Timeout:408,Error_Client_409_Conflict:409,Error_Client_410_Gone:410,Error_Client_411_Length_Required:411,Error_Client_412_Precondition_Failed:412,Error_Client_413_Payload_Too_Large:413,Error_Client_414_URI_Too_Long:414,Error_Client_415_Unsupported_Media_Type:415,Error_Client_416_Range_Not_Satisfiable:416,Error_Client_417_Expectation_Failed:417,Error_Client_421_Misdirected_Request:421,Error_Client_422_Unprocessable_Entity:422,Error_Client_423_Locked:423,Error_Client_424_Failed_Dependency:424,Error_Client_425_Too_Early:425,Error_Client_426_Upgrade_Required:426,Error_Client_428_Precondition_Required:428,Error_Client_429_Too_Many_Requests:429,Error_Client_431_Request_Header_Fields_Too_Large:431,Error_Client_451_Unavailable_For_Legal_Reasons:451,Error_Server_500_Internal_Server_Error:500,Error_Server_501_Not_Implemented:501,Error_Server_502_Bad_Gateway:502,Error_Server_503_Service_Unavailable:503,Error_Server_504_Gateway_Timeout:504,Error_Server_505_HTTP_Version_Not_Supported:505,Error_Server_506_Variant_Also_Negotiates:506,Error_Server_507_Insufficient_Storage:507,Error_Server_508_Loop_Detected:508,Error_Server_510_Not_Extended:510,Error_Server_511_Network_Authentication_Required:511},F={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a Teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"};class V{clientRequest;raw_;headers;logger_;hasBeenSent_=!1;get hasBeenSent(){return this.hasBeenSent_}constructor(f,$){this.clientRequest=f,this.raw_=$,this.logger_=Z(`nt-server-response(${this.clientRequest.remoteAddress})`),this.logger_.logMethodArgs?.("new",this.clientRequest.url.debugId),this.headers={server:"Alwatr Nanotron","content-type":"text/plain charset=UTF-8"};let I=this.clientRequest.routeOption?.crossOrigin;if(I?.enable===!0)this.headers["access-control-allow-origin"]=I.origin,this.headers["access-control-allow-methods"]=I.methods,this.headers["access-control-allow-headers"]=I.headers,this.headers["access-control-max-age"]=I.maxAge}get statusCode(){return this.raw_.statusCode}set statusCode(f){this.raw_.statusCode=f}applyHeaders_(){this.logger_.logMethodArgs?.("applyHeaders_",this.headers);for(let f in this.headers)this.raw_.setHeader(f,this.headers[f])}replyErrorResponse(f){this.logger_.logMethod?.("replyErrorResponse"),this.clientRequest.terminatedHandlers=!0,this.headers["content-type"]="application/json";let $="";if(f.meta!==void 0){let b=typeof f.meta;if(b==="string"||b==="number"||b==="boolean"||f.meta===null)$=`,"meta":"${f.meta}"`;else if(b==="object")$=`,"meta":${JSON.stringify(f.meta)}`}let I=`{"ok":false,"errorCode":"${f.errorCode}","errorMessage":"${f.errorMessage}"${$}}`;this.reply(I)}replyError(f){this.logger_.logMethodArgs?.("replyError",{error:f}),this.clientRequest.terminatedHandlers=!0;let $=this.statusCode;if($<U.Error_Client_400_Bad_Request)this.statusCode=$=500;if(f instanceof Error)this.replyErrorResponse({ok:!1,errorCode:f.name==="Error"?"error_"+$:(f.name+"").toLowerCase(),errorMessage:f.message});else if(typeof f==="string")this.replyErrorResponse({ok:!1,errorCode:"error_"+$,errorMessage:f});else if(typeof f==="object"&&f!==null)this.replyJson(f);else this.replyErrorResponse({ok:!1,errorCode:"error_"+$,errorMessage:F[$]})}replyJson(f){this.logger_.logMethodArgs?.("replyJson",{responseJson:f});let $;try{$=JSON.stringify(f)}catch(I){this.logger_.error("replyJson","reply_json_stringify_failed",I,this.clientRequest.url.debugId),this.statusCode=U.Error_Server_500_Internal_Server_Error,this.replyErrorResponse({ok:!1,errorCode:"reply_json_stringify_failed",errorMessage:"Failed to stringify response JSON."});return}this.headers["content-type"]="application/json",this.reply($)}reply(f){if(this.logger_.logMethodArgs?.("reply",this.clientRequest.url.debugId),this.raw_.writableFinished&&this.hasBeenSent_===!1)this.logger_.accident("reply","server_response_writable_finished_directly"),this.hasBeenSent_=!0;if(this.hasBeenSent_){this.logger_.accident("reply","reply_already_sent",{url:this.clientRequest.url.debugId,replySent:this.hasBeenSent_,writableFinished:this.raw_.writableFinished});return}this.hasBeenSent_=!0;try{if(typeof f==="string")f=Buffer.from(f);this.headers["content-length"]=f.byteLength,this.applyHeaders_(),this.raw_.end(f,"binary")}catch($){this.logger_.error("reply","server_response_error",$,this.clientRequest.url.debugId),this.hasBeenSent_=!1}}}class W{url;serverResponse;routeOption;terminatedHandlers;sharedMeta={};raw_;logger_;remoteAddress;get headers(){return this.raw_.headers}queryParams__;get queryParams(){if(this.queryParams__===void 0){this.queryParams__={};for(let[f,$]of this.url.searchParams.entries())this.queryParams__[f]=$}return this.queryParams__}constructor(f,$,I,b){this.raw_=$,this.url=f,this.routeOption=b,this.remoteAddress=this.getRemoteAddress__(),this.logger_=_(`nt-client-request(${this.remoteAddress})`),this.logger_.logMethodArgs?.("new",f.debugId),this.serverResponse=new V(this,I)}getBodyRaw(){return new Promise((f,$)=>{let I=this.url.method;if(!(I==="POST"||I==="PUT"||I==="PATCH"))return this.serverResponse.headers.connection="close",this.serverResponse.statusCode=U.Error_Client_405_Method_Not_Allowed,$(Error("body_not_allowed"));let b=+this.raw_.headers["content-length"];if(Number.isNaN(b)||b===0)return this.serverResponse.headers.connection="close",this.serverResponse.statusCode=U.Error_Client_411_Length_Required,$(Error("body_length_required"));if(b>this.routeOption.bodyLimit)return this.serverResponse.headers.connection="close",this.serverResponse.statusCode=U.Error_Client_413_Payload_Too_Large,$(Error("body_too_large"));let P=[],G=0,Q=(B)=>{if(G+=B.length,P.push(B),G>this.routeOption.bodyLimit)return this.raw_.removeListener("data",Q),this.raw_.removeListener("end",z),this.raw_.removeListener("error",z),P.length=0,this.serverResponse.headers.connection="close",this.serverResponse.statusCode=U.Error_Client_413_Payload_Too_Large,$(Error("body_too_large"))},z=(B)=>{if(this.raw_.removeListener("data",Q),this.raw_.removeListener("end",z),this.raw_.removeListener("error",z),B!==void 0)return P.length=0,this.serverResponse.statusCode=U.Error_Client_400_Bad_Request,$(B);if(G!==b)return P.length=0,this.serverResponse.statusCode=U.Error_Client_413_Payload_Too_Large,$(Error("body_too_large"));let Y=Buffer.concat(P);f(Y)};this.raw_.on("data",Q),this.raw_.on("end",z),this.raw_.on("error",z),this.raw_.resume()})}getRemoteAddress__(){return this.raw_.headers["x-forwarded-for"]?.split(",").pop()?.trim()||this.raw_.socket.remoteAddress||null}}import{URL as M}from"node:url";class K extends M{static versionPattern_=new RegExp("^/v[0-9]+/");method;debugId;constructor(f,$){let I=f.url??"";if($!=="/"&&I.indexOf($)===0)I=I.slice($.length-1);I=I.replace(K.versionPattern_,"/");super(I,"http://hostname/");this.method=(f.method??"GET").toUpperCase(),this.debugId=`[${this.method}]${this.pathname}`}}class X{static defaultConfig_={host:"0.0.0.0",port:80,requestTimeout:1e4,headersTimeout:130000,keepAliveTimeout:120000,healthRoute:!0,crossOrigin:{enable:!1,origin:"*",methods:"*",headers:"*",maxAge:86400},prefix:"/api/",bodyLimit:1048576};config_;logger_;httpServer;routeHandlerList__;constructor(f){if(this.config_={...X.defaultConfig_,...f},this.logger_=x("nt-api-server"+(this.config_.port!==80?":"+this.config_.port:"")),this.logger_.logMethodArgs?.("new",{config:this.config_}),this.handleClientRequest_=this.handleClientRequest_.bind(this),this.handleServerError_=this.handleServerError_.bind(this),this.handleClientError_=this.handleClientError_.bind(this),this.routeHandlerList__={exact:{},startsWith:{}},this.httpServer=N({keepAlive:!0,keepAliveInitialDelay:0,noDelay:!0},this.handleClientRequest_),this.httpServer.requestTimeout=this.config_.requestTimeout,this.httpServer.keepAliveTimeout=this.config_.keepAliveTimeout,this.httpServer.headersTimeout=this.config_.headersTimeout,this.httpServer.listen(this.config_.port,this.config_.host,()=>{this.logger_.logOther?.(`listening on ${this.config_.host}:${this.config_.port}`)}),this.httpServer.on("error",this.handleServerError_),this.httpServer.on("clientError",this.handleClientError_),this.defineCorsRoute_(),this.config_.healthRoute)this.defineHealthRoute_()}close(){this.logger_.logMethod?.("close"),this.httpServer.close()}getRouteOption_(f){if(this.logger_.logMethod?.("getRouteOption_"),Object.hasOwn(this.routeHandlerList__.exact,f.method)&&Object.hasOwn(this.routeHandlerList__.exact[f.method],f.pathname))return this.routeHandlerList__.exact[f.method][f.pathname];if(Object.hasOwn(this.routeHandlerList__.startsWith,f.method)){let $=this.routeHandlerList__.startsWith[f.method];for(let I in $)if(f.pathname.indexOf(I)===0)return $[I]}return this.logger_.incident?.("getRouteOption_","route_not_found",{method:f.method,url:f.pathname}),null}setRouteOption_(f){this.logger_.logMethodArgs?.("setRouteOption_",f);let $=this.routeHandlerList__[f.matchType];if($[f.method]??={},Object.hasOwn($[f.method],f.url))throw this.logger_.error("defineRoute","route_already_exists",f),Error("route_already_exists");$[f.method][f.url]=f}defineRoute(f){let $={matchType:"exact",preHandlers:[],postHandlers:[],bodyLimit:this.config_.bodyLimit,crossOrigin:this.config_.crossOrigin,...f};this.logger_.logMethodArgs?.("defineRoute",$),this.setRouteOption_($)}handleServerError_(f){if(f.code==="EADDRINUSE")this.logger_.error("handleServerError_","address_in_use",f);else this.logger_.error("handleServerError_","http_server_error",f)}handleClientError_(f,$){this.logger_.accident("handleClientError_","http_server_client_error",{errCode:f.code,errMessage:f.message});let I=f.code?.toLowerCase()??`error_${U.Error_Client_400_Bad_Request}`,b=f.message??F[U.Error_Client_400_Bad_Request],P=`{"ok":false,"errorCode":"${I}","errorMessage":"${b}"}`,G=[`HTTP/1.1 ${U.Error_Client_400_Bad_Request} ${F[U.Error_Client_400_Bad_Request]}`,"content-type: application/json",`content-length: ${Buffer.byteLength(P)}`,`\r
3
3
  `].join(`\r
4
4
  `);$.end(G+P)}async handleClientRequest_(f,$){if(this.logger_.logMethod?.("handleClientRequest_"),f.url===void 0){this.logger_.accident("handleClientRequest_","http_server_url_undefined");return}let I=new K(f,this.config_.prefix),b=this.getRouteOption_(I),P=new W(I,f,$,b);if(b===null){P.serverResponse.statusCode=U.Error_Client_404_Not_Found,P.serverResponse.replyError();return}try{for(let G of b.preHandlers)if(await G.call(P,P,P.serverResponse,P.sharedMeta),P.terminatedHandlers===!0)return;await b.handler.call(P,P,P.serverResponse,P.sharedMeta);for(let G of b.postHandlers){if(P.terminatedHandlers===!0)return;await G.call(P,P,P.serverResponse,P.sharedMeta)}}catch(G){if(this.logger_.error("handleClientRequest_","route_handler_error",G,I.debugId),P.serverResponse.statusCode<U.Error_Client_400_Bad_Request)P.serverResponse.statusCode=U.Error_Server_500_Internal_Server_Error;P.serverResponse.replyError(G)}}defineHealthRoute_(){this.logger_.logMethod?.("defineHealthRoute_"),this.defineRoute({method:"GET",url:"/health",handler:function(){let f=this.serverResponse.raw_;f.statusCode=U.Success_200_OK,f.setHeader("server","Alwatr Nanotron"),f.setHeader("content-type","application/json"),f.end('{"ok":true}')}})}defineCorsRoute_(){this.logger_.logMethod?.("defineCorsRoute_");let f=this.config_.crossOrigin;if(f?.enable!==!0)return;this.defineRoute({method:"OPTIONS",matchType:"startsWith",url:"/",handler:function(){let $=this.serverResponse.raw_;$.writeHead(U.Success_204_No_Content,{"access-control-allow-origin":f.origin,"access-control-allow-methods":f.methods,"access-control-allow-headers":f.headers,"access-control-max-age":f.maxAge+"","content-length":0}),$.end()}})}}export{X as NanotronApiServer,F as HttpStatusMessages,U as HttpStatusCodes,m as HttpMethods};
5
5
 
6
- //# debugId=1A50C713517079C164756E2164756E21
6
+ //# debugId=2FED0C993427D32164756E2164756E21
7
7
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -2,13 +2,13 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/api-server.ts", "../src/api-client-request.ts", "../src/api-server-response.ts", "../src/const.ts", "../src/url.ts"],
4
4
  "sourcesContent": [
5
- "import {createServer} from 'node:http';\n\nimport {createLogger} from '@alwatr/logger';\n\nimport {NanotronClientRequest} from './api-client-request.js';\nimport {HttpStatusCodes, HttpStatusMessages} from './const.js';\nimport {NanotronUrl} from './url.js';\n\nimport type {DefineRouteOption, MatchType, NativeClientRequest, NativeServerResponse} from './type.js';\nimport type {Duplex} from 'node:stream';\n\n/**\n * Configuration options for the NanotronApiServer.\n */\nexport interface NanotronApiServerConfig {\n /**\n * The port number to listen on.\n *\n * @default 80\n */\n port?: number;\n\n /**\n * The hostname to listen on.\n *\n * @default '0.0.0.0'\n */\n host?: string;\n\n /**\n * Sets the timeout (ms) for receiving the entire request from the client.\n *\n * @default 10_000 ms\n */\n requestTimeout?: number;\n\n /**\n * Sets the timeout (ms) for receiving the complete HTTP headers from the client.\n *\n * This should be bigger than `keepAliveTimeout + your server's expected response time`.\n *\n * @default 130_000 ms\n */\n headersTimeout?: number;\n\n /**\n * Sets the timeout (ms) for receiving the complete HTTP headers from the client.\n *\n * @default 120_000 ms\n */\n keepAliveTimeout?: number;\n\n /**\n * Add /health route.\n *\n * @default true\n */\n healthRoute?: boolean;\n\n /**\n * Add OPTIONS route for preflight requests to allow access origins.\n *\n * @default {enable: false, origin: '*', methods: '*', headers: '*', maxAge: 86_400}\n */\n crossOrigin?: {\n enable: boolean;\n origin: string;\n methods: string;\n headers: string;\n maxAge: string | number;\n };\n\n /**\n * A prefix to be added to the beginning of the `url` of all defined routes.\n *\n * @default '/api/'\n */\n prefix?: `/${string}/` | '/';\n\n /**\n * The maximum size of the request body in bytes.\n *\n * @default `1_048_576` (1MiB)\n */\n bodyLimit?: number;\n}\n\nexport class NanotronApiServer {\n protected static readonly defaultConfig_: Readonly<Required<NanotronApiServerConfig>> = {\n host: '0.0.0.0',\n port: 80,\n requestTimeout: 10_000,\n headersTimeout: 130_000,\n keepAliveTimeout: 120_000,\n healthRoute: true,\n crossOrigin: {\n enable: false,\n origin: '*',\n methods: '*',\n headers: '*',\n maxAge: 86_400, // 24h\n },\n prefix: '/api/',\n bodyLimit: 1_048_576, // 1MiB\n };\n\n public readonly config_: Required<NanotronApiServerConfig>;\n protected readonly logger_;\n\n public readonly httpServer;\n\n protected readonly routeHandlerList__: Record<MatchType, DictionaryOpt<DictionaryOpt<Required<DefineRouteOption>>>>;\n\n constructor(config?: Partial<NanotronApiServerConfig>) {\n // Merge the config with the default config.\n this.config_ = {\n ...NanotronApiServer.defaultConfig_,\n ...config,\n };\n\n // Create logger.\n this.logger_ = createLogger('nt-api-server' + (this.config_.port !== 80 ? ':' + this.config_.port : ''));\n this.logger_.logMethodArgs?.('new', {config: this.config_});\n\n // Bind methods.\n this.handleClientRequest_ = this.handleClientRequest_.bind(this);\n this.handleServerError_ = this.handleServerError_.bind(this);\n this.handleClientError_ = this.handleClientError_.bind(this);\n\n // Initialize route handler list.\n this.routeHandlerList__ = {\n exact: {},\n startsWith: {},\n };\n\n // Create the HTTP server.\n this.httpServer = createServer(\n {\n keepAlive: true,\n keepAliveInitialDelay: 0,\n noDelay: true,\n },\n this.handleClientRequest_,\n );\n\n // Configure the server.\n this.httpServer.requestTimeout = this.config_.requestTimeout;\n this.httpServer.keepAliveTimeout = this.config_.keepAliveTimeout;\n this.httpServer.headersTimeout = this.config_.headersTimeout;\n\n // Start the server.\n this.httpServer.listen(this.config_.port, this.config_.host, () => {\n this.logger_.logOther?.(`listening on ${this.config_.host}:${this.config_.port}`);\n });\n\n // Handle server errors.\n this.httpServer.on('error', this.handleServerError_);\n this.httpServer.on('clientError', this.handleClientError_);\n\n this.defineCorsRoute_();\n\n if (this.config_.healthRoute) {\n this.defineHealthRoute_();\n }\n }\n\n public close(): void {\n this.logger_.logMethod?.('close');\n this.httpServer.close();\n }\n\n protected getRouteOption_(url: NanotronUrl): Required<DefineRouteOption> | null {\n this.logger_.logMethod?.('getRouteOption_');\n\n if (\n Object.hasOwn(this.routeHandlerList__.exact, url.method) &&\n Object.hasOwn(this.routeHandlerList__.exact[url.method]!, url.pathname)\n ) {\n return this.routeHandlerList__.exact[url.method]![url.pathname]!;\n }\n\n if (Object.hasOwn(this.routeHandlerList__.startsWith, url.method)) {\n const routeList = this.routeHandlerList__.startsWith[url.method];\n for (const pathname in routeList) {\n if (url.pathname.indexOf(pathname) === 0) {\n return routeList[pathname]!;\n }\n }\n }\n\n this.logger_.incident?.('getRouteOption_', 'route_not_found', {method: url.method, url: url.pathname});\n return null;\n }\n\n protected setRouteOption_(option: Required<DefineRouteOption>): void {\n this.logger_.logMethodArgs?.('setRouteOption_', option);\n\n const routeHandlerList = this.routeHandlerList__[option.matchType];\n\n routeHandlerList[option.method] ??= {};\n\n if (Object.hasOwn(routeHandlerList[option.method]!, option.url)) {\n this.logger_.error('defineRoute', 'route_already_exists', option);\n throw new Error('route_already_exists');\n }\n\n routeHandlerList[option.method]![option.url] = option;\n }\n\n public defineRoute<TSharedMeta extends DictionaryOpt = DictionaryOpt>(option: DefineRouteOption<TSharedMeta>): void {\n const option_: Required<DefineRouteOption<TSharedMeta>> = {\n matchType: 'exact',\n preHandlers: [],\n postHandlers: [],\n bodyLimit: this.config_.bodyLimit,\n crossOrigin: this.config_.crossOrigin,\n ...option,\n };\n this.logger_.logMethodArgs?.('defineRoute', option_);\n this.setRouteOption_(option_ as Required<DefineRouteOption>);\n }\n\n protected handleServerError_(error: NodeJS.ErrnoException): void {\n if (error.code === 'EADDRINUSE') {\n this.logger_.error('handleServerError_', 'address_in_use', error);\n }\n else {\n this.logger_.error('handleServerError_', 'http_server_error', error);\n }\n }\n\n protected handleClientError_(err: NodeJS.ErrnoException, socket: Duplex): void {\n this.logger_.accident('handleClientError_', 'http_server_client_error', {\n errCode: err.code,\n errMessage: err.message,\n });\n\n const errorCode = err.code?.toLowerCase() ?? `error_${HttpStatusCodes.Error_Client_400_Bad_Request}`;\n const errorMessage = err.message ?? HttpStatusMessages[HttpStatusCodes.Error_Client_400_Bad_Request];\n const errorResponse = `{\"ok\":false,\"errorCode\":\"${errorCode}\",\"errorMessage\":\"${errorMessage}\"}`;\n\n const responseHeaders = [\n `HTTP/1.1 ${HttpStatusCodes.Error_Client_400_Bad_Request} ${HttpStatusMessages[HttpStatusCodes.Error_Client_400_Bad_Request]}`,\n 'content-type: application/json',\n `content-length: ${Buffer.byteLength(errorResponse)}`,\n '\\r\\n',\n ].join('\\r\\n');\n\n socket.end(responseHeaders + errorResponse);\n }\n\n protected async handleClientRequest_(\n nativeClientRequest: NativeClientRequest,\n nativeServerResponse: NativeServerResponse,\n ): Promise<void> {\n this.logger_.logMethod?.('handleClientRequest_');\n\n if (nativeClientRequest.url === undefined) {\n this.logger_.accident('handleClientRequest_', 'http_server_url_undefined');\n return;\n }\n\n const url = new NanotronUrl(nativeClientRequest, this.config_.prefix);\n\n const routeOption = this.getRouteOption_(url);\n\n const connection = new NanotronClientRequest(url, nativeClientRequest, nativeServerResponse, routeOption);\n\n if (routeOption === null) {\n connection.serverResponse.statusCode = HttpStatusCodes.Error_Client_404_Not_Found;\n connection.serverResponse.replyError();\n return;\n }\n\n try {\n for (const handler of routeOption.preHandlers) {\n await handler.call(connection, connection, connection.serverResponse, connection.sharedMeta);\n if (connection.terminatedHandlers === true) return; // must check after each pre-handler.\n }\n\n await routeOption.handler.call(connection, connection, connection.serverResponse, connection.sharedMeta);\n\n for (const handler of routeOption.postHandlers) {\n if (connection.terminatedHandlers === true) return; // must check before each post-handler.\n await handler.call(connection, connection, connection.serverResponse, connection.sharedMeta);\n }\n }\n catch (error) {\n this.logger_.error('handleClientRequest_', 'route_handler_error', error, url.debugId);\n\n if (connection.serverResponse.statusCode < HttpStatusCodes.Error_Client_400_Bad_Request) {\n connection.serverResponse.statusCode = HttpStatusCodes.Error_Server_500_Internal_Server_Error;\n }\n connection.serverResponse.replyError(error);\n }\n\n // TODO: handled open remained connections.\n }\n\n protected defineHealthRoute_(): void {\n this.logger_.logMethod?.('defineHealthRoute_');\n\n this.defineRoute({\n method: 'GET',\n url: '/health',\n handler: function () {\n const res = this.serverResponse.raw_;\n res.statusCode = HttpStatusCodes.Success_200_OK;\n res.setHeader('server', 'Alwatr Nanotron');\n res.setHeader('content-type', 'application/json');\n res.end('{\"ok\":true}');\n },\n });\n }\n\n protected defineCorsRoute_(): void {\n this.logger_.logMethod?.('defineCorsRoute_');\n const crossOrigin = this.config_.crossOrigin;\n if (crossOrigin?.enable !== true) return;\n this.defineRoute({\n method: 'OPTIONS',\n matchType: 'startsWith',\n url: '/',\n handler: function () {\n const res = this.serverResponse.raw_;\n res.writeHead(HttpStatusCodes.Success_204_No_Content, {\n 'access-control-allow-origin': crossOrigin.origin,\n 'access-control-allow-methods': crossOrigin.methods,\n 'access-control-allow-headers': crossOrigin.headers,\n 'access-control-max-age': crossOrigin.maxAge + '',\n 'content-length': 0,\n });\n res.end();\n },\n });\n }\n}\n",
6
- "import {createLogger} from '@alwatr/logger';\n\nimport {NanotronServerResponse} from './api-server-response.js';\nimport {HttpStatusCodes} from './const.js';\n\nimport type {DefineRouteOption, HttpRequestHeaders, NativeClientRequest, NativeServerResponse} from './type.js';\nimport type {NanotronUrl} from './url.js';\n\nexport class NanotronClientRequest<TSharedMeta extends DictionaryOpt = DictionaryOpt> {\n public readonly url: NanotronUrl;\n\n public readonly serverResponse: NanotronServerResponse;\n\n public readonly routeOption: Required<DefineRouteOption> | null;\n\n /**\n * A flag to indicate if the running handlers queue has been terminated.\n * This can occur due to an error being thrown or by explicitly calling the `replyError` method.\n *\n * When `terminatedHandlers` is set to `true`, it signifies that the execution of the current\n * sequence of handlers (including pre, main, and post handlers) has been halted and no further\n * handlers in the queue will be executed.\n *\n * Usage:\n * - Check this flag to determine if the handlers queue has been interrupted.\n * - Set this flag to `true` to manually stop the execution of subsequent handlers.\n */\n public terminatedHandlers?: true;\n\n public readonly sharedMeta: TSharedMeta = {} as TSharedMeta;\n\n public readonly raw_: NativeClientRequest;\n\n protected readonly logger_;\n\n public readonly remoteAddress: string | null;\n\n public get headers(): HttpRequestHeaders {\n return this.raw_.headers;\n }\n\n private queryParams__?: DictionaryOpt<string>;\n public get queryParams(): DictionaryOpt<string> {\n if (this.queryParams__ === undefined) {\n this.queryParams__ = {};\n for (const [key, value] of this.url.searchParams.entries()) {\n this.queryParams__[key] = value;\n }\n }\n return this.queryParams__;\n }\n\n constructor(\n url: NanotronUrl,\n nativeClientRequest: NativeClientRequest,\n nativeServerResponse: NativeServerResponse,\n routeOption: Required<DefineRouteOption> | null,\n ) {\n // Store public properties.\n this.raw_ = nativeClientRequest;\n this.url = url;\n this.routeOption = routeOption;\n\n // Get and store remote address.\n this.remoteAddress = this.getRemoteAddress__();\n\n // Create logger.\n this.logger_ = createLogger(`nt-client-request(${this.remoteAddress})`);\n this.logger_.logMethodArgs?.('new', url.debugId);\n\n // Create server response.\n this.serverResponse = new NanotronServerResponse(this, nativeServerResponse);\n }\n\n public getBodyRaw(): Promise<Buffer> {\n return new Promise((resolve, reject) => {\n // method must be POST or PUT or PATCH\n const method = this.url.method;\n if (!(method === 'POST' || method === 'PUT' || method === 'PATCH')) {\n this.serverResponse.headers.connection = 'close';\n this.serverResponse.statusCode = HttpStatusCodes.Error_Client_405_Method_Not_Allowed;\n return reject(new Error('body_not_allowed'));\n }\n\n const contentLength = +this.raw_.headers['content-length']!;\n\n if (Number.isNaN(contentLength) || contentLength === 0) {\n this.serverResponse.headers.connection = 'close';\n this.serverResponse.statusCode = HttpStatusCodes.Error_Client_411_Length_Required;\n return reject(new Error('body_length_required'));\n }\n\n if (contentLength > this.routeOption!.bodyLimit) {\n // TODO: routeOption when null?!\n this.serverResponse.headers.connection = 'close';\n this.serverResponse.statusCode = HttpStatusCodes.Error_Client_413_Payload_Too_Large;\n return reject(new Error('body_too_large'));\n }\n\n const dataChunks: Uint8Array[] = [];\n let receivedLength = 0;\n\n const onData = (chunk: Uint8Array) => {\n receivedLength += chunk.length;\n dataChunks.push(chunk);\n\n if (receivedLength > this.routeOption!.bodyLimit) {\n this.raw_.removeListener('data', onData);\n this.raw_.removeListener('end', onEnd);\n this.raw_.removeListener('error', onEnd);\n dataChunks.length = 0; // free memory\n this.serverResponse.headers.connection = 'close';\n this.serverResponse.statusCode = HttpStatusCodes.Error_Client_413_Payload_Too_Large;\n return reject(new Error('body_too_large'));\n }\n };\n\n const onEnd = (err?: Error) => {\n this.raw_.removeListener('data', onData);\n this.raw_.removeListener('end', onEnd);\n this.raw_.removeListener('error', onEnd);\n\n if (err !== undefined) {\n dataChunks.length = 0; // free memory\n this.serverResponse.statusCode = HttpStatusCodes.Error_Client_400_Bad_Request;\n return reject(err);\n }\n\n if (receivedLength !== contentLength) {\n dataChunks.length = 0; // free memory\n this.serverResponse.statusCode = HttpStatusCodes.Error_Client_413_Payload_Too_Large;\n return reject(new Error('body_too_large'));\n }\n\n const body = Buffer.concat(dataChunks);\n\n resolve(body);\n };\n\n this.raw_.on('data', onData);\n this.raw_.on('end', onEnd);\n this.raw_.on('error', onEnd);\n this.raw_.resume();\n });\n }\n\n private getRemoteAddress__(): string | null {\n return this.raw_.headers['x-forwarded-for']?.split(',').pop()?.trim() || this.raw_.socket.remoteAddress || null;\n }\n}\n",
7
- "import {createLogger} from '@alwatr/logger';\n\nimport {type HttpStatusCode, HttpStatusCodes, HttpStatusMessages} from './const.js';\n\nimport type {NanotronClientRequest} from './api-client-request.js';\nimport type {HttpResponseHeaders, ErrorResponse, NativeServerResponse} from './type.js';\n\n/**\n * Configuration options for the Nanotron Api Server Response.\n */\nexport interface NanotronServerResponseConfig {\n clientRequest: NanotronClientRequest;\n}\n\nexport class NanotronServerResponse {\n public readonly clientRequest: NanotronClientRequest;\n\n public readonly raw_: NativeServerResponse;\n\n public readonly headers: HttpResponseHeaders;\n\n protected readonly logger_;\n\n protected hasBeenSent_ = false;\n public get hasBeenSent(): boolean {\n return this.hasBeenSent_;\n }\n\n constructor(nanotronClientRequest: NanotronClientRequest, nativeServerResponse: NativeServerResponse) {\n // Store public properties.\n this.clientRequest = nanotronClientRequest;\n this.raw_ = nativeServerResponse;\n\n // Create logger.\n this.logger_ = createLogger(`nt-server-response(${this.clientRequest.remoteAddress})`);\n this.logger_.logMethodArgs?.('new', this.clientRequest.url.debugId);\n\n // Set default reply headers.\n this.headers = {\n server: 'Alwatr Nanotron',\n 'content-type': 'text/plain charset=UTF-8',\n };\n\n const crossOrigin = this.clientRequest.routeOption?.crossOrigin;\n if (crossOrigin?.enable === true) {\n this.headers['access-control-allow-origin'] = crossOrigin.origin;\n this.headers['access-control-allow-methods'] = crossOrigin.methods;\n this.headers['access-control-allow-headers'] = crossOrigin.headers;\n this.headers['access-control-max-age'] = crossOrigin.maxAge;\n }\n }\n\n public get statusCode(): HttpStatusCode {\n return this.raw_.statusCode as HttpStatusCode;\n }\n\n public set statusCode(value: HttpStatusCode) {\n this.raw_.statusCode = value;\n }\n\n protected applyHeaders_() {\n this.logger_.logMethodArgs?.('applyHeaders_', this.headers);\n for (const key in this.headers) {\n this.raw_.setHeader(key, this.headers[key as Lowercase<string>]!);\n }\n }\n\n public replyErrorResponse(errorResponse: ErrorResponse): void {\n this.logger_.logMethod?.('replyErrorResponse');\n this.clientRequest.terminatedHandlers = true;\n this.headers['content-type'] = 'application/json';\n let meta = '';\n if (errorResponse.meta !== undefined) {\n const metaType = typeof errorResponse.meta;\n if (metaType === 'string' || metaType === 'number' || metaType === 'boolean' || errorResponse.meta === null) {\n meta = `,\"meta\":\"${errorResponse.meta}\"`;\n }\n else if (metaType === 'object') {\n meta = `,\"meta\":${JSON.stringify(errorResponse.meta)}`;\n }\n }\n const responseString = `{\"ok\":false,\"errorCode\":\"${errorResponse.errorCode}\",\"errorMessage\":\"${errorResponse.errorMessage}\"${meta}}`;\n this.reply(responseString);\n }\n\n public replyError(error?: Error | string | JsonObject | unknown): void {\n this.logger_.logMethodArgs?.('replyError', {error});\n\n this.clientRequest.terminatedHandlers = true;\n let statusCode = this.statusCode;\n\n if (statusCode < HttpStatusCodes.Error_Client_400_Bad_Request) {\n this.statusCode = statusCode = 500;\n }\n\n if (error instanceof Error) {\n this.replyErrorResponse({\n ok: false,\n errorCode: (error.name === 'Error' ? 'error_' + statusCode : (error.name + '').toLowerCase()) as Lowercase<string>,\n errorMessage: error.message,\n });\n }\n else if (typeof error === 'string') {\n this.replyErrorResponse({\n ok: false,\n errorCode: ('error_' + statusCode) as Lowercase<string>,\n errorMessage: error,\n });\n }\n else if (typeof error === 'object' && error !== null) {\n this.replyJson(error as JsonObject);\n }\n else {\n this.replyErrorResponse({\n ok: false,\n errorCode: ('error_' + statusCode) as Lowercase<string>,\n errorMessage: HttpStatusMessages[statusCode],\n });\n }\n }\n\n public replyJson(responseJson: JsonObject): void {\n this.logger_.logMethodArgs?.('replyJson', {responseJson});\n\n let responseString: string;\n try {\n responseString = JSON.stringify(responseJson);\n }\n catch (error) {\n this.logger_.error('replyJson', 'reply_json_stringify_failed', error, this.clientRequest.url.debugId);\n this.statusCode = HttpStatusCodes.Error_Server_500_Internal_Server_Error;\n this.replyErrorResponse({\n ok: false,\n errorCode: 'reply_json_stringify_failed',\n errorMessage: 'Failed to stringify response JSON.',\n });\n return;\n }\n\n this.headers['content-type'] = 'application/json';\n this.reply(responseString);\n }\n\n public reply(context: string | Buffer): void {\n this.logger_.logMethodArgs?.('reply', this.clientRequest.url.debugId);\n\n if (this.raw_.writableFinished && this.hasBeenSent_ === false) {\n // The response has already been sent by direct access to the server api.\n this.logger_.accident('reply', 'server_response_writable_finished_directly');\n this.hasBeenSent_ = true;\n }\n\n if (this.hasBeenSent_) {\n this.logger_.accident('reply', 'reply_already_sent', {\n url: this.clientRequest.url.debugId,\n replySent: this.hasBeenSent_,\n writableFinished: this.raw_.writableFinished,\n });\n return;\n }\n\n this.hasBeenSent_ = true;\n\n try {\n if (typeof context === 'string') {\n context = Buffer.from(context);\n }\n\n this.headers['content-length'] = context.byteLength;\n\n this.applyHeaders_();\n this.raw_.end(context, 'binary');\n }\n catch (error) {\n this.logger_.error('reply', 'server_response_error', error, this.clientRequest.url.debugId);\n this.hasBeenSent_ = false;\n }\n }\n}\n",
5
+ "import {createServer} from 'node:http';\n\nimport {createLogger} from '@alwatr/logger';\n\nimport {NanotronClientRequest} from './api-client-request.js';\nimport {HttpStatusCodes, HttpStatusMessages} from './const.js';\nimport {NanotronUrl} from './url.js';\n\nimport type {DefineRouteOption, MatchType, NativeClientRequest, NativeServerResponse} from './type.js';\nimport type {Duplex} from 'node:stream';\nimport type {DictionaryOpt} from '@alwatr/type-helper';\n\n/**\n * Configuration options for the NanotronApiServer.\n */\nexport interface NanotronApiServerConfig {\n /**\n * The port number to listen on.\n *\n * @default 80\n */\n port?: number;\n\n /**\n * The hostname to listen on.\n *\n * @default '0.0.0.0'\n */\n host?: string;\n\n /**\n * Sets the timeout (ms) for receiving the entire request from the client.\n *\n * @default 10_000 ms\n */\n requestTimeout?: number;\n\n /**\n * Sets the timeout (ms) for receiving the complete HTTP headers from the client.\n *\n * This should be bigger than `keepAliveTimeout + your server's expected response time`.\n *\n * @default 130_000 ms\n */\n headersTimeout?: number;\n\n /**\n * Sets the timeout (ms) for receiving the complete HTTP headers from the client.\n *\n * @default 120_000 ms\n */\n keepAliveTimeout?: number;\n\n /**\n * Add /health route.\n *\n * @default true\n */\n healthRoute?: boolean;\n\n /**\n * Add OPTIONS route for preflight requests to allow access origins.\n *\n * @default {enable: false, origin: '*', methods: '*', headers: '*', maxAge: 86_400}\n */\n crossOrigin?: {\n enable: boolean;\n origin: string;\n methods: string;\n headers: string;\n maxAge: string | number;\n };\n\n /**\n * A prefix to be added to the beginning of the `url` of all defined routes.\n *\n * @default '/api/'\n */\n prefix?: `/${string}/` | '/';\n\n /**\n * The maximum size of the request body in bytes.\n *\n * @default `1_048_576` (1MiB)\n */\n bodyLimit?: number;\n}\n\nexport class NanotronApiServer {\n protected static readonly defaultConfig_: Readonly<Required<NanotronApiServerConfig>> = {\n host: '0.0.0.0',\n port: 80,\n requestTimeout: 10_000,\n headersTimeout: 130_000,\n keepAliveTimeout: 120_000,\n healthRoute: true,\n crossOrigin: {\n enable: false,\n origin: '*',\n methods: '*',\n headers: '*',\n maxAge: 86_400, // 24h\n },\n prefix: '/api/',\n bodyLimit: 1_048_576, // 1MiB\n };\n\n public readonly config_: Required<NanotronApiServerConfig>;\n protected readonly logger_;\n\n public readonly httpServer;\n\n protected readonly routeHandlerList__: Record<MatchType, DictionaryOpt<DictionaryOpt<Required<DefineRouteOption>>>>;\n\n constructor(config?: Partial<NanotronApiServerConfig>) {\n // Merge the config with the default config.\n this.config_ = {\n ...NanotronApiServer.defaultConfig_,\n ...config,\n };\n\n // Create logger.\n this.logger_ = createLogger('nt-api-server' + (this.config_.port !== 80 ? ':' + this.config_.port : ''));\n this.logger_.logMethodArgs?.('new', {config: this.config_});\n\n // Bind methods.\n this.handleClientRequest_ = this.handleClientRequest_.bind(this);\n this.handleServerError_ = this.handleServerError_.bind(this);\n this.handleClientError_ = this.handleClientError_.bind(this);\n\n // Initialize route handler list.\n this.routeHandlerList__ = {\n exact: {},\n startsWith: {},\n };\n\n // Create the HTTP server.\n this.httpServer = createServer(\n {\n keepAlive: true,\n keepAliveInitialDelay: 0,\n noDelay: true,\n },\n this.handleClientRequest_,\n );\n\n // Configure the server.\n this.httpServer.requestTimeout = this.config_.requestTimeout;\n this.httpServer.keepAliveTimeout = this.config_.keepAliveTimeout;\n this.httpServer.headersTimeout = this.config_.headersTimeout;\n\n // Start the server.\n this.httpServer.listen(this.config_.port, this.config_.host, () => {\n this.logger_.logOther?.(`listening on ${this.config_.host}:${this.config_.port}`);\n });\n\n // Handle server errors.\n this.httpServer.on('error', this.handleServerError_);\n this.httpServer.on('clientError', this.handleClientError_);\n\n this.defineCorsRoute_();\n\n if (this.config_.healthRoute) {\n this.defineHealthRoute_();\n }\n }\n\n public close(): void {\n this.logger_.logMethod?.('close');\n this.httpServer.close();\n }\n\n protected getRouteOption_(url: NanotronUrl): Required<DefineRouteOption> | null {\n this.logger_.logMethod?.('getRouteOption_');\n\n if (\n Object.hasOwn(this.routeHandlerList__.exact, url.method)\n && Object.hasOwn(this.routeHandlerList__.exact[url.method]!, url.pathname)\n ) {\n return this.routeHandlerList__.exact[url.method]![url.pathname]!;\n }\n\n if (Object.hasOwn(this.routeHandlerList__.startsWith, url.method)) {\n const routeList = this.routeHandlerList__.startsWith[url.method];\n for (const pathname in routeList) {\n if (url.pathname.indexOf(pathname) === 0) {\n return routeList[pathname]!;\n }\n }\n }\n\n this.logger_.incident?.('getRouteOption_', 'route_not_found', {method: url.method, url: url.pathname});\n return null;\n }\n\n protected setRouteOption_(option: Required<DefineRouteOption>): void {\n this.logger_.logMethodArgs?.('setRouteOption_', option);\n\n const routeHandlerList = this.routeHandlerList__[option.matchType];\n\n routeHandlerList[option.method] ??= {};\n\n if (Object.hasOwn(routeHandlerList[option.method]!, option.url)) {\n this.logger_.error('defineRoute', 'route_already_exists', option);\n throw new Error('route_already_exists');\n }\n\n routeHandlerList[option.method]![option.url] = option;\n }\n\n public defineRoute<TSharedMeta extends DictionaryOpt<any> = DictionaryOpt<any>>(\n option: DefineRouteOption<TSharedMeta>,\n ): void {\n const option_: Required<DefineRouteOption<TSharedMeta>> = {\n matchType: 'exact',\n preHandlers: [],\n postHandlers: [],\n bodyLimit: this.config_.bodyLimit,\n crossOrigin: this.config_.crossOrigin,\n ...option,\n };\n this.logger_.logMethodArgs?.('defineRoute', option_);\n this.setRouteOption_(option_ as Required<DefineRouteOption>);\n }\n\n protected handleServerError_(error: NodeJS.ErrnoException): void {\n if (error.code === 'EADDRINUSE') {\n this.logger_.error('handleServerError_', 'address_in_use', error);\n } else {\n this.logger_.error('handleServerError_', 'http_server_error', error);\n }\n }\n\n protected handleClientError_(err: NodeJS.ErrnoException, socket: Duplex): void {\n this.logger_.accident('handleClientError_', 'http_server_client_error', {\n errCode: err.code,\n errMessage: err.message,\n });\n\n const errorCode = err.code?.toLowerCase() ?? `error_${HttpStatusCodes.Error_Client_400_Bad_Request}`;\n const errorMessage = err.message ?? HttpStatusMessages[HttpStatusCodes.Error_Client_400_Bad_Request];\n const errorResponse = `{\"ok\":false,\"errorCode\":\"${errorCode}\",\"errorMessage\":\"${errorMessage}\"}`;\n\n const responseHeaders = [\n `HTTP/1.1 ${HttpStatusCodes.Error_Client_400_Bad_Request} ${HttpStatusMessages[HttpStatusCodes.Error_Client_400_Bad_Request]}`,\n 'content-type: application/json',\n `content-length: ${Buffer.byteLength(errorResponse)}`,\n '\\r\\n',\n ].join('\\r\\n');\n\n socket.end(responseHeaders + errorResponse);\n }\n\n protected async handleClientRequest_(\n nativeClientRequest: NativeClientRequest,\n nativeServerResponse: NativeServerResponse,\n ): Promise<void> {\n this.logger_.logMethod?.('handleClientRequest_');\n\n if (nativeClientRequest.url === undefined) {\n this.logger_.accident('handleClientRequest_', 'http_server_url_undefined');\n return;\n }\n\n const url = new NanotronUrl(nativeClientRequest, this.config_.prefix);\n\n const routeOption = this.getRouteOption_(url);\n\n const connection = new NanotronClientRequest(url, nativeClientRequest, nativeServerResponse, routeOption);\n\n if (routeOption === null) {\n connection.serverResponse.statusCode = HttpStatusCodes.Error_Client_404_Not_Found;\n connection.serverResponse.replyError();\n return;\n }\n\n try {\n for (const handler of routeOption.preHandlers) {\n await handler.call(connection, connection, connection.serverResponse, connection.sharedMeta);\n if (connection.terminatedHandlers === true) return; // must check after each pre-handler.\n }\n\n await routeOption.handler.call(connection, connection, connection.serverResponse, connection.sharedMeta);\n\n for (const handler of routeOption.postHandlers) {\n if (connection.terminatedHandlers === true) return; // must check before each post-handler.\n await handler.call(connection, connection, connection.serverResponse, connection.sharedMeta);\n }\n } catch (error) {\n this.logger_.error('handleClientRequest_', 'route_handler_error', error, url.debugId);\n\n if (connection.serverResponse.statusCode < HttpStatusCodes.Error_Client_400_Bad_Request) {\n connection.serverResponse.statusCode = HttpStatusCodes.Error_Server_500_Internal_Server_Error;\n }\n connection.serverResponse.replyError(error);\n }\n\n // TODO: handled open remained connections.\n }\n\n protected defineHealthRoute_(): void {\n this.logger_.logMethod?.('defineHealthRoute_');\n\n this.defineRoute({\n method: 'GET',\n url: '/health',\n handler: function () {\n const res = this.serverResponse.raw_;\n res.statusCode = HttpStatusCodes.Success_200_OK;\n res.setHeader('server', 'Alwatr Nanotron');\n res.setHeader('content-type', 'application/json');\n res.end('{\"ok\":true}');\n },\n });\n }\n\n protected defineCorsRoute_(): void {\n this.logger_.logMethod?.('defineCorsRoute_');\n const crossOrigin = this.config_.crossOrigin;\n if (crossOrigin?.enable !== true) return;\n this.defineRoute({\n method: 'OPTIONS',\n matchType: 'startsWith',\n url: '/',\n handler: function () {\n const res = this.serverResponse.raw_;\n res.writeHead(HttpStatusCodes.Success_204_No_Content, {\n 'access-control-allow-origin': crossOrigin.origin,\n 'access-control-allow-methods': crossOrigin.methods,\n 'access-control-allow-headers': crossOrigin.headers,\n 'access-control-max-age': crossOrigin.maxAge + '',\n 'content-length': 0,\n });\n res.end();\n },\n });\n }\n}\n",
6
+ "import {createLogger} from '@alwatr/logger';\n\nimport {NanotronServerResponse} from './api-server-response.js';\nimport {HttpStatusCodes} from './const.js';\n\nimport type {DefineRouteOption, HttpRequestHeaders, NativeClientRequest, NativeServerResponse} from './type.js';\nimport type {NanotronUrl} from './url.js';\nimport type {DictionaryOpt} from '@alwatr/type-helper';\n\nexport class NanotronClientRequest<TSharedMeta extends DictionaryOpt<any> = DictionaryOpt<any>> {\n public readonly url: NanotronUrl;\n\n public readonly serverResponse: NanotronServerResponse;\n\n public readonly routeOption: Required<DefineRouteOption> | null;\n\n /**\n * A flag to indicate if the running handlers queue has been terminated.\n * This can occur due to an error being thrown or by explicitly calling the `replyError` method.\n *\n * When `terminatedHandlers` is set to `true`, it signifies that the execution of the current\n * sequence of handlers (including pre, main, and post handlers) has been halted and no further\n * handlers in the queue will be executed.\n *\n * Usage:\n * - Check this flag to determine if the handlers queue has been interrupted.\n * - Set this flag to `true` to manually stop the execution of subsequent handlers.\n */\n public terminatedHandlers?: true;\n\n public readonly sharedMeta: TSharedMeta = {} as TSharedMeta;\n\n public readonly raw_: NativeClientRequest;\n\n protected readonly logger_;\n\n public readonly remoteAddress: string | null;\n\n public get headers(): HttpRequestHeaders {\n return this.raw_.headers;\n }\n\n private queryParams__?: DictionaryOpt<string>;\n public get queryParams(): DictionaryOpt<string> {\n if (this.queryParams__ === undefined) {\n this.queryParams__ = {};\n for (const [key, value] of this.url.searchParams.entries()) {\n this.queryParams__[key] = value;\n }\n }\n return this.queryParams__;\n }\n\n constructor(\n url: NanotronUrl,\n nativeClientRequest: NativeClientRequest,\n nativeServerResponse: NativeServerResponse,\n routeOption: Required<DefineRouteOption> | null,\n ) {\n // Store public properties.\n this.raw_ = nativeClientRequest;\n this.url = url;\n this.routeOption = routeOption;\n\n // Get and store remote address.\n this.remoteAddress = this.getRemoteAddress__();\n\n // Create logger.\n this.logger_ = createLogger(`nt-client-request(${this.remoteAddress})`);\n this.logger_.logMethodArgs?.('new', url.debugId);\n\n // Create server response.\n this.serverResponse = new NanotronServerResponse(this, nativeServerResponse);\n }\n\n public getBodyRaw(): Promise<Buffer> {\n return new Promise((resolve, reject) => {\n // method must be POST or PUT or PATCH\n const method = this.url.method;\n if (!(method === 'POST' || method === 'PUT' || method === 'PATCH')) {\n this.serverResponse.headers.connection = 'close';\n this.serverResponse.statusCode = HttpStatusCodes.Error_Client_405_Method_Not_Allowed;\n return reject(new Error('body_not_allowed'));\n }\n\n const contentLength = +this.raw_.headers['content-length']!;\n\n if (Number.isNaN(contentLength) || contentLength === 0) {\n this.serverResponse.headers.connection = 'close';\n this.serverResponse.statusCode = HttpStatusCodes.Error_Client_411_Length_Required;\n return reject(new Error('body_length_required'));\n }\n\n if (contentLength > this.routeOption!.bodyLimit) {\n // TODO: routeOption when null?!\n this.serverResponse.headers.connection = 'close';\n this.serverResponse.statusCode = HttpStatusCodes.Error_Client_413_Payload_Too_Large;\n return reject(new Error('body_too_large'));\n }\n\n const dataChunks: Uint8Array[] = [];\n let receivedLength = 0;\n\n const onData = (chunk: Uint8Array) => {\n receivedLength += chunk.length;\n dataChunks.push(chunk);\n\n if (receivedLength > this.routeOption!.bodyLimit) {\n this.raw_.removeListener('data', onData);\n this.raw_.removeListener('end', onEnd);\n this.raw_.removeListener('error', onEnd);\n dataChunks.length = 0; // free memory\n this.serverResponse.headers.connection = 'close';\n this.serverResponse.statusCode = HttpStatusCodes.Error_Client_413_Payload_Too_Large;\n return reject(new Error('body_too_large'));\n }\n };\n\n const onEnd = (err?: Error) => {\n this.raw_.removeListener('data', onData);\n this.raw_.removeListener('end', onEnd);\n this.raw_.removeListener('error', onEnd);\n\n if (err !== undefined) {\n dataChunks.length = 0; // free memory\n this.serverResponse.statusCode = HttpStatusCodes.Error_Client_400_Bad_Request;\n return reject(err);\n }\n\n if (receivedLength !== contentLength) {\n dataChunks.length = 0; // free memory\n this.serverResponse.statusCode = HttpStatusCodes.Error_Client_413_Payload_Too_Large;\n return reject(new Error('body_too_large'));\n }\n\n const body = Buffer.concat(dataChunks);\n\n resolve(body);\n };\n\n this.raw_.on('data', onData);\n this.raw_.on('end', onEnd);\n this.raw_.on('error', onEnd);\n this.raw_.resume();\n });\n }\n\n private getRemoteAddress__(): string | null {\n return this.raw_.headers['x-forwarded-for']?.split(',').pop()?.trim() || this.raw_.socket.remoteAddress || null;\n }\n}\n",
7
+ "import {createLogger} from '@alwatr/logger';\n\nimport {type HttpStatusCode, HttpStatusCodes, HttpStatusMessages} from './const.js';\n\nimport type {NanotronClientRequest} from './api-client-request.js';\nimport type {HttpResponseHeaders, ErrorResponse, NativeServerResponse} from './type.js';\nimport type {JsonObject} from '@alwatr/type-helper';\n\n/**\n * Configuration options for the Nanotron Api Server Response.\n */\nexport interface NanotronServerResponseConfig {\n clientRequest: NanotronClientRequest;\n}\n\nexport class NanotronServerResponse {\n public readonly clientRequest: NanotronClientRequest;\n\n public readonly raw_: NativeServerResponse;\n\n public readonly headers: HttpResponseHeaders;\n\n protected readonly logger_;\n\n protected hasBeenSent_ = false;\n public get hasBeenSent(): boolean {\n return this.hasBeenSent_;\n }\n\n constructor(nanotronClientRequest: NanotronClientRequest, nativeServerResponse: NativeServerResponse) {\n // Store public properties.\n this.clientRequest = nanotronClientRequest;\n this.raw_ = nativeServerResponse;\n\n // Create logger.\n this.logger_ = createLogger(`nt-server-response(${this.clientRequest.remoteAddress})`);\n this.logger_.logMethodArgs?.('new', this.clientRequest.url.debugId);\n\n // Set default reply headers.\n this.headers = {\n 'server': 'Alwatr Nanotron',\n 'content-type': 'text/plain charset=UTF-8',\n };\n\n const crossOrigin = this.clientRequest.routeOption?.crossOrigin;\n if (crossOrigin?.enable === true) {\n this.headers['access-control-allow-origin'] = crossOrigin.origin;\n this.headers['access-control-allow-methods'] = crossOrigin.methods;\n this.headers['access-control-allow-headers'] = crossOrigin.headers;\n this.headers['access-control-max-age'] = crossOrigin.maxAge;\n }\n }\n\n public get statusCode(): HttpStatusCode {\n return this.raw_.statusCode as HttpStatusCode;\n }\n\n public set statusCode(value: HttpStatusCode) {\n this.raw_.statusCode = value;\n }\n\n protected applyHeaders_() {\n this.logger_.logMethodArgs?.('applyHeaders_', this.headers);\n for (const key in this.headers) {\n this.raw_.setHeader(key, this.headers[key as Lowercase<string>]!);\n }\n }\n\n public replyErrorResponse(errorResponse: ErrorResponse): void {\n this.logger_.logMethod?.('replyErrorResponse');\n this.clientRequest.terminatedHandlers = true;\n this.headers['content-type'] = 'application/json';\n let meta = '';\n if (errorResponse.meta !== undefined) {\n const metaType = typeof errorResponse.meta;\n if (metaType === 'string' || metaType === 'number' || metaType === 'boolean' || errorResponse.meta === null) {\n meta = `,\"meta\":\"${errorResponse.meta}\"`;\n } else if (metaType === 'object') {\n meta = `,\"meta\":${JSON.stringify(errorResponse.meta)}`;\n }\n }\n const responseString = `{\"ok\":false,\"errorCode\":\"${errorResponse.errorCode}\",\"errorMessage\":\"${errorResponse.errorMessage}\"${meta}}`;\n this.reply(responseString);\n }\n\n public replyError(error?: Error | string | JsonObject | unknown): void {\n this.logger_.logMethodArgs?.('replyError', {error});\n\n this.clientRequest.terminatedHandlers = true;\n let statusCode = this.statusCode;\n\n if (statusCode < HttpStatusCodes.Error_Client_400_Bad_Request) {\n this.statusCode = statusCode = 500;\n }\n\n if (error instanceof Error) {\n this.replyErrorResponse({\n ok: false,\n errorCode: (error.name === 'Error' ?\n 'error_' + statusCode\n : (error.name + '').toLowerCase()) as Lowercase<string>,\n errorMessage: error.message,\n });\n } else if (typeof error === 'string') {\n this.replyErrorResponse({\n ok: false,\n errorCode: ('error_' + statusCode) as Lowercase<string>,\n errorMessage: error,\n });\n } else if (typeof error === 'object' && error !== null) {\n this.replyJson(error as JsonObject);\n } else {\n this.replyErrorResponse({\n ok: false,\n errorCode: ('error_' + statusCode) as Lowercase<string>,\n errorMessage: HttpStatusMessages[statusCode],\n });\n }\n }\n\n public replyJson(responseJson: JsonObject): void {\n this.logger_.logMethodArgs?.('replyJson', {responseJson});\n\n let responseString: string;\n try {\n responseString = JSON.stringify(responseJson);\n } catch (error) {\n this.logger_.error('replyJson', 'reply_json_stringify_failed', error, this.clientRequest.url.debugId);\n this.statusCode = HttpStatusCodes.Error_Server_500_Internal_Server_Error;\n this.replyErrorResponse({\n ok: false,\n errorCode: 'reply_json_stringify_failed',\n errorMessage: 'Failed to stringify response JSON.',\n });\n return;\n }\n\n this.headers['content-type'] = 'application/json';\n this.reply(responseString);\n }\n\n public reply(context: string | Buffer): void {\n this.logger_.logMethodArgs?.('reply', this.clientRequest.url.debugId);\n\n if (this.raw_.writableFinished && this.hasBeenSent_ === false) {\n // The response has already been sent by direct access to the server api.\n this.logger_.accident('reply', 'server_response_writable_finished_directly');\n this.hasBeenSent_ = true;\n }\n\n if (this.hasBeenSent_) {\n this.logger_.accident('reply', 'reply_already_sent', {\n url: this.clientRequest.url.debugId,\n replySent: this.hasBeenSent_,\n writableFinished: this.raw_.writableFinished,\n });\n return;\n }\n\n this.hasBeenSent_ = true;\n\n try {\n if (typeof context === 'string') {\n context = Buffer.from(context);\n }\n\n this.headers['content-length'] = context.byteLength;\n\n this.applyHeaders_();\n this.raw_.end(context, 'binary');\n } catch (error) {\n this.logger_.error('reply', 'server_response_error', error, this.clientRequest.url.debugId);\n this.hasBeenSent_ = false;\n }\n }\n}\n",
8
8
  "/**\n * Object representing standard HTTP methods.\n */\nexport const HttpMethods = {\n /**\n * GET: Requests a representation of the specified resource.\n */\n GET: 'GET',\n\n /**\n * HEAD: Asks for a response identical to that of a GET request, but without the response body.\n */\n HEAD: 'HEAD',\n\n /**\n * POST: Submits data to be processed (e.g., from an HTML form) to the identified resource.\n */\n POST: 'POST',\n\n /**\n * PUT: Uploads a representation of the specified URI.\n */\n PUT: 'PUT',\n\n /**\n * DELETE: Deletes the specified resource.\n */\n DELETE: 'DELETE',\n\n /**\n * CONNECT: Establishes a tunnel to the server identified by the target resource.\n */\n CONNECT: 'CONNECT',\n\n /**\n * OPTIONS: Describes the communication options for the target resource.\n */\n OPTIONS: 'OPTIONS',\n\n /**\n * TRACE: Performs a message loop-back test along the path to the target resource.\n */\n TRACE: 'TRACE',\n\n /**\n * PATCH: Applies partial modifications to a resource.\n */\n PATCH: 'PATCH',\n} as const;\n\n/**\n * Object representing standard HTTP status codes.\n */\nexport const HttpStatusCodes = {\n /**\n * 100 Continue: The server has received the request headers and the client should proceed to send the request body.\n */\n Info_100_Continue: 100,\n\n /**\n * 101 Switching Protocols: The server understands and is willing to comply with the clients request to switch protocols.\n */\n Info_101_Switching_Protocols: 101,\n\n /**\n * 102 Processing: The server has received and is processing the request, but no response is available yet.\n */\n Info_102_Processing: 102,\n\n /**\n * 103 Early Hints: The server is sending some response headers before the final HTTP message.\n */\n Info_103_Early_Hints: 103,\n\n /**\n * 200 OK: The request has succeeded.\n */\n Success_200_OK: 200,\n\n /**\n * 201 Created: The request has been fulfilled and resulted in a new resource being created.\n */\n Success_201_Created: 201,\n\n /**\n * 202 Accepted: The request has been accepted for processing, but the processing has not been completed.\n */\n Success_202_Accepted: 202,\n\n /**\n * 203 Non-Authoritative Information: The server is a transforming proxy that received a 200 OK\n * from the origin server but is returning a modified version of the origins response.\n */\n Success_203_Non_Authoritative_Information: 203,\n\n /**\n * 204 No Content: The server successfully processed the request and is not returning any content.\n */\n Success_204_No_Content: 204,\n\n /**\n * 205 Reset Content: The server successfully processed the request,\n * asks that the client reset its document view, and is not returning any content.\n */\n Success_205_Reset_Content: 205,\n\n /**\n * 206 Partial Content: The server is delivering only part of the resource due to a range header sent by the client.\n */\n Success_206_Partial_Content: 206,\n\n /**\n * 207 Multi-Status: The message body that follows is an XML message\n * and can contain a number of separate response codes, depending on how many sub-requests were made.\n */\n Success_207_Multi_Status: 207,\n\n /**\n * 208 Already Reported: The members of a DAV binding have already been enumerated\n * in a preceding part of the (multi-status) response, and are not being included again.\n */\n Success_208_Already_Reported: 208,\n\n /**\n * 226 IM Used: The server has fulfilled a request for the resource, and the response is a representation\n * of the result of one or more instance-manipulations applied to the current instance.\n */\n Success_226_IM_Used: 226,\n\n /**\n * 300 Multiple Choices: The request has more than one possible response.\n */\n Redirect_300_Multiple_Choices: 300,\n\n /**\n * 301 Moved Permanently: The URL of the requested resource has been changed permanently.\n */\n Redirect_301_Moved_Permanently: 301,\n\n /**\n * 302 Found: The URL of the requested resource has been changed temporarily.\n */\n Redirect_302_Found: 302,\n\n /**\n * 303 See Other: The response to the request can be found under another URI using a GET method.\n */\n Redirect_303_See_Other: 303,\n\n /**\n * 304 Not Modified: The resource has not been modified since the version specified\n * by the request headers If-Modified-Since or If-None-Match.\n */\n Redirect_304_Not_Modified: 304,\n\n /**\n * 305 Use Proxy: The requested resource is only available through a proxy, the address for which is provided in the response.\n */\n Redirect_305_Use_Proxy: 305,\n\n /**\n * 306 Switch Proxy: No longer used. Originally meant \"Subsequent requests should use the specified proxy.\"\n */\n Redirect_306_Switch_Proxy: 306,\n\n /**\n * 307 Temporary Redirect: The server sends this response to direct the client\n * to get the requested resource at another URI with the same method that was used in the prior request.\n */\n Redirect_307_Temporary_Redirect: 307,\n\n /**\n * 308 Permanent Redirect: This means that the resource is now permanently located at another URI,\n * specified by the Location: HTTP Response header.\n */\n Redirect_308_Permanent_Redirect: 308,\n\n /**\n * 400 Bad Request: The server cannot or will not process the request due to something that is perceived to be a client error.\n */\n Error_Client_400_Bad_Request: 400,\n\n /**\n * 401 Unauthorized: The request has not been applied because it lacks valid authentication credentials for the target resource.\n */\n Error_Client_401_Unauthorized: 401,\n\n /**\n * 402 Payment Required: Reserved for future use.\n */\n Error_Client_402_Payment_Required: 402,\n\n /**\n * 403 Forbidden: The client does not have access rights to the content, so the server is refusing to give the requested resource.\n */\n Error_Client_403_Forbidden: 403,\n\n /**\n * 404 Not Found: The server can not find the requested resource.\n */\n Error_Client_404_Not_Found: 404,\n\n /**\n * 405 Method Not Allowed: The request method is known by the server but is not supported by the target resource.\n */\n Error_Client_405_Method_Not_Allowed: 405,\n\n /**\n * 406 Not Acceptable: The target resource does not have a current representation that would be acceptable\n * to the user agent, according to the proactive negotiation header fields received in the request,\n * and the server is unwilling to supply a default representation.\n */\n Error_Client_406_Not_Acceptable: 406,\n\n /**\n * 407 Proxy Authentication Required: Similar to 401 Unauthorized,\n * but it indicates that the client needs to authenticate itself in order to use a proxy.\n */\n Error_Client_407_Proxy_Authentication_Required: 407,\n\n /**\n * 408 Request Timeout: The server timed out waiting for the request.\n */\n Error_Client_408_Request_Timeout: 408,\n\n /**\n * 409 Conflict: The request could not be processed because of conflict in the request, such as an edit conflict.\n */\n Error_Client_409_Conflict: 409,\n\n /**\n * 410 Gone: The requested resource is no longer available and will not be available again.\n */\n Error_Client_410_Gone: 410,\n\n /**\n * 411 Length Required: The server refuses to accept the request without a defined Content-Length header.\n */\n Error_Client_411_Length_Required: 411,\n\n /**\n * 412 Precondition Failed: One or more conditions given in the request header fields evaluated to false when tested on the server.\n */\n Error_Client_412_Precondition_Failed: 412,\n\n /**\n * 413 Payload Too Large: The server is refusing to process a request because the request payload is larger\n * than the server is willing or able to process.\n */\n Error_Client_413_Payload_Too_Large: 413,\n\n /**\n * 414 URI Too Long: The server is refusing to service the request because the URI is longer than the server is willing to interpret.\n */\n Error_Client_414_URI_Too_Long: 414,\n\n /**\n * 415 Unsupported Media Type: The server is refusing to service the request\n * because the entity of the request is in a format not supported by the requested resource for the requested method.\n */\n Error_Client_415_Unsupported_Media_Type: 415,\n\n /**\n * 416 Range Not Satisfiable: The client has asked for a portion of the file, but the server cannot supply that portion.\n */\n Error_Client_416_Range_Not_Satisfiable: 416,\n\n /**\n * 417 Expectation Failed: The server cannot meet the requirements of the Expect request-header field.\n */\n Error_Client_417_Expectation_Failed: 417,\n\n /**\n * 421 Misdirected Request: The request was directed at a server that is not able to produce a response.\n */\n Error_Client_421_Misdirected_Request: 421,\n\n /**\n * 422 Unprocessable Entity: The request was well-formed but was unable to be followed due to semantic errors.\n */\n Error_Client_422_Unprocessable_Entity: 422,\n\n /**\n * 423 Locked: The resource that is being accessed is locked.\n */\n Error_Client_423_Locked: 423,\n\n /**\n * 424 Failed Dependency: The request failed due to a failure of a previous request.\n */\n Error_Client_424_Failed_Dependency: 424,\n\n /**\n * 425 Too Early: The server is unwilling to risk processing a request that might be replayed.\n */\n Error_Client_425_Too_Early: 425,\n\n /**\n * 426 Upgrade Required: The server refuses to perform the request using the current protocol\n * but might be willing to do so after the client upgrades to a different protocol.\n */\n Error_Client_426_Upgrade_Required: 426,\n\n /**\n * 428 Precondition Required: The origin server requires the request to be conditional.\n */\n Error_Client_428_Precondition_Required: 428,\n\n /**\n * 429 Too Many Requests: The user has sent too many requests in a given amount of time (\"rate limiting\").\n */\n Error_Client_429_Too_Many_Requests: 429,\n\n /**\n * 431 Request Header Fields Too Large: The server is unwilling to process the request because its header fields are too large.\n */\n Error_Client_431_Request_Header_Fields_Too_Large: 431,\n\n /**\n * 451 Unavailable For Legal Reasons: The user requests an illegal resource, such as a web page censored by a government.\n */\n Error_Client_451_Unavailable_For_Legal_Reasons: 451,\n\n /**\n * 500 Internal Server Error: A generic error message, given when no more specific message is suitable.\n */\n Error_Server_500_Internal_Server_Error: 500,\n\n /**\n * 501 Not Implemented: The server either does not recognize the request method, or it lacks the ability to fulfill the request.\n */\n Error_Server_501_Not_Implemented: 501,\n\n /**\n * 502 Bad Gateway: The server was acting as a gateway or proxy and received an invalid response from the upstream server.\n */\n Error_Server_502_Bad_Gateway: 502,\n\n /**\n * 503 Service Unavailable: The server is currently unavailable (because it is overloaded or down for maintenance).\n */\n Error_Server_503_Service_Unavailable: 503,\n\n /**\n * 504 Gateway Timeout: The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.\n */\n Error_Server_504_Gateway_Timeout: 504,\n\n /**\n * 505 HTTP Version Not Supported: The server does not support the HTTP protocol version used in the request.\n */\n Error_Server_505_HTTP_Version_Not_Supported: 505,\n\n /**\n * 506 Variant Also Negotiates: Transparent content negotiation for the request results in a circular reference.\n */\n Error_Server_506_Variant_Also_Negotiates: 506,\n\n /**\n * 507 Insufficient Storage: The server is unable to store the representation needed to complete the request.\n */\n Error_Server_507_Insufficient_Storage: 507,\n\n /**\n * 508 Loop Detected: The server detected an infinite loop while processing the request.\n */\n Error_Server_508_Loop_Detected: 508,\n\n /**\n * 510 Not Extended: Further extensions to the request are required for the server to fulfill it.\n */\n Error_Server_510_Not_Extended: 510,\n\n /**\n * 511 Network Authentication Required: The client needs to authenticate to gain network access.\n */\n Error_Server_511_Network_Authentication_Required: 511,\n} as const;\n\nexport const HttpStatusMessages = {\n 100: 'Continue',\n 101: 'Switching Protocols',\n 102: 'Processing',\n 103: 'Early Hints',\n 200: 'OK',\n 201: 'Created',\n 202: 'Accepted',\n 203: 'Non-Authoritative Information',\n 204: 'No Content',\n 205: 'Reset Content',\n 206: 'Partial Content',\n 207: 'Multi-Status',\n 208: 'Already Reported',\n 226: 'IM Used',\n 300: 'Multiple Choices',\n 301: 'Moved Permanently',\n 302: 'Found',\n 303: 'See Other',\n 304: 'Not Modified',\n 305: 'Use Proxy',\n 307: 'Temporary Redirect',\n 308: 'Permanent Redirect',\n 400: 'Bad Request',\n 401: 'Unauthorized',\n 402: 'Payment Required',\n 403: 'Forbidden',\n 404: 'Not Found',\n 405: 'Method Not Allowed',\n 406: 'Not Acceptable',\n 407: 'Proxy Authentication Required',\n 408: 'Request Timeout',\n 409: 'Conflict',\n 410: 'Gone',\n 411: 'Length Required',\n 412: 'Precondition Failed',\n 413: 'Payload Too Large',\n 414: 'URI Too Long',\n 415: 'Unsupported Media Type',\n 416: 'Range Not Satisfiable',\n 417: 'Expectation Failed',\n 418: \"I'm a Teapot\",\n 421: 'Misdirected Request',\n 422: 'Unprocessable Entity',\n 423: 'Locked',\n 424: 'Failed Dependency',\n 425: 'Too Early',\n 426: 'Upgrade Required',\n 428: 'Precondition Required',\n 429: 'Too Many Requests',\n 431: 'Request Header Fields Too Large',\n 451: 'Unavailable For Legal Reasons',\n 500: 'Internal Server Error',\n 501: 'Not Implemented',\n 502: 'Bad Gateway',\n 503: 'Service Unavailable',\n 504: 'Gateway Timeout',\n 505: 'HTTP Version Not Supported',\n 506: 'Variant Also Negotiates',\n 507: 'Insufficient Storage',\n 508: 'Loop Detected',\n 509: 'Bandwidth Limit Exceeded',\n 510: 'Not Extended',\n 511: 'Network Authentication Required',\n};\n\nexport type HttpStatusCode = keyof typeof HttpStatusMessages;\n",
9
9
  "import {URL} from 'node:url';\n\nimport type {HttpMethod, NativeClientRequest} from './type.js';\n\nexport class NanotronUrl extends URL {\n protected static versionPattern_ = new RegExp('^/v[0-9]+/');\n\n public readonly method: HttpMethod;\n public readonly debugId: string;\n\n constructor(clientRequest: NativeClientRequest, prefix: `/${string}/` | '/') {\n let url = clientRequest.url ?? '';\n if (prefix !== '/' && url.indexOf(prefix) === 0) {\n url = url.slice(prefix.length - 1); // include `/`\n }\n url = url.replace(NanotronUrl.versionPattern_, '/');\n\n super(url, 'http://hostname/');\n\n this.method = (clientRequest.method ?? 'GET').toUpperCase() as HttpMethod;\n\n this.debugId = `[${this.method}]${this.pathname}`;\n }\n}\n"
10
10
  ],
11
- "mappings": ";AAAA,uBAAQ,kBAER,uBAAQ,uBCFR,uBAAQ,uBCAR,uBAAQ,uBCGD,IAAM,EAAc,CAIzB,IAAK,MAKL,KAAM,OAKN,KAAM,OAKN,IAAK,MAKL,OAAQ,SAKR,QAAS,UAKT,QAAS,UAKT,MAAO,QAKP,MAAO,OACT,EAKa,EAAkB,CAI7B,kBAAmB,IAKnB,6BAA8B,IAK9B,oBAAqB,IAKrB,qBAAsB,IAKtB,eAAgB,IAKhB,oBAAqB,IAKrB,qBAAsB,IAMtB,0CAA2C,IAK3C,uBAAwB,IAMxB,0BAA2B,IAK3B,4BAA6B,IAM7B,yBAA0B,IAM1B,6BAA8B,IAM9B,oBAAqB,IAKrB,8BAA+B,IAK/B,+BAAgC,IAKhC,mBAAoB,IAKpB,uBAAwB,IAMxB,0BAA2B,IAK3B,uBAAwB,IAKxB,0BAA2B,IAM3B,gCAAiC,IAMjC,gCAAiC,IAKjC,6BAA8B,IAK9B,8BAA+B,IAK/B,kCAAmC,IAKnC,2BAA4B,IAK5B,2BAA4B,IAK5B,oCAAqC,IAOrC,gCAAiC,IAMjC,+CAAgD,IAKhD,iCAAkC,IAKlC,0BAA2B,IAK3B,sBAAuB,IAKvB,iCAAkC,IAKlC,qCAAsC,IAMtC,mCAAoC,IAKpC,8BAA+B,IAM/B,wCAAyC,IAKzC,uCAAwC,IAKxC,oCAAqC,IAKrC,qCAAsC,IAKtC,sCAAuC,IAKvC,wBAAyB,IAKzB,mCAAoC,IAKpC,2BAA4B,IAM5B,kCA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U,SAAU,iBAAiB,EACzC,EAAI,UAAU,eAAgB,kBAAkB,EAChD,EAAI,IAAI,aAAa,EAEzB,CAAC,EAGO,gBAAgB,EAAS,CACjC,KAAK,QAAQ,YAAY,kBAAkB,EAC3C,IAAM,EAAc,KAAK,QAAQ,YACjC,GAAI,GAAa,SAAW,GAAM,OAClC,KAAK,YAAY,CACf,OAAQ,UACR,UAAW,aACX,IAAK,IACL,QAAS,QAAS,EAAG,CACnB,IAAM,EAAM,KAAK,eAAe,KAChC,EAAI,UAAU,EAAgB,uBAAwB,CACpD,8BAA+B,EAAY,OAC3C,+BAAgC,EAAY,QAC5C,+BAAgC,EAAY,QAC5C,yBAA0B,EAAY,OAAS,GAC/C,iBAAkB,CACpB,CAAC,EACD,EAAI,IAAI,EAEZ,CAAC,EAEL",
12
+ "debugId": "2FED0C993427D32164756E2164756E21",
13
13
  "names": []
14
14
  }
package/dist/type.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Awaitable, DictionaryOpt, JsonObject } from '@alwatr/type-helper';
1
2
  import type { NanotronClientRequest } from './api-client-request.js';
2
3
  import type { NanotronServerResponse } from './api-server-response.js';
3
4
  import type { IncomingMessage, ServerResponse } from 'node:http';
@@ -14,13 +15,13 @@ export type ErrorResponse = {
14
15
  errorMessage: string;
15
16
  meta?: JsonObject;
16
17
  };
17
- export type RouteHandler<TSharedMeta extends DictionaryOpt = DictionaryOpt> = (this: NanotronClientRequest<TSharedMeta>, clientRequest: NanotronClientRequest<TSharedMeta>, serverResponse: NanotronServerResponse, sharedMeta: TSharedMeta) => Awaitable<void>;
18
+ export type RouteHandler<TSharedMeta extends DictionaryOpt<any> = DictionaryOpt<any>> = (this: NanotronClientRequest<TSharedMeta>, clientRequest: NanotronClientRequest<TSharedMeta>, serverResponse: NanotronServerResponse, sharedMeta: TSharedMeta) => Awaitable<void>;
18
19
  export type NativeClientRequest = IncomingMessage;
19
20
  export type NativeServerResponse = ServerResponse;
20
21
  /**
21
22
  * Configuration options for defining a route.
22
23
  */
23
- export interface DefineRouteOption<TSharedMeta extends DictionaryOpt = DictionaryOpt> {
24
+ export interface DefineRouteOption<TSharedMeta extends DictionaryOpt<any> = DictionaryOpt<any>> {
24
25
  /**
25
26
  * The HTTP method for this route.
26
27
  */
@@ -77,11 +78,11 @@ export interface HttpResponseHeaders {
77
78
  /**
78
79
  * Specifies the time in seconds the object has been in a proxy cache.
79
80
  */
80
- age?: string;
81
+ 'age'?: string;
81
82
  /**
82
83
  * Lists the set of HTTP methods supported by the resource identified by the Request-URI.
83
84
  */
84
- allow?: string;
85
+ 'allow'?: string;
85
86
  /**
86
87
  * Specifies caching directives for both requests and responses.
87
88
  */
@@ -89,7 +90,7 @@ export interface HttpResponseHeaders {
89
90
  /**
90
91
  * Controls whether the network connection stays open after the current transaction.
91
92
  */
92
- connection?: string;
93
+ 'connection'?: string;
93
94
  /**
94
95
  * Suggests a filename for the downloaded resource or how the content should be displayed.
95
96
  */
@@ -121,15 +122,15 @@ export interface HttpResponseHeaders {
121
122
  /**
122
123
  * Indicates the date and time at which the message was originated.
123
124
  */
124
- date?: string;
125
+ 'date'?: string;
125
126
  /**
126
127
  * Provides the current value of the entity tag for the requested variant.
127
128
  */
128
- etag?: string;
129
+ 'etag'?: string;
129
130
  /**
130
131
  * Gives the date/time after which the response is considered stale.
131
132
  */
132
- expires?: string;
133
+ 'expires'?: string;
133
134
  /**
134
135
  * Indicates the date and time at which the origin server believes the variant was last modified.
135
136
  */
@@ -137,15 +138,15 @@ export interface HttpResponseHeaders {
137
138
  /**
138
139
  * Provides a list of URIs associated with the resource.
139
140
  */
140
- link?: string;
141
+ 'link'?: string;
141
142
  /**
142
143
  * Used in redirection, or when a new resource has been created.
143
144
  */
144
- location?: string;
145
+ 'location'?: string;
145
146
  /**
146
147
  * Used for backward compatibility with HTTP/1.0 caches.
147
148
  */
148
- pragma?: string;
149
+ 'pragma'?: string;
149
150
  /**
150
151
  * Requests authentication information from the client for a proxy server.
151
152
  */
@@ -157,7 +158,7 @@ export interface HttpResponseHeaders {
157
158
  /**
158
159
  * Contains information about the software used by the origin server to handle the request.
159
160
  */
160
- server?: string;
161
+ 'server'?: string;
161
162
  /**
162
163
  * Used to send cookies from the server to the user agent.
163
164
  */
@@ -169,7 +170,7 @@ export interface HttpResponseHeaders {
169
170
  /**
170
171
  * Allows the sender to include additional fields at the end of chunked messages.
171
172
  */
172
- trailer?: string;
173
+ 'trailer'?: string;
173
174
  /**
174
175
  * Specifies the form of encoding used to safely transfer the entity to the user.
175
176
  */
@@ -178,15 +179,15 @@ export interface HttpResponseHeaders {
178
179
  * Determines how to match future request headers to decide whether a cached response
179
180
  * can be used rather than requesting a fresh one from the origin server.
180
181
  */
181
- vary?: string;
182
+ 'vary'?: string;
182
183
  /**
183
184
  * Lists all intermediate proxies the message has traversed
184
185
  */
185
- via?: string;
186
+ 'via'?: string;
186
187
  /**
187
188
  * Contains additional information about the status or transformation of a message that might not be reflected in the status code.
188
189
  */
189
- warning?: string;
190
+ 'warning'?: string;
190
191
  /**
191
192
  * Indicates the authentication scheme that should be used to access the requested entity.
192
193
  */
@@ -202,7 +203,7 @@ export interface HttpRequestHeaders {
202
203
  *
203
204
  * Example: `accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*\/*;q=0.8'`
204
205
  */
205
- accept?: string;
206
+ 'accept'?: string;
206
207
  /**
207
208
  * Character sets that are acceptable.
208
209
  *
@@ -226,7 +227,7 @@ export interface HttpRequestHeaders {
226
227
  *
227
228
  * Example: `authorization: 'Basic QWxhZGAliMdGVuIHNlc2FtZQ=='`
228
229
  */
229
- authorization?: string;
230
+ 'authorization'?: string;
230
231
  /**
231
232
  * Used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain.
232
233
  *
@@ -274,26 +275,26 @@ export interface HttpRequestHeaders {
274
275
  *
275
276
  * Example: `cookie: 'sessionid=38ali123sc7a8'`
276
277
  */
277
- cookie?: string;
278
+ 'cookie'?: string;
278
279
  /**
279
280
  * The date and time that the message was originated (in "HTTP-date" format as defined by RFC 7231).
280
281
  *
281
282
  * Example: `date: 'Sun, 06 Nov 1994 08:49:37 GMT'`
282
283
  */
283
- date?: string;
284
+ 'date'?: string;
284
285
  /**
285
286
  * The email address of the user making the request.
286
287
  *
287
288
  * Example: `from: 'user@example.com'`
288
289
  */
289
- from?: string;
290
+ 'from'?: string;
290
291
  /**
291
292
  * The domain name of the server (for virtual hosting), and the TCP port number on which the server is listening.
292
293
  * The port number may be omitted if the port is the standard port for the service requested.
293
294
  *
294
295
  * Example: `host: 'en.wikipedia.org:8080'`
295
296
  */
296
- host?: string;
297
+ 'host'?: string;
297
298
  /**
298
299
  * Only send the response if the entity has not been modified since a specific time.
299
300
  *
@@ -329,7 +330,7 @@ export interface HttpRequestHeaders {
329
330
  *
330
331
  * Example: `pragma: 'no-cache'`
331
332
  */
332
- pragma?: string;
333
+ 'pragma'?: string;
333
334
  /**
334
335
  * Authorization credentials for connecting to a proxy.
335
336
  *
@@ -341,14 +342,14 @@ export interface HttpRequestHeaders {
341
342
  *
342
343
  * Example: `range: 'bytes=500-999'`
343
344
  */
344
- range?: string;
345
+ 'range'?: string;
345
346
  /**
346
347
  * This is the address of the previous web page from which a link to the currently requested page was followed.
347
348
  * (The word "referrer" is misspelled in the RFC as well as in most implementations.)
348
349
  *
349
350
  * Example: `referer: 'https://en.wikipedia.org/wiki/Main_Page'`
350
351
  */
351
- referer?: string;
352
+ 'referer'?: string;
352
353
  /**
353
354
  * The user agent string of the user agent.
354
355
  *
@@ -360,32 +361,32 @@ export interface HttpRequestHeaders {
360
361
  *
361
362
  * Example: `upgrade: 'h2c, HTTPS/1.3, IRC/6.9, RTA/x11, websocket'`
362
363
  */
363
- upgrade?: string;
364
+ 'upgrade'?: string;
364
365
  /**
365
366
  * Informs the server of proxies through which the request was sent.
366
367
  *
367
368
  * Example: `via: '1.0 fred, 1.1 example.com (Apache/1.1)'`
368
369
  */
369
- via?: string;
370
+ 'via'?: string;
370
371
  /**
371
372
  * A general warning about possible problems with the entity body.
372
373
  *
373
374
  * Example: `warning: '199 Miscellaneous warning'`
374
375
  */
375
- warning?: string;
376
+ 'warning'?: string;
376
377
  /**
377
378
  * Tells all caching mechanisms from server to client whether they may cache this object.
378
379
  * It is similar to Cache-Control: no-cache, but only applies to proxies and does not apply to private caches.
379
380
  *
380
381
  * Example: `age: '12'`
381
382
  */
382
- age?: string;
383
+ 'age'?: string;
383
384
  /**
384
385
  * Appends " trailers " to the list of acceptable transfer encodings in the `TE` header.
385
386
  *
386
387
  * Example: `allow: 'GET, HEAD'`
387
388
  */
388
- allow?: string;
389
+ 'allow'?: string;
389
390
  /**
390
391
  * What partial content range types this server supports via the `Range` header.
391
392
  *
@@ -418,7 +419,7 @@ export interface HttpRequestHeaders {
418
419
  *
419
420
  * Example: `connection: 'keep-alive'`
420
421
  */
421
- connection?: string;
422
+ 'connection'?: string;
422
423
  /**
423
424
  * The MIME type of the body of the request (used with POST and PUT requests)
424
425
  *
@@ -470,20 +471,20 @@ export interface HttpRequestHeaders {
470
471
  *
471
472
  * Example: `dnt: '1'`
472
473
  */
473
- dnt?: string;
474
+ 'dnt'?: string;
474
475
  /**
475
476
  * The `Expect` HTTP header indicates expectations that need to be fulfilled by the server in order to properly
476
477
  * handle the request.
477
478
  *
478
479
  * Example: `downlink: '10'`
479
480
  */
480
- downlink?: string;
481
+ 'downlink'?: string;
481
482
  /**
482
483
  * Specifies the effective connection type the user agent has to the network.
483
484
  *
484
485
  * Example: `ect: '4g'`
485
486
  */
486
- ect?: string;
487
+ 'ect'?: string;
487
488
  /**
488
489
  * The `Early-Data` header indicates a request that includes an Early Data body
489
490
  *
@@ -503,7 +504,7 @@ export interface HttpRequestHeaders {
503
504
  *
504
505
  * Example: `expect-ct: 'max-age=86400, report-uri="https://report-uri.example.com/report"'`
505
506
  */
506
- forwarded?: string;
507
+ 'forwarded'?: string;
507
508
  /**
508
509
  * The `Keep-Alive` general header allows the sender to hint about how the connection may be used to
509
510
  * set a timeout and a maximum amount of requests.
@@ -528,13 +529,13 @@ export interface HttpRequestHeaders {
528
529
  *
529
530
  * Example: `link: '</feed.xml>; rel="alternate"'`
530
531
  */
531
- link?: string;
532
+ 'link'?: string;
532
533
  /**
533
534
  * Used with the Location response header to indicate the identifier of the payload body sent in the request
534
535
  *
535
536
  * Example: `location: '/new/document'`
536
537
  */
537
- origin?: string;
538
+ 'origin'?: string;
538
539
  /**
539
540
  * The `Ping-From` header specifies a URI where a pong response may be sent.
540
541
  *
@@ -560,7 +561,7 @@ export interface HttpRequestHeaders {
560
561
  *
561
562
  * Example: `purpose: 'prefetch'`
562
563
  */
563
- purpose?: string;
564
+ 'purpose'?: string;
564
565
  /**
565
566
  * Used to indicate the part of a document to return.
566
567
  *
@@ -693,7 +694,7 @@ export interface HttpRequestHeaders {
693
694
  *
694
695
  * Example: `server: 'Apache/2.4.1 (Unix)'`
695
696
  */
696
- server?: string;
697
+ 'server'?: string;
697
698
  /**
698
699
  * The `Service-Worker-Navigation-Preload` header is used to control the behavior of
699
700
  * service worker navigation preloads.
@@ -708,7 +709,7 @@ export interface HttpRequestHeaders {
708
709
  *
709
710
  * Example: `sourcemap: '/path/to/file.js.map'`
710
711
  */
711
- sourcemap?: string;
712
+ 'sourcemap'?: string;
712
713
  /**
713
714
  * The `Strict-Transport-Security` (HSTS) response header informs browsers that a website
714
715
  * should only be accessed using HTTPS, and that any future attempts to access it using HTTP should automatically
@@ -723,7 +724,7 @@ export interface HttpRequestHeaders {
723
724
  *
724
725
  * Example: `te: 'trailers, deflate'`
725
726
  */
726
- te?: string;
727
+ 'te'?: string;
727
728
  /**
728
729
  * The `Timing-Allow-Origin` response header specifies origins that are allowed to see values of attributes
729
730
  * retrieved via features of the Resource Timing API, which would otherwise be reported as zero due to cross-origin restrictions.
@@ -737,7 +738,7 @@ export interface HttpRequestHeaders {
737
738
  *
738
739
  * Example: `trailer: 'Expires'`
739
740
  */
740
- trailer?: string;
741
+ 'trailer'?: string;
741
742
  /**
742
743
  * The `Transfer-Encoding` header field lists the transfer encodings applied to the message body
743
744
  * in order to ensure safe and proper transfer of the message.
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAC,eAAe,EAAE,cAAc,EAAC,MAAM,WAAW,CAAC;AAE/D,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,mBAAmB;QAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B;CACF;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,YAAY,CAAC;AAE/C,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAEhH,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,KAAK,CAAC;IACV,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,WAAW,SAAS,aAAa,GAAG,aAAa,IAAI,CAC5E,IAAI,EAAE,qBAAqB,CAAC,WAAW,CAAC,EACxC,aAAa,EAAE,qBAAqB,CAAC,WAAW,CAAC,EACjD,cAAc,EAAE,sBAAsB,EACtC,UAAU,EAAE,WAAW,KACpB,SAAS,CAAC,IAAI,CAAC,CAAC;AAErB,MAAM,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAClD,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,WAAW,SAAS,aAAa,GAAG,aAAa;IAClF;;OAEG;IAC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MG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAAC;IAErC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAAC;IAErC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC;;;;;;OAMG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAG5B,CAAC,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;CACzE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwatr/nanotron-api-server",
3
- "version": "9.11.2",
3
+ "version": "9.16.0",
4
4
  "description": "Nanotron: Your Lightweight, High-Performance Micro/Nano Service Framework. Nanotron is designed for building blazingly fast and efficient microservices and APIs. Its minimalist approach and focus on performance make it ideal for resource-constrained environments and scenarios where every millisecond counts.",
5
5
  "license": "MPL-2.0",
6
6
  "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com> (https://ali.mihandoost.com)",
@@ -21,12 +21,12 @@
21
21
  },
22
22
  "sideEffects": false,
23
23
  "dependencies": {
24
- "@alwatr/logger": "9.11.2"
24
+ "@alwatr/logger": "9.16.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@alwatr/nano-build": "9.10.1",
28
- "@alwatr/standard": "9.11.2",
29
- "@alwatr/type-helper": "9.11.2",
27
+ "@alwatr/nano-build": "9.14.0",
28
+ "@alwatr/standard": "9.16.0",
29
+ "@alwatr/type-helper": "9.14.0",
30
30
  "@types/node": "^24.12.2",
31
31
  "typescript": "^6.0.3"
32
32
  },
@@ -64,5 +64,5 @@
64
64
  "server",
65
65
  "typescript"
66
66
  ],
67
- "gitHead": "ad72dc5b615ab443b1f7e2616ec647574bb04cf5"
67
+ "gitHead": "c210044f6e8ab444ec2f9e600f095761cbd279bd"
68
68
  }
@@ -5,8 +5,9 @@ import {HttpStatusCodes} from './const.js';
5
5
 
6
6
  import type {DefineRouteOption, HttpRequestHeaders, NativeClientRequest, NativeServerResponse} from './type.js';
7
7
  import type {NanotronUrl} from './url.js';
8
+ import type {DictionaryOpt} from '@alwatr/type-helper';
8
9
 
9
- export class NanotronClientRequest<TSharedMeta extends DictionaryOpt = DictionaryOpt> {
10
+ export class NanotronClientRequest<TSharedMeta extends DictionaryOpt<any> = DictionaryOpt<any>> {
10
11
  public readonly url: NanotronUrl;
11
12
 
12
13
  public readonly serverResponse: NanotronServerResponse;
@@ -4,6 +4,7 @@ import {type HttpStatusCode, HttpStatusCodes, HttpStatusMessages} from './const.
4
4
 
5
5
  import type {NanotronClientRequest} from './api-client-request.js';
6
6
  import type {HttpResponseHeaders, ErrorResponse, NativeServerResponse} from './type.js';
7
+ import type {JsonObject} from '@alwatr/type-helper';
7
8
 
8
9
  /**
9
10
  * Configuration options for the Nanotron Api Server Response.
@@ -37,7 +38,7 @@ export class NanotronServerResponse {
37
38
 
38
39
  // Set default reply headers.
39
40
  this.headers = {
40
- server: 'Alwatr Nanotron',
41
+ 'server': 'Alwatr Nanotron',
41
42
  'content-type': 'text/plain charset=UTF-8',
42
43
  };
43
44
 
@@ -74,8 +75,7 @@ export class NanotronServerResponse {
74
75
  const metaType = typeof errorResponse.meta;
75
76
  if (metaType === 'string' || metaType === 'number' || metaType === 'boolean' || errorResponse.meta === null) {
76
77
  meta = `,"meta":"${errorResponse.meta}"`;
77
- }
78
- else if (metaType === 'object') {
78
+ } else if (metaType === 'object') {
79
79
  meta = `,"meta":${JSON.stringify(errorResponse.meta)}`;
80
80
  }
81
81
  }
@@ -96,21 +96,20 @@ export class NanotronServerResponse {
96
96
  if (error instanceof Error) {
97
97
  this.replyErrorResponse({
98
98
  ok: false,
99
- errorCode: (error.name === 'Error' ? 'error_' + statusCode : (error.name + '').toLowerCase()) as Lowercase<string>,
99
+ errorCode: (error.name === 'Error' ?
100
+ 'error_' + statusCode
101
+ : (error.name + '').toLowerCase()) as Lowercase<string>,
100
102
  errorMessage: error.message,
101
103
  });
102
- }
103
- else if (typeof error === 'string') {
104
+ } else if (typeof error === 'string') {
104
105
  this.replyErrorResponse({
105
106
  ok: false,
106
107
  errorCode: ('error_' + statusCode) as Lowercase<string>,
107
108
  errorMessage: error,
108
109
  });
109
- }
110
- else if (typeof error === 'object' && error !== null) {
110
+ } else if (typeof error === 'object' && error !== null) {
111
111
  this.replyJson(error as JsonObject);
112
- }
113
- else {
112
+ } else {
114
113
  this.replyErrorResponse({
115
114
  ok: false,
116
115
  errorCode: ('error_' + statusCode) as Lowercase<string>,
@@ -125,8 +124,7 @@ export class NanotronServerResponse {
125
124
  let responseString: string;
126
125
  try {
127
126
  responseString = JSON.stringify(responseJson);
128
- }
129
- catch (error) {
127
+ } catch (error) {
130
128
  this.logger_.error('replyJson', 'reply_json_stringify_failed', error, this.clientRequest.url.debugId);
131
129
  this.statusCode = HttpStatusCodes.Error_Server_500_Internal_Server_Error;
132
130
  this.replyErrorResponse({
@@ -170,8 +168,7 @@ export class NanotronServerResponse {
170
168
 
171
169
  this.applyHeaders_();
172
170
  this.raw_.end(context, 'binary');
173
- }
174
- catch (error) {
171
+ } catch (error) {
175
172
  this.logger_.error('reply', 'server_response_error', error, this.clientRequest.url.debugId);
176
173
  this.hasBeenSent_ = false;
177
174
  }
package/src/api-server.ts CHANGED
@@ -8,6 +8,7 @@ import {NanotronUrl} from './url.js';
8
8
 
9
9
  import type {DefineRouteOption, MatchType, NativeClientRequest, NativeServerResponse} from './type.js';
10
10
  import type {Duplex} from 'node:stream';
11
+ import type {DictionaryOpt} from '@alwatr/type-helper';
11
12
 
12
13
  /**
13
14
  * Configuration options for the NanotronApiServer.
@@ -173,8 +174,8 @@ export class NanotronApiServer {
173
174
  this.logger_.logMethod?.('getRouteOption_');
174
175
 
175
176
  if (
176
- Object.hasOwn(this.routeHandlerList__.exact, url.method) &&
177
- Object.hasOwn(this.routeHandlerList__.exact[url.method]!, url.pathname)
177
+ Object.hasOwn(this.routeHandlerList__.exact, url.method)
178
+ && Object.hasOwn(this.routeHandlerList__.exact[url.method]!, url.pathname)
178
179
  ) {
179
180
  return this.routeHandlerList__.exact[url.method]![url.pathname]!;
180
181
  }
@@ -207,7 +208,9 @@ export class NanotronApiServer {
207
208
  routeHandlerList[option.method]![option.url] = option;
208
209
  }
209
210
 
210
- public defineRoute<TSharedMeta extends DictionaryOpt = DictionaryOpt>(option: DefineRouteOption<TSharedMeta>): void {
211
+ public defineRoute<TSharedMeta extends DictionaryOpt<any> = DictionaryOpt<any>>(
212
+ option: DefineRouteOption<TSharedMeta>,
213
+ ): void {
211
214
  const option_: Required<DefineRouteOption<TSharedMeta>> = {
212
215
  matchType: 'exact',
213
216
  preHandlers: [],
@@ -223,8 +226,7 @@ export class NanotronApiServer {
223
226
  protected handleServerError_(error: NodeJS.ErrnoException): void {
224
227
  if (error.code === 'EADDRINUSE') {
225
228
  this.logger_.error('handleServerError_', 'address_in_use', error);
226
- }
227
- else {
229
+ } else {
228
230
  this.logger_.error('handleServerError_', 'http_server_error', error);
229
231
  }
230
232
  }
@@ -284,8 +286,7 @@ export class NanotronApiServer {
284
286
  if (connection.terminatedHandlers === true) return; // must check before each post-handler.
285
287
  await handler.call(connection, connection, connection.serverResponse, connection.sharedMeta);
286
288
  }
287
- }
288
- catch (error) {
289
+ } catch (error) {
289
290
  this.logger_.error('handleClientRequest_', 'route_handler_error', error, url.debugId);
290
291
 
291
292
  if (connection.serverResponse.statusCode < HttpStatusCodes.Error_Client_400_Bad_Request) {
package/src/type.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type {Awaitable, DictionaryOpt, JsonObject} from '@alwatr/type-helper';
1
2
  import type {NanotronClientRequest} from './api-client-request.js';
2
3
  import type {NanotronServerResponse} from './api-server-response.js';
3
4
  import type {IncomingMessage, ServerResponse} from 'node:http';
@@ -19,7 +20,7 @@ export type ErrorResponse = {
19
20
  meta?: JsonObject;
20
21
  };
21
22
 
22
- export type RouteHandler<TSharedMeta extends DictionaryOpt = DictionaryOpt> = (
23
+ export type RouteHandler<TSharedMeta extends DictionaryOpt<any> = DictionaryOpt<any>> = (
23
24
  this: NanotronClientRequest<TSharedMeta>,
24
25
  clientRequest: NanotronClientRequest<TSharedMeta>,
25
26
  serverResponse: NanotronServerResponse,
@@ -32,7 +33,7 @@ export type NativeServerResponse = ServerResponse;
32
33
  /**
33
34
  * Configuration options for defining a route.
34
35
  */
35
- export interface DefineRouteOption<TSharedMeta extends DictionaryOpt = DictionaryOpt> {
36
+ export interface DefineRouteOption<TSharedMeta extends DictionaryOpt<any> = DictionaryOpt<any>> {
36
37
  /**
37
38
  * The HTTP method for this route.
38
39
  */
@@ -98,12 +99,12 @@ export interface HttpResponseHeaders {
98
99
  /**
99
100
  * Specifies the time in seconds the object has been in a proxy cache.
100
101
  */
101
- age?: string;
102
+ 'age'?: string;
102
103
 
103
104
  /**
104
105
  * Lists the set of HTTP methods supported by the resource identified by the Request-URI.
105
106
  */
106
- allow?: string;
107
+ 'allow'?: string;
107
108
 
108
109
  /**
109
110
  * Specifies caching directives for both requests and responses.
@@ -113,7 +114,7 @@ export interface HttpResponseHeaders {
113
114
  /**
114
115
  * Controls whether the network connection stays open after the current transaction.
115
116
  */
116
- connection?: string;
117
+ 'connection'?: string;
117
118
 
118
119
  /**
119
120
  * Suggests a filename for the downloaded resource or how the content should be displayed.
@@ -153,17 +154,17 @@ export interface HttpResponseHeaders {
153
154
  /**
154
155
  * Indicates the date and time at which the message was originated.
155
156
  */
156
- date?: string;
157
+ 'date'?: string;
157
158
 
158
159
  /**
159
160
  * Provides the current value of the entity tag for the requested variant.
160
161
  */
161
- etag?: string;
162
+ 'etag'?: string;
162
163
 
163
164
  /**
164
165
  * Gives the date/time after which the response is considered stale.
165
166
  */
166
- expires?: string;
167
+ 'expires'?: string;
167
168
 
168
169
  /**
169
170
  * Indicates the date and time at which the origin server believes the variant was last modified.
@@ -173,17 +174,17 @@ export interface HttpResponseHeaders {
173
174
  /**
174
175
  * Provides a list of URIs associated with the resource.
175
176
  */
176
- link?: string;
177
+ 'link'?: string;
177
178
 
178
179
  /**
179
180
  * Used in redirection, or when a new resource has been created.
180
181
  */
181
- location?: string;
182
+ 'location'?: string;
182
183
 
183
184
  /**
184
185
  * Used for backward compatibility with HTTP/1.0 caches.
185
186
  */
186
- pragma?: string;
187
+ 'pragma'?: string;
187
188
 
188
189
  /**
189
190
  * Requests authentication information from the client for a proxy server.
@@ -198,7 +199,7 @@ export interface HttpResponseHeaders {
198
199
  /**
199
200
  * Contains information about the software used by the origin server to handle the request.
200
201
  */
201
- server?: string;
202
+ 'server'?: string;
202
203
 
203
204
  /**
204
205
  * Used to send cookies from the server to the user agent.
@@ -213,7 +214,7 @@ export interface HttpResponseHeaders {
213
214
  /**
214
215
  * Allows the sender to include additional fields at the end of chunked messages.
215
216
  */
216
- trailer?: string;
217
+ 'trailer'?: string;
217
218
 
218
219
  /**
219
220
  * Specifies the form of encoding used to safely transfer the entity to the user.
@@ -224,17 +225,17 @@ export interface HttpResponseHeaders {
224
225
  * Determines how to match future request headers to decide whether a cached response
225
226
  * can be used rather than requesting a fresh one from the origin server.
226
227
  */
227
- vary?: string;
228
+ 'vary'?: string;
228
229
 
229
230
  /**
230
231
  * Lists all intermediate proxies the message has traversed
231
232
  */
232
- via?: string;
233
+ 'via'?: string;
233
234
 
234
235
  /**
235
236
  * Contains additional information about the status or transformation of a message that might not be reflected in the status code.
236
237
  */
237
- warning?: string;
238
+ 'warning'?: string;
238
239
 
239
240
  /**
240
241
  * Indicates the authentication scheme that should be used to access the requested entity.
@@ -254,7 +255,7 @@ export interface HttpRequestHeaders {
254
255
  *
255
256
  * Example: `accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*\/*;q=0.8'`
256
257
  */
257
- accept?: string;
258
+ 'accept'?: string;
258
259
 
259
260
  /**
260
261
  * Character sets that are acceptable.
@@ -282,7 +283,7 @@ export interface HttpRequestHeaders {
282
283
  *
283
284
  * Example: `authorization: 'Basic QWxhZGAliMdGVuIHNlc2FtZQ=='`
284
285
  */
285
- authorization?: string;
286
+ 'authorization'?: string;
286
287
 
287
288
  /**
288
289
  * Used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain.
@@ -338,21 +339,21 @@ export interface HttpRequestHeaders {
338
339
  *
339
340
  * Example: `cookie: 'sessionid=38ali123sc7a8'`
340
341
  */
341
- cookie?: string;
342
+ 'cookie'?: string;
342
343
 
343
344
  /**
344
345
  * The date and time that the message was originated (in "HTTP-date" format as defined by RFC 7231).
345
346
  *
346
347
  * Example: `date: 'Sun, 06 Nov 1994 08:49:37 GMT'`
347
348
  */
348
- date?: string;
349
+ 'date'?: string;
349
350
 
350
351
  /**
351
352
  * The email address of the user making the request.
352
353
  *
353
354
  * Example: `from: 'user@example.com'`
354
355
  */
355
- from?: string;
356
+ 'from'?: string;
356
357
 
357
358
  /**
358
359
  * The domain name of the server (for virtual hosting), and the TCP port number on which the server is listening.
@@ -360,7 +361,7 @@ export interface HttpRequestHeaders {
360
361
  *
361
362
  * Example: `host: 'en.wikipedia.org:8080'`
362
363
  */
363
- host?: string;
364
+ 'host'?: string;
364
365
 
365
366
  /**
366
367
  * Only send the response if the entity has not been modified since a specific time.
@@ -402,7 +403,7 @@ export interface HttpRequestHeaders {
402
403
  *
403
404
  * Example: `pragma: 'no-cache'`
404
405
  */
405
- pragma?: string;
406
+ 'pragma'?: string;
406
407
 
407
408
  /**
408
409
  * Authorization credentials for connecting to a proxy.
@@ -416,7 +417,7 @@ export interface HttpRequestHeaders {
416
417
  *
417
418
  * Example: `range: 'bytes=500-999'`
418
419
  */
419
- range?: string;
420
+ 'range'?: string;
420
421
 
421
422
  /**
422
423
  * This is the address of the previous web page from which a link to the currently requested page was followed.
@@ -424,7 +425,7 @@ export interface HttpRequestHeaders {
424
425
  *
425
426
  * Example: `referer: 'https://en.wikipedia.org/wiki/Main_Page'`
426
427
  */
427
- referer?: string;
428
+ 'referer'?: string;
428
429
 
429
430
  /**
430
431
  * The user agent string of the user agent.
@@ -438,21 +439,21 @@ export interface HttpRequestHeaders {
438
439
  *
439
440
  * Example: `upgrade: 'h2c, HTTPS/1.3, IRC/6.9, RTA/x11, websocket'`
440
441
  */
441
- upgrade?: string;
442
+ 'upgrade'?: string;
442
443
 
443
444
  /**
444
445
  * Informs the server of proxies through which the request was sent.
445
446
  *
446
447
  * Example: `via: '1.0 fred, 1.1 example.com (Apache/1.1)'`
447
448
  */
448
- via?: string;
449
+ 'via'?: string;
449
450
 
450
451
  /**
451
452
  * A general warning about possible problems with the entity body.
452
453
  *
453
454
  * Example: `warning: '199 Miscellaneous warning'`
454
455
  */
455
- warning?: string;
456
+ 'warning'?: string;
456
457
 
457
458
  /**
458
459
  * Tells all caching mechanisms from server to client whether they may cache this object.
@@ -460,14 +461,14 @@ export interface HttpRequestHeaders {
460
461
  *
461
462
  * Example: `age: '12'`
462
463
  */
463
- age?: string;
464
+ 'age'?: string;
464
465
 
465
466
  /**
466
467
  * Appends " trailers " to the list of acceptable transfer encodings in the `TE` header.
467
468
  *
468
469
  * Example: `allow: 'GET, HEAD'`
469
470
  */
470
- allow?: string;
471
+ 'allow'?: string;
471
472
 
472
473
  /**
473
474
  * What partial content range types this server supports via the `Range` header.
@@ -505,7 +506,7 @@ export interface HttpRequestHeaders {
505
506
  *
506
507
  * Example: `connection: 'keep-alive'`
507
508
  */
508
- connection?: string;
509
+ 'connection'?: string;
509
510
 
510
511
  /**
511
512
  * The MIME type of the body of the request (used with POST and PUT requests)
@@ -565,7 +566,7 @@ export interface HttpRequestHeaders {
565
566
  *
566
567
  * Example: `dnt: '1'`
567
568
  */
568
- dnt?: string;
569
+ 'dnt'?: string;
569
570
 
570
571
  /**
571
572
  * The `Expect` HTTP header indicates expectations that need to be fulfilled by the server in order to properly
@@ -573,14 +574,14 @@ export interface HttpRequestHeaders {
573
574
  *
574
575
  * Example: `downlink: '10'`
575
576
  */
576
- downlink?: string;
577
+ 'downlink'?: string;
577
578
 
578
579
  /**
579
580
  * Specifies the effective connection type the user agent has to the network.
580
581
  *
581
582
  * Example: `ect: '4g'`
582
583
  */
583
- ect?: string;
584
+ 'ect'?: string;
584
585
 
585
586
  /**
586
587
  * The `Early-Data` header indicates a request that includes an Early Data body
@@ -603,7 +604,7 @@ export interface HttpRequestHeaders {
603
604
  *
604
605
  * Example: `expect-ct: 'max-age=86400, report-uri="https://report-uri.example.com/report"'`
605
606
  */
606
- forwarded?: string;
607
+ 'forwarded'?: string;
607
608
 
608
609
  /**
609
610
  * The `Keep-Alive` general header allows the sender to hint about how the connection may be used to
@@ -632,14 +633,14 @@ export interface HttpRequestHeaders {
632
633
  *
633
634
  * Example: `link: '</feed.xml>; rel="alternate"'`
634
635
  */
635
- link?: string;
636
+ 'link'?: string;
636
637
 
637
638
  /**
638
639
  * Used with the Location response header to indicate the identifier of the payload body sent in the request
639
640
  *
640
641
  * Example: `location: '/new/document'`
641
642
  */
642
- origin?: string;
643
+ 'origin'?: string;
643
644
 
644
645
  /**
645
646
  * The `Ping-From` header specifies a URI where a pong response may be sent.
@@ -671,7 +672,7 @@ export interface HttpRequestHeaders {
671
672
  *
672
673
  * Example: `purpose: 'prefetch'`
673
674
  */
674
- purpose?: string;
675
+ 'purpose'?: string;
675
676
 
676
677
  /**
677
678
  * Used to indicate the part of a document to return.
@@ -820,7 +821,7 @@ export interface HttpRequestHeaders {
820
821
  *
821
822
  * Example: `server: 'Apache/2.4.1 (Unix)'`
822
823
  */
823
- server?: string;
824
+ 'server'?: string;
824
825
 
825
826
  /**
826
827
  * The `Service-Worker-Navigation-Preload` header is used to control the behavior of
@@ -837,7 +838,7 @@ export interface HttpRequestHeaders {
837
838
  *
838
839
  * Example: `sourcemap: '/path/to/file.js.map'`
839
840
  */
840
- sourcemap?: string;
841
+ 'sourcemap'?: string;
841
842
 
842
843
  /**
843
844
  * The `Strict-Transport-Security` (HSTS) response header informs browsers that a website
@@ -854,7 +855,7 @@ export interface HttpRequestHeaders {
854
855
  *
855
856
  * Example: `te: 'trailers, deflate'`
856
857
  */
857
- te?: string;
858
+ 'te'?: string;
858
859
 
859
860
  /**
860
861
  * The `Timing-Allow-Origin` response header specifies origins that are allowed to see values of attributes
@@ -870,7 +871,7 @@ export interface HttpRequestHeaders {
870
871
  *
871
872
  * Example: `trailer: 'Expires'`
872
873
  */
873
- trailer?: string;
874
+ 'trailer'?: string;
874
875
 
875
876
  /**
876
877
  * The `Transfer-Encoding` header field lists the transfer encodings applied to the message body