-
-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial functionality for a custom stream handler
- Loading branch information
1 parent
d7c30fc
commit bd971f1
Showing
11 changed files
with
1,246 additions
and
1,128 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {Response} from './response'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export type Handler = (body: any) => Promise<Response>; | ||
|
||
export interface StreamEvents { | ||
onOpen: () => void; | ||
onResult: (result: {text?: string; error?: string}) => void; | ||
onClose: () => void; | ||
stopClicked: {listener: () => void}; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export type StreamHandler = (body: any, events: StreamEvents) => void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import {Handler, StreamHandler} from './handler'; | ||
import {GenericObject} from './object'; | ||
import {Response} from './response'; | ||
|
||
export interface Request { | ||
url?: string; | ||
method?: string; | ||
headers?: GenericObject<string>; | ||
additionalBodyProps?: GenericObject<any>; | ||
websocket?: boolean | string | string[]; | ||
handler?: (body: any) => Promise<Response>; | ||
handler?: Handler; | ||
streamHandler?: StreamHandler; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters