Skip to content

Conversation

Leka74
Copy link

@Leka74 Leka74 commented Aug 31, 2025

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Adds requires support to HttpApiMiddleware.Tag to allow middlewares to depend on other middleware outputs.

Details:

  • New option: requires?: Context.Tag | ReadonlyArray<Context.Tag> when defining a middleware tag.

Example:

export class AdminUser extends HttpApiMiddleware.Tag<AdminUser>()("Http/Admin", {
  failure: HttpApiError.Forbidden,
  requires: CurrentUser // or: [CurrentUser, Session]
}) {}

// Inside the middleware implementation you can now safely use the required services
yield* CurrentUser

Related

@Leka74 Leka74 requested a review from tim-smart as a code owner August 31, 2025 18:59
@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Aug 31, 2025
Copy link

changeset-bot bot commented Aug 31, 2025

🦋 Changeset detected

Latest commit: 14347e8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
@effect/platform Minor
@effect/cli Major
@effect/cluster Major
@effect/experimental Major
@effect/opentelemetry Major
@effect/platform-browser Major
@effect/platform-bun Major
@effect/platform-node-shared Major
@effect/platform-node Major
@effect/rpc Major
@effect/sql-clickhouse Major
@effect/sql-d1 Major
@effect/sql-drizzle Major
@effect/sql-libsql Major
@effect/sql-mssql Major
@effect/sql-mysql2 Major
@effect/sql-pg Major
@effect/sql-sqlite-bun Major
@effect/sql-sqlite-node Major
@effect/sql Major
@effect/workflow Major
@effect/ai Major
@effect/ai-amazon-bedrock Major
@effect/ai-anthropic Major
@effect/ai-google Major
@effect/ai-openai Major
@effect/sql-sqlite-do Major
@effect/sql-sqlite-react-native Major
@effect/sql-sqlite-wasm Major
@effect/sql-kysely Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Leka74 Leka74 changed the title feat: required field for dependencies in HttpApiMiddleware feat: requires field for dependencies in HttpApiMiddleware Sep 1, 2025
@effect-bot effect-bot force-pushed the next-minor branch 6 times, most recently from 7b84260 to 14a9104 Compare September 2, 2025 21:02
@tim-smart
Copy link
Contributor

HttpApiMiddleware will have a type-level requires option: https://github.com/Effect-TS/effect-smol/blob/main/packages/effect/src/unstable/httpapi/HttpApiMiddleware.ts#L173

It could be back-ported at some stage.

@effect-bot effect-bot force-pushed the next-minor branch 16 times, most recently from 5cac2f0 to 27301e6 Compare September 6, 2025 11:52
@patroza
Copy link
Member

patroza commented Sep 7, 2025

It could be back-ported at some stage.

better soon than later. guess we can expand #5331 to http api

@effect-bot effect-bot force-pushed the next-minor branch 15 times, most recently from 123a26d to 3eae676 Compare September 13, 2025 10:45
@effect-bot effect-bot force-pushed the next-minor branch 8 times, most recently from b64c6b1 to 5306ee2 Compare September 17, 2025 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Discussion Ongoing
Development

Successfully merging this pull request may close these issues.

3 participants