While Suvidha enhances Express.js with type safety and structure, it has some trade-offs:

1. TypeScript Required

  • Designed for TypeScript. Pure JavaScript projects will not benefit from type inference or validation.

2. Zod Dependency

  • Relies on Zod for validation. Alternative libraries such as Joi and Yup are not natively supported yet.

3. Global Middleware Compatibility

  • Express global middleware (e.g., app.use(cors())) won’t extend Suvidha’s typed context.

4. Shallow Immutability in Middleware

Suvidha enforces shallow readonly constraints on context objects. Although root-level keys are immutable, nested objects can still be modified:

.use(() => ({
  user: { name: "Alice" } // root key "user" is readonly
}))

// Root-level mutation is blocked.
req.context.user = { name: "Bob" }; // TypeScript error

// Nested mutation allowed (risky!)
req.context.user.name = "Bob"; // No error, but this violates the intended immutability.

5. Response Control

  • Mixing res.send() with Suvidha’s Http classes can trigger dual-response warnings.
  • It is recommended to return data or throw errors rather than manually handling responses.

6. Custom Handlers Require Boilerplate

  • To use Http classes or Protocol objects in custom handlers, you need to implement the Handlers interface.

7. Learning Curve

  • Requires an understanding of Zod, type chaining, and Suvidha’s flow compared to raw Express.