Skip to content

Commit

Permalink
feat: simple docker (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bugs5382 authored Feb 4, 2024
2 parents e5accf0 + 38d13ae commit 93928ec
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions .npmpackagejsonlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"Shane Froebel"
]],
"valid-values-private": ["error", [
true,
false
]],
"no-restricted-dependencies": ["error", [
Expand Down
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:20.11.0-alpine3.19

# set working directory in the image
WORKDIR /home/node/app

## copy over server
COPY docker .

## Run
RUN npm install
RUN npm i node-hl7-server

# EXPOSE
EXPOSE 3000

# COMMAND
CMD ["npm", "run", "server"]
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ Then you can query the segment ```MSH.12``` in this instance and get its result.

Please consult [node-hl7-client](https://www.npmjs.com/package/node-hl7-client) documentation for further ways to parse the message segment.

## Docker

```
npm run docker:build
```

This package, if you download from source,
comes with a DockerFile to build a simple docker image with a basic node-hl7-server running.
All the server does is respond "success" to all properly formatted HL7 messages.

If you want more a custom instance of this server, download the GIT,
and modify ```docker/server.js``` to your liking and then build the docker image and run it.

Suggestions? Open a PR!

## Acknowledgements

- Code Design/Auto Re-Connect/Resend, Inspiration: [node-rabbitmq-client](https://github.com/cody-greene/node-rabbitmq-client)
Expand Down
32 changes: 32 additions & 0 deletions docker/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "docker-hl7-server",
"version": "1.0.0",
"main": "server.js",
"private": true,
"scripts": {
"server": "node server.js"
},
"description": "Simple Server running on Docker",
"author": "Shane Froebel",
"license": "MIT",
"bugs": {
"url": "https://github.com/Bugs5382/node-hl7-server/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Bugs5382/node-hl7-server.git"
},
"keywords": [
"hl7",
"hl7-parser",
"hl7-client",
"hl7-server",
"hl7-builder",
"hl7-speffications",
"hl7-validation"
],
"engines": {
"node": ">=20.0.0"
},
"homepage": "https://github.com/Bugs5382/node-hl7-server#readme"
}
23 changes: 23 additions & 0 deletions docker/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { Server } = require('node-hl7-server')

const server = new Server({ bindAddress: 'localhost' })

const inbound = server.createInbound({ port: 3000 }, async (req, res) => {
await res.sendResponse('AA')
})

inbound.on('client.close', () => {
console.log('Client Disconnected')
})

inbound.on('client.connect', () => {
console.log('Client Connected')
})

inbound.on('data.raw', (data) => {
console.log('Raw Data:', data)
})

inbound.on('listen', () => {
console.log('Ready to Listen for Messages')
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"clean": "rm -rf coverage docs lib temp",
"build": "tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && tsc -p tsconfig.types.json && ./bin/build-types.sh",
"build:watch": "tsc -p tsconfig.esm.json -w",
"docker:build": "docker build -t docker-hl7-server:latest .",
"npm:lint": "npmPkgJsonLint .",
"lint": "npm run npm:lint && ts-standard | snazzy",
"lint:fix": "npm run npm:lint . && ts-standard --fix | snazzy",
Expand Down

0 comments on commit 93928ec

Please sign in to comment.