Skip to content

Conversation

@schiwekM
Copy link
Contributor

@schiwekM schiwekM changed the title Document cds.middlewares.before and cds.middlewares.after Document cds.middlewares.before Jan 26, 2026
Copy link
Contributor

@daogrady daogrady left a comment

Choose a reason for hiding this comment

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

Hi Marten,

thank you for your contribution! Judging from the documentation, before should take in an ordered list of handlers:

The standard set of middlewares uses the following order
https://cap.cloud.sap/docs/node.js/cds-serve#cds-middlewares

is there a way to distinguish them, making sure they are defined in the right order?

Also, there's a subtle syntactic quirk here:

[number]  // tuple with exactly one number in it
[number, number]  // tuple with exactly two numbers in it
number[]  // array of number (arbitrary length)

I guess we want to aim for either

RequestHandler[]

if we want to allow an arbitrary number of handlers in any order, or

[RequestHandler, RequestHandler, RequestHandler]

if we want to strictly allow three (or however many is correct) handlers, or

[RequestHandlerA, RequestHandlerB, RequestHandlerC]

if we want to strictly allow three handlers, and each such handler must fulfil some condition we define, to make sure they are in the correct order.

Best,
Daniel

@schiwekM
Copy link
Contributor Author

Hi @daogrady,

thanks for the explanation - first time writing types :)

I think

RequestHandler[]

is the best version as in theory applications can also modify cds.middlewares.before to introduce own ones.

BR, Marten

Copy link
Contributor

@daogrady daogrady left a comment

Choose a reason for hiding this comment

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

No worries, just wanted to make sure. Welcome to TypeScript in that case and thanks for your contribution!

@schiwekM schiwekM changed the title Document cds.middlewares.before fix: Document cds.middlewares.before Jan 28, 2026
@schiwekM schiwekM merged commit 830729c into main Jan 28, 2026
11 checks passed
@schiwekM schiwekM deleted the feat/cds.middlewares.signature branch January 28, 2026 11:51
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.

3 participants