tidewave 0.6.0 → 0.7.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,3 +1,4 @@
1
- import type { Handler } from '../index';
1
+ import { type Request, type Handler } from '../index';
2
2
  import type { TidewaveConfig } from '../../core';
3
- export declare function createHandleConfig(config: TidewaveConfig): Handler;
3
+ export type LocalPortGetter = (req: Request) => number | undefined;
4
+ export declare function createHandleConfig(config: TidewaveConfig, getLocalPort?: LocalPortGetter): Handler;
@@ -1,5 +1,6 @@
1
1
  import type { ServerResponse } from 'http';
2
2
  import type { IncomingMessage, NextFunction, Server } from 'connect';
3
+ import { type LocalPortGetter } from './handlers/config';
3
4
  import type { TidewaveConfig } from '../core';
4
5
  export interface Request extends IncomingMessage {
5
6
  body?: Record<string, unknown>;
@@ -8,9 +9,12 @@ export type Response = ServerResponse<IncomingMessage>;
8
9
  export type NextFn = NextFunction;
9
10
  export declare const ENDPOINT: "/tidewave";
10
11
  export type Handler = (req: Request, res: Response, next: NextFn) => Promise<void>;
11
- declare function getHandlers(config: TidewaveConfig): Record<string, Handler>;
12
- export declare function configureServer(server?: Server, config?: TidewaveConfig): Server;
13
- export declare function serve(server: Server, config?: TidewaveConfig): void;
12
+ export interface HandlerOptions {
13
+ getLocalPort?: LocalPortGetter;
14
+ }
15
+ declare function getHandlers(config: TidewaveConfig, options?: HandlerOptions): Record<string, Handler>;
16
+ export declare function configureServer(server?: Server, config?: TidewaveConfig, options?: HandlerOptions): Server;
14
17
  export declare function checkSecurity(config: TidewaveConfig): (req: Request, res: Response, next: NextFn) => void;
15
18
  export declare function methodNotAllowed(res: Response): void;
19
+ export declare function originNotAllowed(res: Response): void;
16
20
  export { getHandlers };
@@ -2,11 +2,3 @@ import type { TidewaveConfig } from '../core';
2
2
  import type { Request, Response } from './index';
3
3
  export declare function checkRemoteIp(req: Request, res: Response, config: TidewaveConfig): boolean;
4
4
  export declare function isLocalIp(ip?: string): boolean;
5
- export declare function checkOrigin(req: Request, res: Response, config: TidewaveConfig): boolean;
6
- export declare function getDefaultAllowedOrigins(config: TidewaveConfig): string[];
7
- export declare function parseUrl(url: string): {
8
- scheme?: string;
9
- host: string;
10
- port?: number;
11
- } | null;
12
- export declare function isOriginAllowed(origin: ReturnType<typeof parseUrl>, allowed: ReturnType<typeof parseUrl>): boolean;
@@ -7,5 +7,6 @@ export type FunctionLike = (...args: any[]) => unknown;
7
7
  export type Nextable<H extends FunctionLike> = (...args: [...Parameters<H>, NextHandler]) => ValueOrPromise<any>;
8
8
  export type ValueOrPromise<T> = T | Promise<T>;
9
9
  export type RequestHandler<Req extends Request, Res extends Response> = (req: Req, res: Res) => ValueOrPromise<void>;
10
+ export declare function getRequestLocalPort(request: Request): number | undefined;
10
11
  export declare function tidewaveHandler(config?: TidewaveConfig): Promise<NextJsHandler>;
11
12
  export {};