fastify-hl7 2.1.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,7 +9,7 @@ If you are using this NPM package, please consider giving it a :star: star.
9
9
  This will increase its visibility and solicit more contribution from the outside.
10
10
 
11
11
  This documentation is how to use this plugin, not on how to use the libraries above.
12
- Head [here](#external-libraries) if you need help with those.
12
+ Head [here](#external-libraries-options) if you need help with those.
13
13
 
14
14
  ## Table of Contents
15
15
 
@@ -19,7 +19,7 @@ Head [here](#external-libraries) if you need help with those.
19
19
  2. [Client Quick Start](#client-quick-start)
20
20
  3. [Full Documentation](#full-documentation)
21
21
  1. [This Library Options](#this-library-options)
22
- 2. [External Libraries](#external-libraries)
22
+ 2. [External Libraries Options](#external-libraries-options)
23
23
  4. [Acknowledgements](#acknowledgements)
24
24
  5. [License](#license)
25
25
 
@@ -97,19 +97,17 @@ await client.sendMessage(message)
97
97
 
98
98
  If this is not set, enableServer will be set to ```true```. You need to set this to ```false``` will turn off the server capabilities.
99
99
 
100
-
101
100
  ### ```serverOptions```
102
101
 
103
102
  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.
104
103
  This could be enabling IPv4 or IPv6 and other server options including TLS. Since you cannot set this after run time, it has to be set during registration.
105
104
 
106
- ### External Libraries
105
+ ### External Libraries Options
107
106
 
108
107
  * [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.
109
108
  * [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.
110
109
 
111
- Please review the library for more complete documentation.
112
- A far as this plugin for Fastify, there are no options to pass.
110
+ Please review the libraries for more complete documentation.
113
111
 
114
112
  ## Acknowledgements
115
113
 
package/lib/cjs/api.js CHANGED
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.HL7Server = exports.HL7Client = exports.fastifyHL7 = void 0;
7
- var _1 = __importDefault(require("."));
7
+ const _1 = __importDefault(require("."));
8
8
  exports.fastifyHL7 = _1.default;
9
- var hL7Client_js_1 = require("./class/hL7Client.js");
9
+ const hL7Client_js_1 = require("./class/hL7Client.js");
10
10
  Object.defineProperty(exports, "HL7Client", { enumerable: true, get: function () { return hL7Client_js_1.HL7Client; } });
11
- var hL7Server_js_1 = require("./class/hL7Server.js");
11
+ const hL7Server_js_1 = require("./class/hL7Server.js");
12
12
  Object.defineProperty(exports, "HL7Server", { enumerable: true, get: function () { return hL7Server_js_1.HL7Server; } });
13
13
  exports.default = _1.default;
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
3
  if (k2 === undefined) k2 = k;
15
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -33,132 +22,84 @@ var __importStar = (this && this.__importStar) || function (mod) {
33
22
  __setModuleDefault(result, mod);
34
23
  return result;
35
24
  };
36
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
- return new (P || (P = Promise))(function (resolve, reject) {
39
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
- step((generator = generator.apply(thisArg, _arguments || [])).next());
43
- });
44
- };
45
- var __generator = (this && this.__generator) || function (thisArg, body) {
46
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
- function verb(n) { return function (v) { return step([n, v]); }; }
49
- function step(op) {
50
- if (f) throw new TypeError("Generator is already executing.");
51
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
52
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
53
- if (y = 0, t) op = [op[0] & 2, t.value];
54
- switch (op[0]) {
55
- case 0: case 1: t = op; break;
56
- case 4: _.label++; return { value: op[1], done: false };
57
- case 5: _.label++; y = op[1]; op = [0]; continue;
58
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
- default:
60
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
- if (t[2]) _.ops.pop();
65
- _.trys.pop(); continue;
66
- }
67
- op = body.call(thisArg, _);
68
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
- }
71
- };
72
25
  Object.defineProperty(exports, "__esModule", { value: true });
73
26
  exports.HL7Client = void 0;
74
- var node_hl7_client_1 = __importStar(require("node-hl7-client"));
75
- var errors_js_1 = require("../errors.js");
76
- var HL7Client = /** @class */ (function () {
77
- function HL7Client() {
27
+ const node_hl7_client_1 = __importStar(require("node-hl7-client"));
28
+ const errors_js_1 = require("../errors.js");
29
+ class HL7Client {
30
+ constructor() {
78
31
  this._clientConnections = [];
79
32
  }
80
33
  /**
81
34
  * Close All Connections for this Client
82
35
  * @since 1.0.0
83
36
  */
84
- HL7Client.prototype.closeAll = function () {
85
- return __awaiter(this, void 0, void 0, function () {
86
- var _this = this;
87
- return __generator(this, function (_a) {
88
- this._clientConnections.forEach(function (outbound) {
89
- outbound.ports.map(function (port) { return __awaiter(_this, void 0, void 0, function () {
90
- return __generator(this, function (_a) {
91
- switch (_a.label) {
92
- case 0: return [4 /*yield*/, port.connection.close()];
93
- case 1:
94
- _a.sent();
95
- return [2 /*return*/];
96
- }
97
- });
98
- }); });
99
- });
100
- return [2 /*return*/, true];
37
+ async closeAll() {
38
+ this._clientConnections.forEach(outbound => {
39
+ outbound.ports.map(async (port) => {
40
+ await port.connection.close();
101
41
  });
102
42
  });
103
- };
43
+ return true;
44
+ }
104
45
  /**
105
46
  * Build a HL7 Batch
106
- * @description Create a properly formatted HL7 Batch.
47
+ *@remarks Create a properly formatted HL7 Batch.
107
48
  * @since 1.0.0
108
49
  * @param props
109
50
  */
110
- HL7Client.prototype.buildBatch = function (props) {
51
+ buildBatch(props) {
111
52
  if (typeof props !== 'undefined' && typeof props.text !== 'undefined') {
112
53
  throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('Use processMessage method. This is for building.');
113
54
  }
114
- return new node_hl7_client_1.Batch(__assign({}, props));
115
- };
55
+ return new node_hl7_client_1.Batch({ ...props });
56
+ }
116
57
  /**
117
58
  * Build Date
118
- * @description Build a date string based off HL7 Standards
59
+ *@remarks Build a date string based off HL7 Standards
119
60
  * @since 2.1.0
120
61
  * @param date
121
62
  * @param length Options are 8, 12, or 14 (default)
122
63
  */
123
- HL7Client.prototype.buildDate = function (date, length) {
64
+ buildDate(date, length) {
124
65
  return (0, node_hl7_client_1.createHL7Date)(date, length);
125
- };
66
+ }
126
67
  /**
127
68
  * Build a HL7 File Batch
128
- * @description Create a properly formatted HL7 File Batch.
69
+ *@remarks Create a properly formatted HL7 File Batch.
129
70
  * @since 1.0.0
130
71
  * @param props
131
72
  */
132
- HL7Client.prototype.buildFileBatch = function (props) {
73
+ buildFileBatch(props) {
133
74
  if (typeof props !== 'undefined' && (typeof props.fullFilePath !== 'undefined' || typeof props.fileBuffer !== 'undefined')) {
134
75
  throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('Use readFile or readFileBuffer method. This is for building.');
135
76
  }
136
- return new node_hl7_client_1.FileBatch(__assign({}, props));
137
- };
77
+ return new node_hl7_client_1.FileBatch({ ...props });
78
+ }
138
79
  /**
139
80
  * Build a HL7 Message
140
- * @description Create a properly formatted HL7 message.
81
+ *@remarks Create a properly formatted HL7 message.
141
82
  * @since 1.0.0
142
83
  * @param props
143
84
  */
144
- HL7Client.prototype.buildMessage = function (props) {
85
+ buildMessage(props) {
145
86
  if (typeof props !== 'undefined' && typeof props.text !== 'undefined') {
146
87
  throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('Use processMessage method. This is for building.');
147
88
  }
148
- return new node_hl7_client_1.Message(__assign({}, props));
149
- };
89
+ return new node_hl7_client_1.Message({ ...props });
90
+ }
150
91
  /**
151
92
  *
152
93
  * @param name
153
94
  * @param props
154
95
  */
155
- HL7Client.prototype.createClient = function (name, props) {
156
- var nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
96
+ createClient(name, props) {
97
+ const nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
157
98
  if (nameFormat.test(name)) {
158
99
  throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};\':"\\\\|,.<>\\/?~.');
159
100
  }
160
101
  // make sure that this does not exist already...
161
- this._clientConnections.forEach(function (connections) {
102
+ this._clientConnections.forEach((connections) => {
162
103
  if (connections.name === name) {
163
104
  throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('name must be unique.');
164
105
  }
@@ -168,116 +109,115 @@ var HL7Client = /** @class */ (function () {
168
109
  // }
169
110
  });
170
111
  // new client
171
- var client = new node_hl7_client_1.default(props);
112
+ const client = new node_hl7_client_1.default(props);
172
113
  // add it to the collection
173
114
  this._clientConnections.push({
174
- name: name,
175
- client: client,
115
+ name,
116
+ client,
176
117
  ports: []
177
118
  });
178
119
  return client;
179
- };
120
+ }
180
121
  /**
181
122
  * Create an HL7 Outbound Connection
182
- * @description Connect to an HL7 Server/Broker
123
+ *@remarks Connect to an HL7 Server/Broker
183
124
  * @since 1.0.0
184
125
  * @param name The name stored within created client connections.
185
126
  * @param props
186
127
  * @param handler
187
128
  */
188
- HL7Client.prototype.createConnection = function (name, props, handler) {
189
- var nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
129
+ createConnection(name, props, handler) {
130
+ const nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
190
131
  if (nameFormat.test(name)) {
191
132
  throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};\':"\\\\|,.<>\\/?~.');
192
133
  }
193
- var getConnection = this._clientConnections.find(function (client) { return client.name === name; });
134
+ const getConnection = this._clientConnections.find(client => client.name === name);
194
135
  if (typeof getConnection !== 'undefined') {
195
136
  // make sure port is not used all ready
196
- getConnection.ports.forEach(function (outbound) {
137
+ getConnection.ports.forEach((outbound) => {
197
138
  if (outbound.port === props.port.toString()) {
198
- throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("port ".concat(props.port, " is already used with this client. Choose a new outgoing port."));
139
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(`port ${props.port} is already used with this client. Choose a new outgoing port.`);
199
140
  }
200
141
  });
201
142
  // create outbound port to the server in getConnection.client
202
- var outbound = new node_hl7_client_1.Connection(getConnection.client, props, handler);
143
+ const outbound = new node_hl7_client_1.Connection(getConnection.client, props, handler);
203
144
  // add it to the array of known ports. need to know this, so we can get it later if needed.
204
145
  getConnection.ports.push({ port: props.port.toString(), connection: outbound });
205
146
  // return it right away. the user might do something with it.
206
147
  return outbound;
207
148
  }
208
149
  throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('No valid client. Improper setup of a outbound connection.');
209
- };
150
+ }
210
151
  /**
211
152
  * Get Client by the name
212
153
  * @since 1.0.0
213
154
  * @param name
214
155
  */
215
- HL7Client.prototype.getClientByName = function (name) {
216
- var connection = this._clientConnections.find(function (connection) { return connection.name === name; });
156
+ getClientByName(name) {
157
+ const connection = this._clientConnections.find(connection => connection.name === name);
217
158
  if (typeof connection !== 'undefined') {
218
159
  return connection.client;
219
160
  }
220
161
  return undefined;
221
- };
162
+ }
222
163
  /**
223
164
  * Get Connection by Port
224
165
  * @since 1.0.0
225
166
  * @param port
226
167
  */
227
- HL7Client.prototype.getClientConnectionByPort = function (port) {
228
- var connection;
229
- this._clientConnections.forEach(function (outbound) {
230
- outbound.ports.forEach(function (aPort) {
168
+ getClientConnectionByPort(port) {
169
+ let connection;
170
+ this._clientConnections.forEach(outbound => {
171
+ outbound.ports.forEach(aPort => {
231
172
  if (aPort.port === port) {
232
173
  connection = aPort.connection;
233
174
  }
234
175
  });
235
176
  });
236
177
  return connection;
237
- };
178
+ }
238
179
  /**
239
180
  * Process a HL7
240
- * @description A HL7 message that could either be a Message (MSH) or Batch (BHS)
181
+ *@remarks A HL7 message that could either be a Message (MSH) or Batch (BHS)
241
182
  * @since 1.0.0
242
183
  * @param text Raw HL& String
243
184
  */
244
- HL7Client.prototype.processHL7 = function (text) {
185
+ processHL7(text) {
245
186
  if ((0, node_hl7_client_1.isBatch)(text)) {
246
- return new node_hl7_client_1.Batch({ text: text });
187
+ return new node_hl7_client_1.Batch({ text });
247
188
  }
248
189
  else {
249
- return new node_hl7_client_1.Message({ text: text });
190
+ return new node_hl7_client_1.Message({ text });
250
191
  }
251
- };
192
+ }
252
193
  /**
253
194
  * Read File
254
- * @description Pass the correct path of the file you want to read.
195
+ *@remarks Pass the correct path of the file you want to read.
255
196
  * @since 1.0.0
256
197
  * @param fullFilePath
257
198
  * @returns FileBatch
258
199
  * @example
259
- *
200
+ * ```ts
260
201
  * fastify.hl7.readFile( path.join('temp/', 'hl7.readTestBHS.20231208.hl7') )
261
- *
202
+ * ```
262
203
  */
263
- HL7Client.prototype.readFile = function (fullFilePath) {
264
- return new node_hl7_client_1.FileBatch({ fullFilePath: fullFilePath });
265
- };
204
+ readFile(fullFilePath) {
205
+ return new node_hl7_client_1.FileBatch({ fullFilePath });
206
+ }
266
207
  /**
267
208
  * Read a File Buffer
268
- * @description Translate an already Buffered HL7 FHS segment to decode it.
209
+ *@remarks Translate an already Buffered HL7 FHS segment to decode it.
269
210
  * @since 1.0.0
270
211
  * @param fileBuffer
271
212
  * @returns FileBatch
272
213
  * @example
273
- *
214
+ * ```ts
274
215
  * const fileBuffer = fs.readFileSync(path.join('temp/', 'hl7.readTestBHS.20231208.hl7'))
275
216
  * fastify.hl7.readFileBuffer(fileBuffer)
276
- *
217
+ * ```
277
218
  */
278
- HL7Client.prototype.readFileBuffer = function (fileBuffer) {
279
- return new node_hl7_client_1.FileBatch({ fileBuffer: fileBuffer });
280
- };
281
- return HL7Client;
282
- }());
219
+ readFileBuffer(fileBuffer) {
220
+ return new node_hl7_client_1.FileBatch({ fileBuffer });
221
+ }
222
+ }
283
223
  exports.HL7Client = HL7Client;
@@ -1,46 +1,10 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
3
  exports.HL7Server = void 0;
40
- var node_hl7_server_1 = require("node-hl7-server");
41
- var errors_js_1 = require("../errors.js");
42
- var HL7Server = /** @class */ (function () {
43
- function HL7Server(server) {
4
+ const node_hl7_server_1 = require("node-hl7-server");
5
+ const errors_js_1 = require("../errors.js");
6
+ class HL7Server {
7
+ constructor(server) {
44
8
  this._server = server;
45
9
  this._serverInboundConnections = [];
46
10
  }
@@ -49,43 +13,23 @@ var HL7Server = /** @class */ (function () {
49
13
  * @since 1.0.0
50
14
  * @param port
51
15
  */
52
- HL7Server.prototype.close = function (port) {
53
- return __awaiter(this, void 0, void 0, function () {
54
- var inbound;
55
- return __generator(this, function (_a) {
56
- switch (_a.label) {
57
- case 0:
58
- inbound = this._serverInboundConnections.find(function (server) { return server.port === port; });
59
- if (!(typeof inbound !== 'undefined')) return [3 /*break*/, 2];
60
- return [4 /*yield*/, inbound.server.close()]; // close the server for all inbound connections
61
- case 1: return [2 /*return*/, _a.sent()]; // close the server for all inbound connections
62
- case 2: throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE("No inbound server listening on port: ".concat(port));
63
- }
64
- });
65
- });
66
- };
16
+ async close(port) {
17
+ const inbound = this._serverInboundConnections.find(server => server.port === port);
18
+ if (typeof inbound !== 'undefined') {
19
+ return await inbound.server.close(); // close the server for all inbound connections
20
+ }
21
+ throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE(`No inbound server listening on port: ${port}`);
22
+ }
67
23
  /**
68
24
  * Close all Inbound connections.
69
25
  * @since 1.0.0
70
26
  */
71
- HL7Server.prototype.closeAll = function () {
72
- return __awaiter(this, void 0, void 0, function () {
73
- var _this = this;
74
- return __generator(this, function (_a) {
75
- this._serverInboundConnections.map(function (inbound) { return __awaiter(_this, void 0, void 0, function () {
76
- return __generator(this, function (_a) {
77
- switch (_a.label) {
78
- case 0: return [4 /*yield*/, inbound.server.close()];
79
- case 1:
80
- _a.sent();
81
- return [2 /*return*/];
82
- }
83
- });
84
- }); });
85
- return [2 /*return*/, true];
86
- });
27
+ async closeAll() {
28
+ this._serverInboundConnections.map(async (inbound) => {
29
+ await inbound.server.close();
87
30
  });
88
- };
31
+ return true;
32
+ }
89
33
  /**
90
34
  * Create Inbound connection.
91
35
  * @since 1.0.0
@@ -93,43 +37,42 @@ var HL7Server = /** @class */ (function () {
93
37
  * @param props
94
38
  * @param handler
95
39
  */
96
- HL7Server.prototype.createInbound = function (name, props, handler) {
97
- var nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
40
+ createInbound(name, props, handler) {
41
+ const nameFormat = /[ `!@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?~]/; //eslint-disable-line
98
42
  if (nameFormat.test(name)) {
99
43
  throw new errors_js_1.errors.FASTIFY_HL7_ERR_USAGE('name must not contain certain characters: `!@#$%^&*()+\\-=\\[\\]{};\':"\\\\|,.<>\\/?~.');
100
44
  }
101
- var inbound = new node_hl7_server_1.Inbound(this._server, props, handler);
45
+ const inbound = new node_hl7_server_1.Inbound(this._server, props, handler);
102
46
  this._serverInboundConnections.push({
103
- name: name,
47
+ name,
104
48
  port: props.port.toString(),
105
49
  server: inbound
106
50
  });
107
51
  return inbound;
108
- };
52
+ }
109
53
  /**
110
54
  * Get Server Inbound Connection by Name
111
55
  * @since 1.0.0
112
56
  * @param name
113
57
  */
114
- HL7Server.prototype.getServerByName = function (name) {
115
- var inbound = this._serverInboundConnections.find(function (inbound) { return inbound.name === name; });
58
+ getServerByName(name) {
59
+ const inbound = this._serverInboundConnections.find(inbound => inbound.name === name);
116
60
  if (typeof inbound !== 'undefined') {
117
61
  return inbound.server;
118
62
  }
119
63
  return undefined;
120
- };
64
+ }
121
65
  /**
122
66
  * Get Server Inbound Connection by Port
123
67
  * @since 1.0.0
124
68
  * @param port
125
69
  */
126
- HL7Server.prototype.getServerByPort = function (port) {
127
- var inbound = this._serverInboundConnections.find(function (inbound) { return inbound.port === port; });
70
+ getServerByPort(port) {
71
+ const inbound = this._serverInboundConnections.find(inbound => inbound.port === port);
128
72
  if (typeof inbound !== 'undefined') {
129
73
  return inbound.server;
130
74
  }
131
75
  return undefined;
132
- };
133
- return HL7Server;
134
- }());
76
+ }
77
+ }
135
78
  exports.HL7Server = HL7Server;
package/lib/cjs/errors.js CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.errors = void 0;
7
- var error_1 = __importDefault(require("@fastify/error"));
7
+ const error_1 = __importDefault(require("@fastify/error"));
8
8
  exports.errors = {
9
9
  /** Error if there is an setup error of the plugin itself. */
10
10
  FASTIFY_HL7_ERR_SETUP_ERRORS: (0, error_1.default)('FASTIFY_HL7_ERR_SETUP_ERRORS', 'Setup error: %s'),