@worktango/ai-assistant 0.0.37 → 0.0.38
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/express.js +5 -1
- package/express.d.ts +12 -3
- package/package.json +1 -1
package/dist/express.js
CHANGED
|
@@ -11195,10 +11195,14 @@ function setupAiAssistantRoutes(args) {
|
|
|
11195
11195
|
target: `${protocol}://${args.targetHost}:${port}`,
|
|
11196
11196
|
changeOrigin: true,
|
|
11197
11197
|
pathRewrite: (path, req) => {
|
|
11198
|
-
|
|
11198
|
+
const expressRequest = req;
|
|
11199
|
+
return args.getTargetPath(expressRequest.originalUrl || path);
|
|
11199
11200
|
},
|
|
11200
11201
|
on: {
|
|
11201
11202
|
proxyReq: async (proxyReq, req) => {
|
|
11203
|
+
if (!proxyReq.writable) {
|
|
11204
|
+
return;
|
|
11205
|
+
}
|
|
11202
11206
|
try {
|
|
11203
11207
|
const bearerToken = await args.getBearerToken(req.headers);
|
|
11204
11208
|
proxyReq.setHeader("Authorization", `Bearer ${bearerToken}`);
|
package/express.d.ts
CHANGED
|
@@ -7,7 +7,9 @@ export function setupAiAssistantRoutes(args: {
|
|
|
7
7
|
* back-channel request proxying. This should be a JWT token that can be
|
|
8
8
|
* decoded on the `kazoo-web` application to authenticate the request.
|
|
9
9
|
*/
|
|
10
|
-
getBearerToken: (
|
|
10
|
+
getBearerToken: (
|
|
11
|
+
headers: Record<string, undefined | string | string[]>
|
|
12
|
+
) => Promise<string>;
|
|
11
13
|
/**
|
|
12
14
|
* The host of the application to proxy requests to.
|
|
13
15
|
*/
|
|
@@ -31,8 +33,15 @@ export function setupAiAssistantRoutes(args: {
|
|
|
31
33
|
preflightMiddlewares?: RequestHandler[];
|
|
32
34
|
/**
|
|
33
35
|
* A function that should return the target path for the proxy request, based
|
|
34
|
-
* on the incoming
|
|
36
|
+
* on the incoming full path. The path returned will be appended to the
|
|
35
37
|
* target host and port to form the final URL.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* getTargetPath: (fullPath) => {
|
|
42
|
+
* return fullPath;
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
36
45
|
*/
|
|
37
|
-
getTargetPath: (
|
|
46
|
+
getTargetPath: (fullPath: string) => string;
|
|
38
47
|
}): void;
|