# mirth-node

> Mirh API for javascript applications.

Latest version **1.1.15** (published 2022-11-08) · (MIT OR GPL-3.0-or-later) license · 0 weekly downloads

## Install

```sh
npm install mirth-node
pnpm add mirth-node
yarn add mirth-node
bun add mirth-node
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.15 |
| Published | 2022-11-08 |
| First published | 2022-09-28 |
| Weekly downloads | 0 |
| License | (MIT OR GPL-3.0-or-later) |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 36.2 KB |
| Known vulnerabilities | 0 (+24 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Igor Zorko |
| Maintainers | izorko |
| Keywords | Mirth, javascript, node |

## Links

- npm: https://www.npmjs.com/package/mirth-node
- Repository: https://github.com/izorko33/mirth-node
- Homepage: https://github.com/izorko33/mirth-node#readme
- Issues: https://github.com/izorko33/mirth-node/issues
- npm.io page: https://npm.io/package/mirth-node

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^0.27.2
- [dotenv](https://npm.io/package/dotenv.md) ^16.0.2

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.1.15 (latest) — 2022-11-08
- 1.1.14 — 2022-11-07
- 1.1.13 — 2022-11-04
- 1.1.12 — 2022-11-04
- 1.1.11 — 2022-10-24
- 1.1.10 — 2022-10-19
- 1.1.9 — 2022-10-19
- 1.1.8 — 2022-10-17
- 1.1.7 — 2022-10-12
- 1.1.6 — 2022-10-12
- 1.1.5 — 2022-10-12
- 1.1.4 — 2022-10-12
- 1.1.3 — 2022-10-12
- 1.1.2 — 2022-10-11
- 1.1.1 — 2022-10-11
- … 9 more at https://npm.io/package/mirth-node/versions

## README

# Mirth-Node

The Mirth-js is a client for having Mirth for nodejs and react applications.
Tested Mirth versions: 3.x, 4.x

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [Custom Functions](#custom-functions)

---

## Installation

```
npm install mirth-node --save
```

Import

```
const { MirthClient } = require('mirth-node');
require('dotenv').config(); // If you want to use proccess.env
```

---

## Usage

Example function

```
const { MirthClient } = require('mirth-node');
require('dotenv').config();

async function main() {
  const clientMirth = await new MirthClient({
    host: process.env.MIRTH_HOST,
    port: process.env.MIRTH_PORT,
    username: process.env.MIRTH_USER,
    password: process.env.MIRTH_PASSWORD,
    disableTLSCheck: true,
  });
  const currentUser = await clientMirth.getCurrentUser();
  console.log(currentUser);
}

main();

```

Creating new instance

```
  const clientMirth = new MirthClient({
    host: process.env.MIRTH_HOST,
    port: process.env.MIRTH_PORT,
    username: process.env.MIRTH_USER,
    password: process.env.MIRTH_PASSWORD,
    disableTLSCheck: true,
  });
```

Exporting all channels and code templates

```
await clientMirth.syncDown();
```

Uploading/updating all channels and code templates

```
await clientMirth.syncUp();
```

Check for current logged in user.

```
  const currentUser = await clientMirth.getCurrentUser();
  console.log(currentUser);
```

Getting all channels, checking count and downloading all message.

```
  const channels = await clientMirth.getChannels();
  channels.channel.forEach(async element => {
    const count = await clientMirth.getMessageCount({ channelId: element.id });
    console.log(`${element.name} : ${count}, id: ${element.id}`);
    if (count > 0) {
      clientMirth.exportMessagesByChannelId(element.id, count);
    }
  });
```

Send/resend messages to specific open port.

```
await clientMirth.sendMessagesToChannel([PATHTOFILE], 'localhost', '6661');
```

---

### Custom functions

#### syncDown()

Summary: Export all channels and code templates in exports folder.

---

#### syncUp()

Summary: Import all channels and code templates from exports folder. Auto redeploy.

---

#### updateChannelById(channelId)

Summary: Update only one specific channel. You will need to redeploy that channel.

---

#### exportMessagesByChannelId(channelId, limit)

Summary: Exports limited messages for specific channel.

---

#### sendMessagesToChannel(pathToFileName, host, port)

Summary: Send messages to specific channel from specific file.

---

#### updateAllCodeTemplates()

Summary: Update all code templates from exports folder.

---

---
_Source: https://npm.io/package/mirth-node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
