@worktango/ai-assistant 0.0.25 → 0.0.26
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 +3 -2
- package/package.json +1 -1
- package/src/backend/express.ts +10 -3
- package/types.d.ts +6 -0
- package/express.d.ts +0 -1
package/dist/express.js
CHANGED
|
@@ -50,17 +50,18 @@ function setupAiAssistantRoutes(args) {
|
|
|
50
50
|
if (!bearerToken) {
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
const
|
|
53
|
+
const targetPath = args.getTargetPath(req);
|
|
54
54
|
const options = {
|
|
55
55
|
hostname: args.targetHost,
|
|
56
56
|
port: args.targetPort,
|
|
57
|
-
path:
|
|
57
|
+
path: targetPath,
|
|
58
58
|
method: req.method,
|
|
59
59
|
headers: { ...req.headers }
|
|
60
60
|
};
|
|
61
61
|
options.headers["Authorization"] = `Bearer ${bearerToken}`;
|
|
62
62
|
delete options.headers.host;
|
|
63
63
|
logger.debug("Proxying request:", {
|
|
64
|
+
targetPath,
|
|
64
65
|
method: req.method,
|
|
65
66
|
headers: options.headers,
|
|
66
67
|
proxyOptions: options
|
package/package.json
CHANGED
package/src/backend/express.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import http from "http";
|
|
2
2
|
|
|
3
|
-
import { Express, RequestHandler } from "express";
|
|
3
|
+
import type { Express, RequestHandler, Request } from "express";
|
|
4
4
|
|
|
5
5
|
import { coalesce } from "@kazoohr/helpers";
|
|
6
6
|
|
|
@@ -36,6 +36,12 @@ export function setupAiAssistantRoutes(args: {
|
|
|
36
36
|
* Middleware functions to run before the proxy request.
|
|
37
37
|
*/
|
|
38
38
|
preflightMiddlewares?: RequestHandler[];
|
|
39
|
+
/**
|
|
40
|
+
* A function that should return the target path for the proxy request, based
|
|
41
|
+
* on the incoming request object. The path returned will be appended to the
|
|
42
|
+
* target host and port to form the final URL.
|
|
43
|
+
*/
|
|
44
|
+
getTargetPath: (req: Request) => string;
|
|
39
45
|
}) {
|
|
40
46
|
const logger = coalesce(args.logger, console);
|
|
41
47
|
const routePath = args.route ?? "/ai-assistant";
|
|
@@ -54,12 +60,12 @@ export function setupAiAssistantRoutes(args: {
|
|
|
54
60
|
return;
|
|
55
61
|
}
|
|
56
62
|
|
|
57
|
-
const
|
|
63
|
+
const targetPath = args.getTargetPath(req);
|
|
58
64
|
|
|
59
65
|
const options = {
|
|
60
66
|
hostname: args.targetHost,
|
|
61
67
|
port: args.targetPort,
|
|
62
|
-
path:
|
|
68
|
+
path: targetPath,
|
|
63
69
|
method: req.method,
|
|
64
70
|
headers: { ...req.headers },
|
|
65
71
|
};
|
|
@@ -68,6 +74,7 @@ export function setupAiAssistantRoutes(args: {
|
|
|
68
74
|
delete options.headers.host;
|
|
69
75
|
|
|
70
76
|
logger.debug("Proxying request:", {
|
|
77
|
+
targetPath,
|
|
71
78
|
method: req.method,
|
|
72
79
|
headers: options.headers,
|
|
73
80
|
proxyOptions: options,
|
package/types.d.ts
CHANGED
|
@@ -68,5 +68,11 @@ declare module "@worktango/ai-assistant/express" {
|
|
|
68
68
|
* Middleware functions to run before the proxy request.
|
|
69
69
|
*/
|
|
70
70
|
preflightMiddlewares?: RequestHandler[];
|
|
71
|
+
/**
|
|
72
|
+
* A function that should return the target path for the proxy request, based
|
|
73
|
+
* on the incoming request object. The path returned will be appended to the
|
|
74
|
+
* target host and port to form the final URL.
|
|
75
|
+
*/
|
|
76
|
+
getTargetPath: (req: Request) => string;
|
|
71
77
|
}): void;
|
|
72
78
|
}
|
package/express.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { setupAiAssistantRoutes } from "./src/backend/express";
|