Getting Started
Create a Glion app, run it locally, and process your first HL7v2 message.
Quick Start
- Create a new Glion app with the CLI.
cd my-app.- Start the dev server. The server is now waiting for MLLP traffic on
127.0.0.1:2575.
npm create glion@latest my-app
cd my-app
npm run devpnpm create glion my-app
cd my-app
pnpm devyarn create glion my-app
cd my-app
yarn devbun create glion my-app
cd my-app
bun --bun run dev- Open another terminal and send your first message.
printf '\x0bMSH|^~\&|SENDER|SENDER|GLION|NODE|20260509120000||ADT^A01|MSG001|P|2.5.1\rEVN||20260509120000\rPID|||123456^^^MRN||Doe^John\r\x1c\x0d' \
| nc 127.0.0.1 2575That's a working MLLP server. nc is fine for one-off pokes; for a typed client with NAK handling, TLS, and Cloudflare Workers support, see Sending HL7v2 messages.
System requirements
Before you begin, make sure your development environment meets the following requirements:
- Minimum Node.js version: 20.x
- Operating systems: macOS, Windows (including WSL), and Linux.
Manual installation
To manually create a new Glion app, install the required packages:
npm install @glion/cli @glion/mllp @glion/mllp-ack @glion/hl7v2 @glion/ackpnpm add @glion/cli @glion/mllp @glion/mllp-ack @glion/hl7v2 @glion/ackyarn add @glion/cli @glion/mllp @glion/mllp-ack @glion/hl7v2 @glion/ackbun add @glion/cli @glion/mllp @glion/mllp-ack @glion/hl7v2 @glion/ackCreate the Glion configuration
- Create a new file
glion.config.tswith the following content:
import { defineConfig } from "@glion/cli/config";
export default defineConfig({
entry: "./src/app.ts",
port: 2575,
});- Add the following scripts to your package.json file:
{
"scripts": {
"dev": "glion dev",
"start": "glion start"
}
}These scripts refer to the different stages of developing an application:
glion dev: Starts the development server using ourmllp-serverimplementation. It watches for file changes and automatically restarts the server, providing a smooth development experience with hot reloading and detailed error messages.glion start: Starts the production server.
Create the router
- Create a new directory
srcin the root of your project. This is where you will write your Glion application code. - Create a new file
src/app.ts. This is the root router of your application, where you will define your routes and middleware. It must export a defaultMllpinstance.
import { UnsupportedMessageTypeReject } from "@glion/ack";
import { parseHL7v2 } from "@glion/hl7v2";
import { Mllp } from "@glion/mllp";
import { ackMiddleware } from "@glion/mllp-ack";
const app = new Mllp();
app.parser(parseHL7v2);
// Turn handler return values into AA ACKs and throws into the matching NAK.
app.use(ackMiddleware());
// One route: accept ADT^A01 (patient admit).
app.on("ADT^A01", () => {
// Returning normally produces an AA (Application Accept) ACK.
});
// Catch-all — reject anything else with an AR NAK.
app.on("*", (ctx) => {
throw new UnsupportedMessageTypeReject(
`Unsupported message type: ${ctx.messageType}^${ctx.triggerEvent}`
);
});
export default app;Run the development server
- Run
npm run devto start the development server. - The server is now waiting for MLLP traffic on
127.0.0.1:2575. - Edit the
src/app.tsfile and save it to see the server automatically restart with your changes.
You have a working MLLP server! Next, send your first message to see it in action. You can use nc or any MLLP client to send a message to 127.0.0.1:2575. For a typed client with NAK handling, TLS, etc., see Sending HL7v2 messages.