Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cfware/koa-daemon
Koa Daemon Base Class
https://github.com/cfware/koa-daemon
Last synced: 3 months ago
JSON representation
Koa Daemon Base Class
- Host: GitHub
- URL: https://github.com/cfware/koa-daemon
- Owner: cfware
- License: mit
- Archived: true
- Created: 2017-07-22T06:29:43.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-25T21:06:07.000Z (about 7 years ago)
- Last Synced: 2024-09-26T16:41:01.803Z (3 months ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @cfware/koa-daemon
[![Travis CI][travis-image]][travis-url]
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![MIT][license-image]](LICENSE)Koa Daemon Base Class
### Install @cfware/koa-daemon
```sh
npm i --save @cfware/koa-daemon
```## Usage
```js
'use strict';const koaDaemon = require('@cfware/koa-daemon');
class MyDaemon extends koaDaemon {
constructor(listenAddr) {
super(listenAddr);
this.on('started', () => {
console.log(`Started, listening on http://localhost:${daemon.boundAddress.port}/`);/* stop server and end client connections on SIGINT or SIGTERM. */
process.on('SIGINT', () => daemon.stop());
process.on('SIGTERM', () => daemon.stop());
});
this.on('stopped', () => console.log('Stopped Daemon'));
}
start() {
this.app.use(ctx => ctx.body = 'Hello World!');
super.start();
}
}const daemon = new MyDaemon({port: 0});
daemon.start();
```## Running tests
Tests are provided by eslint and mocha.
```sh
npm install
npm test
```[npm-image]: https://img.shields.io/npm/v/@cfware/koa-daemon.svg
[npm-url]: https://npmjs.org/package/@cfware/koa-daemon
[travis-image]: https://travis-ci.org/cfware/koa-daemon.svg?branch=master
[travis-url]: https://travis-ci.org/cfware/koa-daemon
[downloads-image]: https://img.shields.io/npm/dm/@cfware/koa-daemon.svg
[downloads-url]: https://npmjs.org/package/@cfware/koa-daemon
[license-image]: https://img.shields.io/github/license/cfware/koa-daemon.svg