Skip to content

Commit

Permalink
feat: v1.0.0 (#4)
Browse files Browse the repository at this point in the history
* yay!
  • Loading branch information
Bugs5382 committed Dec 30, 2023
2 parents 36b35d9 + b772290 commit 3a1b01d
Show file tree
Hide file tree
Showing 32 changed files with 1,433 additions and 138 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
jest.config.ts
release.config.js
/__tests__/**/*
release.config.cjs
4 changes: 0 additions & 4 deletions .github/release-drafter.yml

This file was deleted.

31 changes: 20 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
name: GitHub CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
branches: [ 'main', 'develop' ]

jobs:
Test:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
strategy:
matrix:
node-version: [ 18.x, 20.x, 'lts/*' ]
Expand All @@ -23,14 +26,14 @@ jobs:
run: npm install --ignore-scripts
- name: Run Unit Tests
run: npm run test:ci
- name: Release Drafter
uses: release-drafter/release-drafter@v5.9.0
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
Release:
runs-on: ubuntu-latest
needs: [ test ]
needs: [ 'Test' ]
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -39,9 +42,15 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- run: npm install
- name: NPM Install
run: npm install --ignore-scripts
- name: Semantic Release (Dry Run)
run: npm run semantic-release:dry-run
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Semantic Release
run: npm run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,4 @@ package-lock.json

# Webstorm
.idea
lib
16 changes: 0 additions & 16 deletions .npmignore

This file was deleted.

52 changes: 52 additions & 0 deletions .npmpackagejsonlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"rules": {
"require-author": "error",
"require-description": "error",
"require-engines": "error",
"require-license": "error",
"require-name": "error",
"require-repository": "error",
"require-version": "error",
"require-bugs": "error",
"require-homepage": "error",
"require-keywords": "error",
"bin-type": "error",
"config-type": "error",
"description-type": "error",
"devDependencies-type": "error",
"directories-type": "error",
"engines-type": "error",
"files-type": "error",
"homepage-type": "error",
"keywords-type": "error",
"license-type": "error",
"main-type": "error",
"man-type": "error",
"name-type": "error",
"preferGlobal-type": "error",
"private-type": "error",
"repository-type": "error",
"scripts-type": "error",
"version-type": "error",
"valid-values-author": ["error", [
"Shane Froebel"
]],
"valid-values-private": ["error", [
false
]],
"no-restricted-dependencies": ["error", [
"gulping-npm-package-json-lint"
]],
"no-restricted-pre-release-dependencies": ["error", [
"gulping-npm-package-json-lint"
]],
"no-restricted-devDependencies": ["error", [
"gulping-npm-package-json-lint"
]],
"no-restricted-pre-release-devDependencies": ["error", [
"gulping-npm-package-json-lint"
]],
"name-format": "error",
"version-format": "error"
}
}
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# [1.0.0-beta.2](https://github.com/Bugs5382/fastify-hl7/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2023-12-30)


### Features

