# moin

> a Simple Microservice Server

Latest version **1.2.0** (published 2016-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install moin
pnpm add moin
yarn add moin
bun add moin
```

Provides the command `moin`.

## 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.2.0 |
| Published | 2016-08-17 |
| First published | 2016-05-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0 |
| Dependencies | 9 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Torben Hartmann |
| Maintainers | torben.hartmann |
| Keywords | microservice, application-server, event-driven |

## Links

- npm: https://www.npmjs.com/package/moin
- Repository: https://github.com/moinjs/moin
- Homepage: https://github.com/moinjs/moin#readme
- Issues: https://github.com/moinjs/moin/issues
- npm.io page: https://npm.io/package/moin

## Dependencies (9)

- [colors](https://npm.io/package/colors.md) ^1.1.2
- [moin-logo](https://npm.io/package/moin-logo.md) ^1.0.0
- [cli-spinner](https://npm.io/package/cli-spinner.md) ^0.2.5
- [object-merge](https://npm.io/package/object-merge.md) ^2.5.1
- [moin-fs-watcher](https://npm.io/package/moin-fs-watcher.md) ^1.0.0
- [moin-event-system](https://npm.io/package/moin-event-system.md) ^1.0.0
- [moin-service-loader](https://npm.io/package/moin-service-loader.md) ^1.0.0
- [moin-service-settings](https://npm.io/package/moin-service-settings.md) ^1.0.0
- [moin-remote-dispatcher](https://npm.io/package/moin-remote-dispatcher.md) ^1.0.0

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.2.0 (latest) — 2016-08-17
- 1.1.3 — 2016-08-10
- 1.1.2 — 2016-08-09
- 1.1.1 — 2016-08-09
- 1.1.0 — 2016-08-09
- 1.0.6 — 2016-07-13
- 1.0.5 — 2016-07-12
- 1.0.4 — 2016-07-12
- 1.0.3 — 2016-07-12
- 1.0.2 — 2016-07-12
- 1.0.1 — 2016-07-12
- 1.0.0 — 2016-07-12
- 0.0.1 — 2016-05-31

## README

# moin

[![Join the chat at https://gitter.im/moinjs/moin](https://badges.gitter.im/moinjs/moin.svg)](https://gitter.im/moinjs/moin?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![logo](https://raw.githubusercontent.com/moinjs/moin/master/logo.png)
>Moin (pronounced [ˈmɔɪn]) is a German greeting meaning "hello" and in some places "goodbye".

Moin is an event-driven microservice application server written in behalf of my bachelor thesis at the FH-Kiel.

#What is it good for
##Reloading of Code
Imagine you set up a simple express Webserver. When you make changes to a route, you have to restart the whole application in order to see the changes.
Moin watches your service directory and reloads your Module when something was changed. It automatically stops all your self-set timers, so you don't have to.

##Advanced Event System
Ever wanted to have more control over the Event filtering? In any normal Node Application you can only listen on event names.
In Moin, you can filter the events on any property. You can even define dynamic checks like `{event:"httpRequest",method:(m)=>m=="get"||m=="post"}`.
 
When you emit an event you can register for the return values of the handlers. This is utilized in the example below.

#Installation
Just install Moin as a global Package.
```bash
npm install -g moin
```

To ease the generation of configs and the creation of services you can use the yeoman generator:
```bash
   npm install -g yo generator-moin
```

To initialize the current directory for the use of moin just execute:
```bash
yo moin
```

To create a new service you can use:

```bash
yo moin:service
```

#Docs
You can read the docs at [moinjs.github.io](http://moinjs.github.io)
#Sample: a small Webserver
###webserver/index.js
````javascript
let app = require("express")();
let server = app.listen(3000, function () {
    console.log("Webserver started")
});

//Send out an event for every get Reguest
app.get("*", function (req, res) {
    moin.emit("httpRequest", {
        method: "get",
        path: req.path
    }, 30000).then(({values,errors,stats})=> {
        //See how many Listeners have responded.
        switch(values.length){
            case 0:
                res.send(404,"Not Found");
                break;
            default:
                res.send(200,values.join("<br/>"));
        }
    })
});

moin.registerUnloadHandler(()=>server.close());
````

###hello/index.js
````javascript
moin.on({event: "httpRequest", method: "get"}, (event)=> {
    return `Moin, ${event.path}!`;
});
````

This example opens an express Webserver and emits an event, when a url is accessed. The hello service registeres for these events and returns a response, which is then served to the Browser.

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