@@ -37,6 +37,17 @@ import type { HttpContext } from './http_context/main.js'
3737 * using `request.request` property.
3838 */
3939export class Request extends Macroable {
40+ /**
41+ * Encryption module to verify signed URLs and unsign/decrypt
42+ * cookies
43+ */
44+ #encryption: Encryption
45+
46+ /**
47+ * Request config
48+ */
49+ #config: RequestConfig
50+
4051 /**
4152 * Request body set using `setBody` method
4253 */
@@ -90,11 +101,13 @@ export class Request extends Macroable {
90101 constructor (
91102 public request : IncomingMessage ,
92103 public response : ServerResponse ,
93- private encryption : Encryption ,
94- private config : RequestConfig
104+ encryption : Encryption ,
105+ config : RequestConfig
95106 ) {
96107 super ( )
97108
109+ this . #config = config
110+ this . #encryption = encryption
98111 this . parsedUrl = parse ( this . request . url ! , false )
99112 this . #parseQueryString( )
100113 }
@@ -114,7 +127,7 @@ export class Request extends Macroable {
114127 */
115128 #initiateCookieParser( ) {
116129 if ( ! this . #cookieParser) {
117- this . #cookieParser = new CookieParser ( this . header ( 'cookie' ) ! , this . encryption )
130+ this . #cookieParser = new CookieParser ( this . header ( 'cookie' ) ! , this . # encryption)
118131 }
119132 }
120133
@@ -133,7 +146,7 @@ export class Request extends Macroable {
133146 */
134147 id ( ) : string | undefined {
135148 let requestId = this . header ( 'x-request-id' )
136- if ( ! requestId && this . config . generateRequestId ) {
149+ if ( ! requestId && this . # config. generateRequestId ) {
137150 requestId = cuid ( )
138151 this . request . headers [ 'x-request-id' ] = requestId
139152 }
@@ -320,7 +333,7 @@ export class Request extends Macroable {
320333 * ```
321334 */
322335 method ( ) : string {
323- if ( this . config . allowMethodSpoofing && this . intended ( ) === 'POST' ) {
336+ if ( this . # config. allowMethodSpoofing && this . intended ( ) === 'POST' ) {
324337 return this . input ( '_method' , this . intended ( ) ) . toUpperCase ( )
325338 }
326339 return this . intended ( )
@@ -382,12 +395,12 @@ export class Request extends Macroable {
382395 * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
383396 */
384397 ip ( ) : string {
385- const ipFn = this . config . getIp
398+ const ipFn = this . # config. getIp
386399 if ( typeof ipFn === 'function' ) {
387400 return ipFn ( this )
388401 }
389402
390- return proxyaddr ( this . request , this . config . trustProxy )
403+ return proxyaddr ( this . request , this . # config. trustProxy )
391404 }
392405
393406 /**
@@ -409,7 +422,7 @@ export class Request extends Macroable {
409422 * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
410423 */
411424 ips ( ) : string [ ] {
412- return proxyaddr . all ( this . request , this . config . trustProxy )
425+ return proxyaddr . all ( this . request , this . # config. trustProxy )
413426 }
414427
415428 /**
@@ -437,7 +450,7 @@ export class Request extends Macroable {
437450 return 'https'
438451 }
439452
440- if ( ! trustProxy ( this . request . socket . remoteAddress ! , this . config . trustProxy ) ) {
453+ if ( ! trustProxy ( this . request . socket . remoteAddress ! , this . # config. trustProxy ) ) {
441454 return this . parsedUrl . protocol || 'http'
442455 }
443456
@@ -478,7 +491,7 @@ export class Request extends Macroable {
478491 * Use X-Fowarded-Host when we trust the proxy header and it
479492 * exists
480493 */
481- if ( trustProxy ( this . request . socket . remoteAddress ! , this . config . trustProxy ) ) {
494+ if ( trustProxy ( this . request . socket . remoteAddress ! , this . # config. trustProxy ) ) {
482495 host = this . header ( 'X-Forwarded-Host' ) || host
483496 }
484497
@@ -540,7 +553,7 @@ export class Request extends Macroable {
540553 return [ ]
541554 }
542555
543- const offset = this . config . subdomainOffset
556+ const offset = this . # config. subdomainOffset
544557 const subdomains = hostname . split ( '.' ) . reverse ( ) . slice ( offset )
545558
546559 /*
@@ -907,7 +920,7 @@ export class Request extends Macroable {
907920 /*
908921 * Return false when signature fails
909922 */
910- const signedUrl = this . encryption . verifier . unsign ( signature , purpose )
923+ const signedUrl = this . # encryption. verifier . unsign ( signature , purpose )
911924 if ( ! signedUrl ) {
912925 return false
913926 }
0 commit comments