ampcode-connector 0.1.11 → 0.1.12
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/package.json +1 -1
- package/src/config/config.ts +3 -0
- package/src/index.ts +1 -1
- package/src/server/server.ts +2 -2
package/package.json
CHANGED
package/src/config/config.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { LogLevel } from "../utils/logger.ts";
|
|
|
7
7
|
import { logger } from "../utils/logger.ts";
|
|
8
8
|
|
|
9
9
|
export interface ProxyConfig {
|
|
10
|
+
hostname: string;
|
|
10
11
|
port: number;
|
|
11
12
|
ampUpstreamUrl: string;
|
|
12
13
|
ampApiKey?: string;
|
|
@@ -20,6 +21,7 @@ export interface ProxyConfig {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
const DEFAULTS: ProxyConfig = {
|
|
24
|
+
hostname: "localhost",
|
|
23
25
|
port: 8765,
|
|
24
26
|
ampUpstreamUrl: DEFAULT_AMP_UPSTREAM_URL,
|
|
25
27
|
logLevel: "info",
|
|
@@ -44,6 +46,7 @@ export async function loadConfig(): Promise<ProxyConfig> {
|
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
return {
|
|
49
|
+
hostname: asString(file?.hostname) ?? process.env.HOST ?? DEFAULTS.hostname,
|
|
47
50
|
port,
|
|
48
51
|
ampUpstreamUrl: asString(file?.ampUpstreamUrl) ?? DEFAULTS.ampUpstreamUrl,
|
|
49
52
|
ampApiKey: apiKey,
|
package/src/index.ts
CHANGED
|
@@ -59,7 +59,7 @@ function banner(config: ProxyConfig): void {
|
|
|
59
59
|
|
|
60
60
|
line();
|
|
61
61
|
line(` ${s.bold}ampcode-connector${s.reset}`);
|
|
62
|
-
line(` ${s.dim}http
|
|
62
|
+
line(` ${s.dim}http://${config.hostname}:${config.port}${s.reset}`);
|
|
63
63
|
line();
|
|
64
64
|
|
|
65
65
|
for (const p of providers) {
|
package/src/server/server.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { type ParsedBody, parseBody } from "./body.ts";
|
|
|
17
17
|
export function startServer(config: ProxyConfig): ReturnType<typeof Bun.serve> {
|
|
18
18
|
const server = Bun.serve({
|
|
19
19
|
port: config.port,
|
|
20
|
-
hostname:
|
|
20
|
+
hostname: config.hostname,
|
|
21
21
|
idleTimeout: 255, // seconds — LLM streaming responses can take minutes
|
|
22
22
|
|
|
23
23
|
async fetch(req) {
|
|
@@ -38,7 +38,7 @@ export function startServer(config: ProxyConfig): ReturnType<typeof Bun.serve> {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
affinity.startCleanup();
|
|
41
|
-
logger.info(`ampcode-connector listening on http
|
|
41
|
+
logger.info(`ampcode-connector listening on http://${config.hostname}:${config.port}`);
|
|
42
42
|
|
|
43
43
|
const shutdown = () => {
|
|
44
44
|
logger.info("Shutting down...");
|