koa-initializer
Module for generating and handling initializers of your koa application
Last updated 36 minutes ago by imatveev .
MIT · Original npm · Tarball · package.json
$ cnpm install koa-initializer 
SYNC missed versions from official npm registry.

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)
    }
};

Current Tags

  • 4.0.1                                ...           latest (36 minutes ago)

12 Versions

  • 4.0.1                                ...           36 minutes ago
  • 4.0.0                                ...           2 months ago
  • 3.0.2                                ...           7 months ago
  • 3.0.1                                ...           9 months ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           3 years ago
  • 1.1.4                                ...           3 years ago
  • 1.1.3                                ...           3 years ago
  • 1.1.2                                ...           3 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 6
This Week 9
This Month 9
Last Day 0
Last Week 2
Last Month 3
Dependencies (1)
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |