Skip to content

feat: add app-aware router creation - #7396

Open
armanmikoyan wants to merge 1 commit into
expressjs:masterfrom
armanmikoyan:feat/app-create-router
Open

feat: add app-aware router creation#7396
armanmikoyan wants to merge 1 commit into
expressjs:masterfrom
armanmikoyan:feat/app-create-router

Conversation

@armanmikoyan

@armanmikoyan armanmikoyan commented Jul 27, 2026

Copy link
Copy Markdown

Description

Closes #2564.

Adds app.createRouter(options) to create an app-aware router that inherits the application's applicable routing settings:

  • case sensitive routing
  • strict routing

Routers created with express.Router() do not inherit these settings:

const app = express()

app.enable('case sensitive routing')
app.enable('strict routing')

const router = express.Router()
// Does not inherit the app settings
// caseSensitive: undefined
// strict: undefined

The new method allows these settings to be inherited:

const router = app.createRouter()
// caseSensitive: true
// strict: true

Explicit options override inherited settings, while other Router options are passed through:

const router = app.createRouter({
  strict: false,
  mergeParams: true
})

Tests

  • Added tests for inherited routing settings
  • Added tests for explicit overrides
  • Added coverage for additional Router options
  • Router-related test suite passes

@armanmikoyan
armanmikoyan force-pushed the feat/app-create-router branch from cae971d to 1855a86 Compare July 27, 2026 10:33
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.

Shouldn't app.set("case sensitive routing") propagate to new Routers?

1 participant