# koa-initializer

> Module for generating and handling initializers of your koa application

Latest version **4.0.1** (published 2020-06-06) · MIT license · 0 weekly downloads

## Install

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

## 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 | 4.0.1 |
| Published | 2020-06-06 |
| First published | 2016-09-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ivan_matvieiev@globallogic.com |
| Maintainers | imatveev |

## Links

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

## Dependencies (1)

- [mkdirp](https://npm.io/package/mkdirp.md) ^1.0.4

## Recent versions

- 4.0.1 (latest) — 2020-06-06
- 4.0.0 — 2020-03-26
- 3.0.2 — 2019-11-13
- 3.0.1 — 2019-09-12
- 2.0.1 — 2017-12-26
- 2.0.0 — 2017-08-21
- 1.1.4 — 2017-08-21
- 1.1.3 — 2017-08-21
- 1.1.2 — 2017-08-21
- 1.0.2 — 2016-10-12
- 1.0.1 — 2016-09-01
- 1.0.0 — 2016-09-01

## README

# koa-initializer

A koa plugin for handling async/sync initializers of your application.
## Installation
    npm install koa-initializer
## When should I use koa-initializer?
You need to add synchronous or asynchronous code, that must be executed before your koa app starts.
## API
    const initializer = require('koa-initializer');
    const Koa         = require('koa');
    const app         = new Koa();

    // koa v2

    initializer(app)
    .then(() => {
        //Your application code
    });

    // koa v3
    await initializer(app);
    //Your application code

So as you can see initializer returns promise;
## Initializer file path and structure
Your app root folder should contain "initializers" folder with initializers files (name of file irrelevant).
initializer.js:

    'use strict';

    module.exports = {
        priority: 800, // Any diapason (bigger number - higher priority, so 1000 goes before 800)
        execute(app) { // Executable function (takes app as parameter)
            //Any synchronous/asynchronous code (asynchronous must return promise)
        }
    };

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