https://github.com/naxmefy/node-koa-starter
https://github.com/naxmefy/node-koa-starter
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/naxmefy/node-koa-starter
- Owner: naxmefy
- License: mit
- Created: 2016-09-03T12:12:35.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-10-08T09:08:29.000Z (about 9 years ago)
- Last Synced: 2025-02-17T00:37:03.031Z (11 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-koa-starter
[](https://badge.fury.io/js/%40naxmefy%2Fkoa-starter)
[](https://travis-ci.org/naxmefy/node-koa-starter)
[](https://coveralls.io/github/naxmefy/node-koa-starter?branch=master)
## Installation
```
$ npm install --save @naxmefy/koa-starter
```
## Usage
```JavaScript
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)
```JavaScript
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)
})
})
```