Skip to content

feat: accept config object in createApp() to consolidate settings (#31)#32

Merged
Nadhila-dot merged 1 commit intomainfrom
fix/consolidate-config-31
Mar 31, 2026
Merged

feat: accept config object in createApp() to consolidate settings (#31)#32
Nadhila-dot merged 1 commit intomainfrom
fix/consolidate-config-31

Conversation

@JustaCube
Copy link
Copy Markdown
Collaborator

Allow createApp() to accept an optional config object that consolidates server, TLS, and dev settings in one place instead of scattering them across httpServerConfig, app.listen(), and .opt().

New usage:
const app = createApp({
server: { port: 8080, host: "0.0.0.0" },
tls: { cert: "./cert.pem", key: "./key.pem" },
dev: { hotReload: true, notify: true },
})
await app.listen()

Fully backward compatible — createApp() with no args still works, and app.listen(options) can still override any setting per-call.

Allow createApp() to accept an optional config object that consolidates
server, TLS, and dev settings in one place instead of scattering them
across httpServerConfig, app.listen(), and .opt().

New usage:
  const app = createApp({
    server: { port: 8080, host: "0.0.0.0" },
    tls: { cert: "./cert.pem", key: "./key.pem" },
    dev: { hotReload: true, notify: true },
  })
  await app.listen()

Fully backward compatible — createApp() with no args still works,
and app.listen(options) can still override any setting per-call.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@JustaCube JustaCube requested a review from Nadhila-dot March 30, 2026 23:53
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19b0dbce54

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/index.js
serverConfig: {
...(appListenDefaults.serverConfig ?? {}),
...(listenOptions.serverConfig ?? {}),
tls: listenOptions.serverConfig?.tls ?? appListenDefaults.serverConfig?.tls,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve explicit null when overriding TLS per listen call

Using nullish coalescing here makes it impossible to disable app-level TLS defaults for a specific listen() call. If createApp({ tls: ... }) is used and a caller passes serverConfig.tls = null (or chains .tls(null)), null is treated as missing and the default TLS config is reapplied, so the server still starts in HTTPS mode instead of HTTP. This breaks the advertised per-call override behavior.

Useful? React with 👍 / 👎.

Comment thread src/index.js

// Consolidate top-level config into a normalized shape that listen() can use as defaults.
const appConfig = {
server: config.server ?? {},
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle null config input in createApp()

createApp now dereferences config.server directly, so createApp(null) throws at startup. Before this change, extra arguments were ignored, so this is a backward-incompatible runtime break for JS callers that forward optional config values which may be null (e.g., parsed JSON/env defaults). Treating null like an omitted config would avoid this crash.

Useful? React with 👍 / 👎.

@Nadhila-dot Nadhila-dot merged commit 32b29e2 into main Mar 31, 2026
2 checks passed
@Nadhila-dot Nadhila-dot deleted the fix/consolidate-config-31 branch April 1, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants