# ow-koa

> koa module for ow

Latest version **1.0.1** (published 2018-05-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install ow-koa
pnpm add ow-koa
yarn add ow-koa
bun add ow-koa
```

## 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.0.1 |
| Published | 2018-05-30 |
| First published | 2018-05-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 53.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | flipace |

## Links

- npm: https://www.npmjs.com/package/ow-koa
- npm.io page: https://npm.io/package/ow-koa

## Dependencies (8)

- [koa](https://npm.io/package/koa.md) ^2.5.1
- [path](https://npm.io/package/path.md) ^0.12.7
- [get-port](https://npm.io/package/get-port.md) ^3.2.0
- [koa-mount](https://npm.io/package/koa-mount.md) ^3.0.0
- [koa-helmet](https://npm.io/package/koa-helmet.md) ^4.0.0
- [koa-router](https://npm.io/package/koa-router.md) ^7.4.0
- [koa-static](https://npm.io/package/koa-static.md) ^4.0.3
- [koa-bodyparser](https://npm.io/package/koa-bodyparser.md) ^4.2.1

## Recent versions

- 1.0.1 (latest) — 2018-05-30
- 1.0.0 — 2018-05-30

## README

<img src="ow-logo.png" width="100" />

# ow-koa

**ow-koa** gives you everything you need to create a modular application using **ow-core** and a selection of koa middlewares, such as koa-helmet, koa-router, koa-mount, koa-static and koa-bodyparser.

With this module it's as easy as pie to add routes for your ow modules.

# Quick Start

```bash
yarn add ow-koa
```

## Usage

Creating and starting a new app is as simple as writing 3 lines (or 1, if you dare to do so) of code.

```js
import Ow from 'ow-core';
import OwKoa from 'ow-koa';

async function boot() {
  const app = new Ow();

  await app.addModules([
    OwKoa
  ]);

  app.start();
}

boot();
```

```bash
yarn start
```

This is going to add and configure a koa server which will listen on a random port.
Your log output should display that the server is listening on this port and a route /checkConnection
will be available to check whether everything works as expected.


## Adding routes

Adding routes or middleware is really easy.

For infos about koa-router, please refer to its documentation: [alexmingoia/koa-router](https://github.com/alexmingoia/koa-router)

**ow-koa** attaches:

```js
app.koa // the koa instance
app.router // the koa-router instance
```

You can access them from within
all modules you added to your **ow** application. 

```js
import { OwModule } from 'ow-core';

class MyModule extends OwModule {
  static dependencies = ['OwKoa'];

  load() {
    const { router } = this.app;

    router.get('/my-module', ctx => ctx.body = 'My Module!');
  }
}
```

```bash
yarn start
```

Now you can go to http://localhost:{PORT}/my-module and you should see 'My Module!'

### About

Built with <3 by the folks at [ovos](https://ovos.at)

Contributions are very welcome!

### License

[MIT License](LICENSE)

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