Skip to content

Commit 0e7d241

Browse files
authored
chore: export UserConfigSchema for consumers (#771)
1 parent a585a82 commit 0e7d241

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/common/config/userConfig.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ export const UserConfigSchema = z4.object({
113113
httpPort: z4.coerce
114114
.number()
115115
.int()
116-
.min(1, "Invalid httpPort: must be at least 1")
116+
.min(0, "Invalid httpPort: must be at least 0")
117117
.max(65535, "Invalid httpPort: must be at most 65535")
118118
.default(3000)
119-
.describe("Port number for the HTTP server (only used when transport is 'http').")
119+
.describe("Port number for the HTTP server (only used when transport is 'http'). Use 0 for a random port.")
120120
.register(configRegistry, { overrideBehavior: "not-allowed" }),
121121
httpHost: z4
122122
.string()
@@ -125,7 +125,7 @@ export const UserConfigSchema = z4.object({
125125
.register(configRegistry, { overrideBehavior: "not-allowed" }),
126126
httpHeaders: z4
127127
.object({})
128-
.passthrough()
128+
.loose()
129129
.default({})
130130
.describe(
131131
"Header that the HTTP server will validate when making requests (only used when transport is 'http')."

src/lib.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export { Server, type ServerOptions } from "./server.js";
22
export { Session, type SessionOptions } from "./common/session.js";
3-
export { type UserConfig } from "./common/config/userConfig.js";
3+
export { type UserConfig, UserConfigSchema } from "./common/config/userConfig.js";
44
export { LoggerBase, type LogPayload, type LoggerType, type LogLevel } from "./common/logger.js";
55
export { StreamableHttpRunner } from "./transports/streamableHttp.js";
66
export { StdioRunner } from "./transports/stdio.js";

tests/unit/common/config.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,17 +690,17 @@ describe("config", () => {
690690
});
691691

692692
describe("httpPort", () => {
693-
it("must be above 1", () => {
693+
it("must be above 0", () => {
694694
const onErrorFn = vi.fn();
695695
const onExitFn = vi.fn<CreateUserConfigHelpers["closeProcess"]>();
696696
createUserConfig({
697697
onError: onErrorFn,
698698
closeProcess: onExitFn,
699-
cliArguments: ["--httpPort", "0"],
699+
cliArguments: ["--httpPort", "-1"],
700700
});
701701
expect(onErrorFn).toBeCalledWith(
702702
expect.stringContaining(
703-
"Invalid configuration for the following fields:\nhttpPort - Invalid httpPort: must be at least 1"
703+
"Invalid configuration for the following fields:\nhttpPort - Invalid httpPort: must be at least 0"
704704
)
705705
);
706706
expect(onExitFn).toBeCalledWith(1);

0 commit comments

Comments
 (0)