@naxmefy/koa-starter

koa2 starter

Usage no npm install needed!

<script type="module">
  import naxmefyKoaStarter from 'https://cdn.skypack.dev/@naxmefy/koa-starter';
</script>

README

node-koa-starter

npm version

Build Status Coverage Status

Installation

$ npm install --save @naxmefy/koa-starter

Usage

import Koa from 'koa'
import koaStarter from '@naxmefy/koa-starter'

const app = koaStarter(Koa, {})

if (!module.parent) {
  app.start()
}

Usage (Testing - mocha + co-mocha + supertest)

import supertest from 'supertest'
import app from '../src'

before(function () {
  this.app = koaStarter(Koa, {
      onBootstrap () {
        this.calledOnBooststrap = true
      }
    })
    this.request = supertest(this.app.start({
      port: null,
      ip: null
    }))
})

describe('app', function () {
  it('should be bootstrapped', function () {
    this.app.isBootstrapped.should.be.ok()
    this.app.calledOnBooststrap.should.be.ok()
  })

  it('should response 404', function * () {
    const response = yield this.request.get('/')

    response.status.should.be.eql(404)
  })
})