Skip to content

v0.7.10

Choose a tag to compare

@github-actions github-actions released this 27 Sep 13:05
· 40 commits to main since this release

ExisJS Release v0.7.10

Release Date: 2026-09-27
Type: Minor Feature, DI Reflection, Serialization Resilience, Validator Coercion & Error Standardization
Affected Packages: exisjs


Highlights

  • Class Controller Inheritance (Base & Abstract Controller Support):
    • Controllers can now extend abstract or base controllers with @Controller() discovering all inherited route methods, parameter metadata, middlewares, lifecycle guards, interceptors, and exception filters across the full prototype hierarchy.
  • Property-Level @Inject() and @Optional() Decorators:
    • Services, controllers, and modules support property injection directly on class fields (@Inject(Token) public service!: Service) with TypeScript design:type reflection fallback and @Optional() handling.
  • Forward References & Circular Dependency DI Resolution (forwardRef):
    • Added forwardRef(() => Target) and lazy ES6 Proxy circular dependency resolution in the DI container, resolving cyclic service dependencies seamlessly.
  • Built-in Parameter Transformation Pipes & @UsePipes:
    • Added ParseIntPipe, ParseFloatPipe, ParseBoolPipe, ParseUUIDPipe, ParseArrayPipe, ValidationPipe, and the @UsePipes(...pipes) decorator for class, method, and parameter level data transformation.
  • @Global() Module & Provider Decorator:
    • Added @Global() decorator for modules, making exported providers globally accessible across the entire application without redundant imports.
  • Automatic Constructor Parameter Type Reflection via design:paramtypes:
    • In OOP controllers and services, ExisJS automatically inspects TypeScript's emitted metadata (Reflect.getMetadata('design:paramtypes', TargetClass)) and matches parameter classes directly against INJECTABLE_REGISTRY.
    • Eliminates boilerplate @Inject(Service) decorators on standard constructor parameters.
  • Built-in Safe Response Serializer (BSON, Dates & Prototype Auto-Unwrapping):
    • Added a zero-crash serialization engine (safeSanitize) in the HTTP response pipeline.
    • Automatically unwraps Mongoose documents and ORM models via .toObject({ virtuals: true, getters: true }) or .toJSON().
    • Automatically converts MongoDB BSON types (ObjectId, Decimal128, Long, Binary), native BigInt (to string), Date (to ISO 8601), and Map/Set structures.
    • Stack-based ancestor tracking prevents circular reference crashes (replacing cycles with '[Circular]') without false-positive detection on shared directed acyclic graphs (DAGs).
  • Enhanced Serialization Error Diagnostics:
    • Automatically tracks object property paths during traversal (e.g. 'recentTransactions[0].accountId'), logging detailed diagnostic information for debugging un-serializable properties.
  • Automatic Query Parameter Type Coercion:
    • HTTP query schemas evaluated with tex.number() and tex.boolean() automatically coerce incoming string query values (e.g., ?limit=100&active=true) into native numbers (100) and booleans (true), eliminating manual string parsing in route handlers.
  • Standardized Error Response Envelope:
    • Standardized framework error responses (HttpError, validation failures, authentication guard rejections) into a consistent JSON envelope: { success: false, statusCode, error, message, validationErrors, errors, timestamp }.
  • Smart ETag Disabling on Dynamic API Routes:
    • Defaulted etag: false in exis.config.ts for dynamic REST endpoints, eliminating redundant SHA-1 hashing CPU overhead and eliminating confusing 304 response timings in dev logs while keeping ETags configurable globally or per-route.
  • Reverse Proxy & Multi-CDN Client IP Header Resolution:
    • Enhanced req.ip evaluation to prioritize CF-Connecting-IP, True-Client-IP, X-Real-IP, and X-Client-IP before X-Forwarded-For when trustProxy: true (or process.env.TRUST_PROXY === 'true'), ensuring rate limiters and IP filters identify real client IPs behind Cloudflare, AWS ALB, NGINX, and Render.
  • Test Harness Client Enhancements:
    • Updated createTestApp client HTTP methods (client.get, client.post, etc.) to accept optional request options (e.g. custom headers like client.get('/ledger', { headers: { 'if-none-match': '"etag"' } })).

Key Improvements & Details

1. Automatic Parameter Type Reflection & DI Auto-Resolution

import { Controller, Get, Param } from 'exisjs/decorators'
import { UserService } from './user.service'

@Controller('/users')
export default class UserController {
  // No @Inject() boilerplate required! Auto-resolved via design:paramtypes + INJECTABLE_REGISTRY
  constructor(private readonly userService: UserService) {}

  @Get('/:id')
  async getUser(@Param('id') id: string) {
    return this.userService.findById(id)
  }
}

2. Built-in Safe Response Serializer (Mongoose & BSON)

import { Controller, Get } from 'exisjs/decorators'
import { UserModel } from './user.model'

@Controller('/users')
export default class UserController {
  @Get('/active')
  async getActiveUsers() {
    // Automatically unwrapped via .toObject() and ObjectIds converted to strings!
    // No .lean() or manual mapping needed.
    return UserModel.find({ isActive: true })
  }
}

3. Automatic Query Type Coercion

import { Controller, Get, Query } from 'exisjs/decorators'
import { tex, type ResolveSchema } from 'exisjs/validator'

export const ListQuerySchema = tex.object({
  page: tex.number({ default: 1 }),
  limit: tex.number({ default: 20 }),
  active: tex.boolean({ optional: true }),
})

export type ListQueryDto = ResolveSchema<typeof ListQuerySchema>

@Controller('/items')
export default class ItemController {
  @Get('/', { query: ListQuerySchema })
  async listItems(@Query() query: ListQueryDto) {
    // query.limit is number (100), query.active is boolean (true)
    return { query }
  }
}

4. Standardized Error Response Envelope

{
  "success": false,
  "statusCode": 400,
  "error": "Bad Request",
  "message": "Validation Error: limit: Must be a number",
  "validationErrors": {
    "limit": "Must be a number"
  },
  "errors": {
    "limit": "Must be a number"
  },
  "timestamp": "2026-09-27T10:11:42.000Z"
}

5. Multi-CDN & Reverse Proxy Client IP Resolution

import { defineConfig } from 'exisjs/config'

export default defineConfig({
  // Evaluates CF-Connecting-IP, True-Client-IP, X-Real-IP, and X-Forwarded-For
  trustProxy: true,
  etag: false, // Smart ETag default for mutable REST APIs
})

Full Changelog: v0.7.9...v0.7.10