@json-express/transport-express
v2.0.0
Published
Express.js transport plugin for JSON Express
Maintainers
Readme
@json-express/transport-express
The official Express.js transport layer for JSONExpress.
This plugin binds the agnostic API routes generated by JSONExpress to an Express.js web server. It is included by default when you use the @json-express/cli, but can also be installed and configured manually for custom setups.
📦 Installation
If you are customizing your JSONExpress stack locally:
npm install @json-express/transport-express🚀 Usage
With Auto-Discovery (CLI)
If you are using the JSONExpress CLI, simply installing this package is enough. The CLI will automatically discover it, register it with the Microkernel, and boot the server.
Programmatic Usage
If you are building a custom Node.js script using the JSONExpress Core:
import { JsonExpressKernel } from '@json-express/core';
import { ExpressTransport } from '@json-express/transport-express';
const kernel = new JsonExpressKernel();
const transport = new ExpressTransport();
kernel.registerTransport(transport);
// ... register other plugins
await kernel.boot(['users', 'posts']);⚙️ Configuration Options
You can configure this plugin using your .env file (via config-env) or a jex.config.* file (via advanced config).
Using .env
Remember to use the jex_ or JEX_ prefix. Dots (.) denote nested objects, and underscores (_) are used for multi-word keys.
Using .env
Remember to use the jex. or JEX. namespace prefix. Dots (.) denote nested objects, and underscores (_) are used for multi-word keys.
Automated Access Logging & Tracing
The Express transport now automatically performs post-response access logging using the framework's configured logger.
- It generates a unique
traceIdviaAsyncLocalStoragefor every request. - It logs the method, path, status code, and latency (in ms) once the request is complete.
- No configuration required. The old
jex.transport.express.loggerflag has been deprecated and superseded by this automated behavior.
Other Options
# Change the default server port (default: 3000)
jex.port=8080
# Enable trust proxy for load balancers (default: false)
jex.transport.express.trust_proxy=trueUsing jex.config.json
{
"transport": {
"express": {
"port": 8080,
"trust_proxy": true
}
}
}