@naxmefy/koa-starter
koa2 starter
Last updated 4 years ago by naxmefy .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @naxmefy/koa-starter 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.1                                ...           latest (4 years ago)

2 Versions

  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |