@json-express/transport-express
Official Express.js transport for JSONExpress.
The @json-express/transport-express package acts as the bridge between the internal JSONExpress routing engine and the external network. It implements the ITransport interface, translating abstract RouteDefinition objects generated by the API Generators into real express.js routes.
Because JSONExpress isolates its core logic from the network layer, you never have to deal with raw req and res objects unless you want to.
Installation
npm install @json-express/transport-express expressConfiguration
The transport is auto-discovered by the json-express runtime — installing the package is enough. It is the default transport shipped with @json-express/boot.
npm install @json-express/transport-express express
npx json-expressThe default port is 3000; override via jex.port. If both transport-express and transport-fastify are installed, pick one explicitly:
jex.port=8080
jex.transport=@json-express/transport-expressCore Features
1. Abstracted Request Handling
This transport automatically handles all JSON body parsing (express.json()). More importantly, it wraps every incoming request in a unified JsonRequest and JsonResponse interface. This allows JSONExpress plugins to function identically whether you are using Express, Fastify, or a Serverless function.
2. Request Tracing & Logging
Enterprise applications require traceability. When an HTTP request enters the ExpressTransport, the transport automatically:
- Generates a unique UUID
traceId. - Wraps the entire request execution inside Node.js
AsyncLocalStorage. - Ensures that any internal logs generated during the request (e.g. database queries, validation errors) are automatically stamped with that
traceId. - Outputs a standardized post-response access log (e.g.,
GET /albums 200 (15ms)).
3. Native HTTPS / SSL Support
If you are developing locally and want to test secure cookies or webhook integrations, you can mount an SSL key/cert directly into the transport without a reverse proxy. The simplest path is to install @json-express/plugin-devcert, which generates a locally-trusted certificate and injects it into express.ssl automatically.
To pin your own files, set their paths through the config provider in jex.config.ts (file paths cannot be expressed as plain .env strings):
// jex.config.ts
import fs from 'fs';
export default {
express: {
ssl: {
key: fs.readFileSync('./cert.key'),
cert: fs.readFileSync('./cert.crt')
}
}
};When express.ssl is present, the transport boots an https.createServer instead of plain HTTP.
4. Standardized Error Formats
This transport registers centralized 404 and 500 error handlers at the very bottom of the middleware stack. This guarantees that unhandled exceptions from custom endpoints never crash the server, and always return a strictly formatted JSON response back to the client.
Related Ecosystem Packages
- @json-express/transport-fastify: Want higher throughput? Swap to Fastify without rewriting any of your application code!
- @json-express/plugin-devcert: Automatically generates local SSL certificates and injects them into the
express.sslconfiguration block!