# get_koa_middlewares_object_with_config

> load koa 2.x middlewares with config

Latest version **1.0.4** (published 2016-09-11) · MIT license · 0 weekly downloads

## Install

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

## 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.4 |
| Published | 2016-09-11 |
| First published | 2016-09-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | i5ting |
| Maintainers | i5ting |

## Links

- npm: https://www.npmjs.com/package/get_koa_middlewares_object_with_config
- Repository: https://github.com/i5ting/koa_middlewares_with_config
- Homepage: https://github.com/i5ting/koa_middlewares_with_config#readme
- Issues: https://github.com/i5ting/koa_middlewares_with_config/issues
- npm.io page: https://npm.io/package/get_koa_middlewares_object_with_config

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^2.2.0
- [call_module_with_config](https://npm.io/package/call_module_with_config.md) ^1.0.1

## Recent versions

- 1.0.4 (latest) — 2016-09-11

## README

# get_koa_middlewares_with_config

get Koa 2.x middlewares with config

[![NPM version](https://img.shields.io/npm/v/koa_middlewares_with_config.svg?style=flat-square)](https://www.npmjs.com/package/get_koa_middlewares_with_config)

## Install

```
$ npm i -S get_koa_middlewares_with_config
```

## Usages

```
var conf = {
  'koa-favicon': {
    'path': 'sss',
    'options': {
      'maxAge': 1
    }
  },
  'koa-etag':{
    
  }
}

var middlewares = require('get_koa_middlewares_with_config')(conf)

app.use(middlewares)
```

## Examples


### example 1

- app2.js
- middlewares.js

```
'use strict'

var conf = {
  'koa-favicon': {
    'path': 'sss',
    'options': {
      'maxAge': 1
    }
  },
  'koa-etag':{
    
  }
}

module.exports = require('.')(conf)

```

then in app2.js

```
const Koa = require('koa');
const etag = require('koa-etag');
const favicon = require('koa-favicon');
const app = new Koa();

app.use((ctx, next) => {
  return next().then(() => {
    console.log('hello etag fresh= ' + ctx.fresh)
    if (ctx.fresh) {
      ctx.status = 304;
      ctx.body = null;
    }
  });
})

app.use(require('./middlewares'))

app.use((ctx, next)=>{
  console.log('hello etag fresh= ' + ctx.fresh)
  ctx.body = '<h1>hello etag</h1>'
  // ctx.etag = 'etaghaha';
  console.log('hello etag fresh= ' + ctx.fresh)
})

app.listen(3005);

```

### example 2

app.js

```
const Koa = require('koa');
const etag = require('koa-etag');
const favicon = require('koa-favicon');
const app = new Koa();

app.use((ctx, next) => {
  return next().then(() => {
    console.log('hello etag fresh= ' + ctx.fresh)
    if (ctx.fresh) {
      ctx.status = 304;
      ctx.body = null;
    }
  });
})

var conf = {
  'koa-favicon': {
    'path': 'sss',
    'options': {
      'maxAge': 1
    }
  },
  'koa-etag':{
    
  }
}

var middlewares = require('.')(conf)

app.use(middlewares)


app.use((ctx, next)=>{
  console.log('hello etag fresh= ' + ctx.fresh)
  ctx.body = '<h1>hello etag</h1>'
  // ctx.etag = 'etaghaha';
  console.log('hello etag fresh= ' + ctx.fresh)
})

app.listen(3005);
```

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