* added functions that get ([c68830e](https://github.com/Bugs5382/fastify-hl7/commit/c68830ed6397d1bb71ad6a7720e92eaafca8e2ce))
* added functions that get ([#3](https://github.com/Bugs5382/fastify-hl7/issues/3)) ([d94ea96](https://github.com/Bugs5382/fastify-hl7/commit/d94ea96c63726c8b6e79d52df1fb48414b1e1138))

# 1.0.0-beta.1 (2023-12-29)


### Bug Fixes

* removed .npmignore ([bd788da](https://github.com/Bugs5382/fastify-hl7/commit/bd788dad661f7f4e271458d5b633280a9d561fef))


### Features

* added in ([3c340d5](https://github.com/Bugs5382/fastify-hl7/commit/3c340d59ac2861bbf58c90acb28615914410b3ca))
* buildMessage, publishMessage ([fc1d7db](https://github.com/Bugs5382/fastify-hl7/commit/fc1d7db9968030247c518817ce5a6c8f231fa91d))
* client stuff done ([bd6cb46](https://github.com/Bugs5382/fastify-hl7/commit/bd6cb464ad45833b0c3df2623db22ff5737a36ba))
* develop branch for release ([28c5f30](https://github.com/Bugs5382/fastify-hl7/commit/28c5f30f01a88cbec9b04b37b1aadf7ed959a369))
* first working version ([f9d3ffd](https://github.com/Bugs5382/fastify-hl7/commit/f9d3ffd660c9802778adb9732d6e3587be109139))
* fixed client connections ([c421328](https://github.com/Bugs5382/fastify-hl7/commit/c4213281c43f8ee7655f4e6c88cf0d0ad15e8d3b))
* full example ([7c36b2d](https://github.com/Bugs5382/fastify-hl7/commit/7c36b2d02c65a05050ec44889f8745a2c61ede62))
* initial build ([36b35d9](https://github.com/Bugs5382/fastify-hl7/commit/36b35d904231507b6a6004bda4a5f07c2d224233))
* new design, again. ([2113ca3](https://github.com/Bugs5382/fastify-hl7/commit/2113ca3183d91a085791a067e2af6fc69d305aba))
* registration working ([6f54019](https://github.com/Bugs5382/fastify-hl7/commit/6f54019a66aa5c24ec1d7ce3130475ef6b602426))
* release branch for release ([c85e0be](https://github.com/Bugs5382/fastify-hl7/commit/c85e0bec4fbb6019d460e0b5743292e58097cb41))
* standardized project ([dec9a8b](https://github.com/Bugs5382/fastify-hl7/commit/dec9a8b35af1ab60bb44c709e02472911788e99f))
* standardized project ([#1](https://github.com/Bugs5382/fastify-hl7/issues/1)) ([42b973f](https://github.com/Bugs5382/fastify-hl7/commit/42b973f1680c5dcce0296cd7fb1a11b80dc9920c))
* update server signatures ([d1fc0da](https://github.com/Bugs5382/fastify-hl7/commit/d1fc0dad4c3ca5dbfa40b4850cd092f43a82e3d8))
122 changes: 122 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Fastify HL7

A Fastify Hl7 Plugin Developed in Pure TypeScript.
It uses the [node-hl7-client](https://github.com/Bugs5382/node-hl7-client) and [node-hl7-server](https://github.com/Bugs5382/node-hl7-server) plugin as a wrapper.

The build exports this to valid ESM and CJS for ease of cross-compatibility.

If you are using this NPM package, please consider giving it a :star: star.
This will increase its visibility and solicit more contribution from the outside.

This documentation is how to use this plugin, not on how to use the libraries above.
Head [here](#external-libraries) if you need help with those.

## Table of Contents

1. [Install](#install)
2. [Basic Usage](#basic-usage)
1. [Server Quick Start](#server-quick-start)
2. [Client Quick Start](#client-quick-start)
3. [Full Documentation](#full-documentation)
1. [This Library Options](#this-library-options)
2. [External Libraries](#external-libraries)
4. [Acknowledgements](#acknowledgements)
5. [License](#license)

## Install

```
npm install fastify-hl7
```

## Basic Usage

Register this as a plugin.

```ts
await fastify.register(fastifyHL7)
```

### Server Quick Start

```ts
const listener = fastify.hl7.createInbound(
'ib_adt',
{port: 3001},
async (req, res) => {
const messageReq = req.getMessage()
const messageType = req.getType()
// your logic here
await res.sendResponse('AA')
})
```
This will create a inbound connection. You can optionally return it to a variable to attach advanced listeners.

### Client Quick Start

```ts
import fastify from "fastify";

fastify.hl7.createClient('localhost', {host: '0.0.0.0'})
```

This will create a "client" class that will then allow you to attach different outbound connections.
The name ```localhost``` in a unique identifier to this host, so it can be used to attach different outbound connections to this server/broker.

There might be times when your HL7 messages need to cross-over to different hosts/server/inbound endpoints and this is how you would get them.

Within your code now you can use the fastify context and access the ```hl7``` decorator,
and create an outbound connection.

```ts
const client = fastify.hl7.createOutbound(
'ob_adt',
{port: 3001},
async (res) => {
const messageRes = res.getMessage()
// Your code here. Either a failure or a success, but still do your work here.
})

// building a HL7 Message Segment
const message = app.hl7.buildMessage({
messageHeader: {
msh_9_1: "ADT",
msh_9_2: "A01",
msh_11_1: "D",
}
})

await client.sendMessage(message)
```

## Full Documentation

### This Library Options

### `enableServer`

If this is not set, enableServer will be set to ```true```. You need to set this to ```false``` will turn off the server capabilities.


### ```serverOptions```

Set this using the options from the [node-hl7-serer](https://github.com/Bugs5382/node-hl7-server/blob/main/README.md) library ServerOptions values to override server creation.
This could be enabling IPv4 or IPv6 and other server options including TLS. SInce you can not set this after run time, it has to be set during registration.



### External Libraries

* [node-hl7-client](https://github.com/Bugs5382/node-hl7-client/blob/main/README.md) - For the Client, Parser, and Builder to review their options that can be passed as props.
* [node-hl7-server](https://github.com/Bugs5382/node-hl7-server/blob/main/README.md) - For the Server to the options that can be passed as props.

Please review the library for more complete documentation.
A far as this plugin for Fastify, there are no options to pass.

## Acknowledgements

- My Wife and Baby Girl.

## License

Licensed under [MIT](./LICENSE).
1 change: 1 addition & 0 deletions __tests__/__hl7__/hl7.readFileTestMSH.20081231.hl7
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FHS|^~\&|||||20081231||hl7.readFileTestMSH.20081231.hl7||12345MSH|^~\&|||||20081231||ADT^A01^ADT_A01|12345|D|2.7EVN||20081231FTS|1
Expand Down
18 changes: 9 additions & 9 deletions __tests__/__utils__/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* istanbul ignore next */
import EventEmitter from "node:events";
import EventEmitter from 'node:events'

export function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms))
export async function sleep (ms: number): Promise<any> {
return await new Promise(resolve => setTimeout(resolve, ms))
}

export interface Deferred<T=any> {
Expand All @@ -11,19 +11,19 @@ export interface Deferred<T=any> {
promise: Promise<T>
}

export function createDeferred<T=any>(noUncaught?: boolean): Deferred<T> {
let dfd: any = {}
export function createDeferred<T=any> (noUncaught?: boolean): Deferred<T> {
const dfd: any = {}
dfd.promise = new Promise((resolve, reject) => {
dfd.resolve = resolve
dfd.reject = reject
})
/* istanbul ignore next */
if (noUncaught) {
if (noUncaught) { // eslint-disable-line
dfd.promise.catch(() => {})
}
return dfd
}

export function expectEvent<T=any>(emitter: EventEmitter, name: string|symbol): Promise<T> {
return new Promise<T>((resolve) => { emitter.once(name, resolve) })
}
export async function expectEvent<T=any> (emitter: EventEmitter, name: string | symbol): Promise<T> {
return await new Promise<T>((resolve) => { emitter.once(name, resolve) })
}
Loading

0 comments on commit 3a1b01d

Please sign in to comment.