返回类型PassThrough
This commit is contained in:
parent
7fd563a2c8
commit
ff3496a9ac
|
|
@ -2,6 +2,7 @@ import { IncomingHttpHeaders, IncomingMessage } from "http";
|
|||
import { AsyncContext } from "../store/AsyncRowStore";
|
||||
import { EntityDict } from "./Entity";
|
||||
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
||||
import { PassThrough } from "stream";
|
||||
export type EndpointItem<ED extends EntityDict & BaseEntityDict, BackCxt extends AsyncContext<ED>> = RestEndpoint<ED, BackCxt> | CustomEndpoint<ED, BackCxt>;
|
||||
export interface RestEndpoint<ED extends EntityDict & BaseEntityDict, BackCxt extends AsyncContext<ED>> {
|
||||
name: string;
|
||||
|
|
@ -19,6 +20,6 @@ export interface CustomEndpoint<ED extends EntityDict & BaseEntityDict, BackCxt
|
|||
params?: string[];
|
||||
method: 'get' | 'post' | 'put' | 'delete';
|
||||
type: "custom";
|
||||
fn: (contextGetter: () => Promise<BackCxt>, params: Record<string, string>, headers: IncomingHttpHeaders, req: IncomingMessage, body?: any) => Promise<NodeJS.ReadableStream>;
|
||||
fn: (contextGetter: () => Promise<BackCxt>, params: Record<string, string>, headers: IncomingHttpHeaders, req: IncomingMessage, body?: any) => Promise<PassThrough | NodeJS.ReadableStream>;
|
||||
}
|
||||
export type Endpoint<ED extends EntityDict & BaseEntityDict, BackCxt extends AsyncContext<ED>> = EndpointItem<ED, BackCxt> | EndpointItem<ED, BackCxt>[];
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { ClientRequest, IncomingHttpHeaders, IncomingMessage } from "http";
|
|||
import { AsyncContext } from "../store/AsyncRowStore";
|
||||
import { EntityDict } from "./Entity";
|
||||
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
||||
import { PassThrough } from "stream";
|
||||
|
||||
export type EndpointItem<ED extends EntityDict & BaseEntityDict, BackCxt extends AsyncContext<ED>> = RestEndpoint<ED, BackCxt> | CustomEndpoint<ED, BackCxt>
|
||||
export interface RestEndpoint<ED extends EntityDict & BaseEntityDict, BackCxt extends AsyncContext<ED>> {
|
||||
|
|
@ -23,7 +24,7 @@ export interface CustomEndpoint<ED extends EntityDict & BaseEntityDict, BackCxt
|
|||
method: 'get' | 'post' | 'put' | 'delete';
|
||||
type: "custom";
|
||||
fn: (contextGetter: () => Promise<BackCxt>, params: Record<string, string>, headers: IncomingHttpHeaders,
|
||||
req: IncomingMessage, body?: any) => Promise<NodeJS.ReadableStream>;
|
||||
req: IncomingMessage, body?: any) => Promise<PassThrough | NodeJS.ReadableStream>;
|
||||
};
|
||||
|
||||
export type Endpoint<ED extends EntityDict & BaseEntityDict, BackCxt extends AsyncContext<ED>> = EndpointItem<ED, BackCxt> | EndpointItem<ED, BackCxt>[];
|
||||
|
|
|
|||
Loading…
Reference in New Issue