@tinyhttp/app 2.0.17 → 2.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -8,8 +8,8 @@ import { Router, pushMiddleware } from '@tinyhttp/router';
8
8
  import { getResponseHeader, setHeader, send, json, status, sendStatus, sendFile, setContentType, setLocationHeader, setLinksHeader, setVaryHeader, setCookie, clearCookie, formatResponse, redirect, attachment, download, append } from '@tinyhttp/res';
9
9
  import { parse } from 'regexparam';
10
10
 
11
- const trustRemoteAddress = ({ connection }) => {
12
- const val = connection.remoteAddress;
11
+ const trustRemoteAddress = ({ socket }) => {
12
+ const val = socket.remoteAddress;
13
13
  if (typeof val === 'function')
14
14
  return val;
15
15
  if (typeof val === 'boolean' && val === true)
package/dist/request.d.ts CHANGED
@@ -6,12 +6,14 @@ import { App } from './app';
6
6
  import type { Middleware, Handler } from '@tinyhttp/router';
7
7
  import type { Response } from './response';
8
8
  import type { URLParams } from '@tinyhttp/req';
9
+ import type { Socket } from 'net';
10
+ import type { TLSSocket } from 'tls';
9
11
  export { getURLParams } from '@tinyhttp/req';
10
12
  export declare const getRouteFromApp: ({ middleware }: App, h: Handler<Request, Response>) => Middleware<Request, Response>;
11
13
  export declare const getProtocol: (req: Request) => Protocol;
12
14
  export declare const getHostname: (req: Request) => string | undefined;
13
- export declare const getIP: (req: Pick<IncomingMessage, 'headers' | 'connection'>) => string | undefined;
14
- export declare const getIPs: (req: Pick<IncomingMessage, 'headers' | 'connection'>) => string[] | undefined;
15
+ export declare const getIP: (req: Pick<Request, 'headers' | 'connection' | 'socket'>) => string | undefined;
16
+ export declare const getIPs: (req: Pick<Request, 'headers' | 'connection' | 'socket'>) => string[] | undefined;
15
17
  export declare const getSubdomains: (req: Request, subdomainOffset?: number) => string[];
16
18
  export declare type Connection = IncomingMessage['socket'] & {
17
19
  encrypted: boolean;
@@ -26,6 +28,7 @@ export interface Request extends IncomingMessage {
26
28
  query: ParsedUrlQuery;
27
29
  params: URLParams;
28
30
  connection: Connection;
31
+ socket: TLSSocket | Socket;
29
32
  route?: Middleware;
30
33
  protocol: Protocol;
31
34
  secure: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinyhttp/app",
3
- "version": "2.0.17",
3
+ "version": "2.0.20",
4
4
  "description": "0-legacy, tiny & fast web framework as a replacement of Express",
5
5
  "type": "module",
6
6
  "homepage": "https://tinyhttp.v1rtl.site",
@@ -34,10 +34,10 @@
34
34
  "dependencies": {
35
35
  "@tinyhttp/cookie": "2.0.3",
36
36
  "@tinyhttp/proxy-addr": "2.0.3",
37
- "@tinyhttp/req": "2.0.11",
38
- "@tinyhttp/res": "2.0.13",
37
+ "@tinyhttp/req": "2.0.12",
38
+ "@tinyhttp/res": "2.0.15",
39
39
  "@tinyhttp/router": "2.0.4",
40
- "header-range-parser": "1.1.1",
40
+ "header-range-parser": "1.1.3",
41
41
  "regexparam": "^2.0.0"
42
42
  },
43
43
  "scripts": {