# koa-base

> Koa base framework

Latest version **0.1.7** (published 2015-09-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install koa-base
pnpm add koa-base
yarn add koa-base
bun add koa-base
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.7 |
| Published | 2015-09-18 |
| First published | 2015-08-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.11.16 |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Marc Vornetran |
| Maintainers | marc1404 |
| Keywords | koa, base, bootstrap, koajs, framework |

## Links

- npm: https://www.npmjs.com/package/koa-base
- Repository: https://github.com/marc1404/koa-base
- Homepage: https://github.com/marc1404/koa-base#readme
- Issues: https://github.com/marc1404/koa-base/issues
- npm.io page: https://npm.io/package/koa-base

## Dependencies (6)

- [koa](https://npm.io/package/koa.md) ^1.0.0
- [dotenv](https://npm.io/package/dotenv.md) ^1.2.0
- [koa-logger](https://npm.io/package/koa-logger.md) ^1.3.0
- [koa-static](https://npm.io/package/koa-static.md) ^1.4.9
- [koa-bodyparser](https://npm.io/package/koa-bodyparser.md) ^2.0.1
- [koa-static-cache](https://npm.io/package/koa-static-cache.md) ^3.1.2

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads
- [@modern-js/plugin-swc](https://npm.io/package/@modern-js/plugin-swc.md) — 3.4K weekly downloads

## Recent versions

- 0.1.7 (latest) — 2015-09-18
- 0.1.6 — 2015-08-29
- 0.1.5 — 2015-08-22
- 0.0.5 — 2015-08-18
- 0.0.4 — 2015-08-18
- 0.0.3 — 2015-08-18
- 0.0.2 — 2015-08-17
- 0.0.1 — 2015-08-17

## README

# koa-base
[![npm](https://img.shields.io/npm/v/koa-base.svg?style=flat-square)](https://www.npmjs.com/package/koa-base)
[![Travis](https://img.shields.io/travis/marc1404/koa-base.svg?style=flat-square)](https://travis-ci.org/marc1404/koa-base)
[![Code Climate](https://img.shields.io/codeclimate/github/marc1404/koa-base.svg?style=flat-square)](https://codeclimate.com/github/marc1404/koa-base)
[![Code Climate](https://img.shields.io/codeclimate/coverage/github/marc1404/koa-base.svg?style=flat-square)](https://codeclimate.com/github/marc1404/koa-base/coverage)
[![npm](https://img.shields.io/npm/l/koa-base.svg?style=flat-square)](https://github.com/marc1404/koa-base/blob/master/LICENSE)
[![npm](https://img.shields.io/npm/dm/koa-base.svg?style=flat-square)](https://www.npmjs.com/package/koa-base)

[![David](https://img.shields.io/david/marc1404/koa-base.svg?style=flat-square)](https://github.com/marc1404/koa-base/blob/master/package.json)
[![David](https://img.shields.io/david/dev/marc1404/koa-base.svg?style=flat-square)](https://github.com/marc1404/koa-base/blob/master/package.json)

## Installation
```bash
$ npm install koa-base
```
  
## Description
This package provides a quick start into the awesome [koa](https://www.npmjs.com/package/koa) framework.
It does not tell you how to structure your koa application or which packages you should use.
Some basic packages are included out of the box:
- [dotenv](https://www.npmjs.com/package/dotenv)
- [koa-bodyparser](https://www.npmjs.com/package/koa-bodyparser)
- [koa-logger](https://www.npmjs.com/package/koa-logger)
- [koa-static](https://www.npmjs.com/package/koa-static)
- [koa-static-cache](https://www.npmjs.com/package/koa-static-cache)

**Dotenv** will search for a *.env* file, it should contain *=* separated values which will be put into the [process.env](https://nodejs.org/api/process.html#process_process_env) object.  
*.env*
```
PORT=80
```
This value will be available as:
```javascript
console.log(process.env.PORT); // 80
```
Port is the only required value in the *.env* file!

**koa-bodyparser** will parse the request for a json body and store it in ```this.request.body```.
This is something which most apps will need, that is why this package is included by default.

**koa-logger** is a development style logger which outputs requests to the console.

**koa-static** will serve static files out of a directory.
  
**koa-static-cache** can be used instead of *koa-static* to serve static files from memory.

## Usage
```javascript
var koa = require('koa-base');

koa.config = app => {
    // configure app
};

koa.run = server => {
    // if you need the server object for e.g. socket.io
};

// start app, options are not necessary
koa.start({
    port: 80, // default: options.port || process.env.PORT || 80
    serve: 'public', // default: 'public'
    bodyParser: true // default: true
    staticCache: false // default: false
});
```
  
## Options
- ```port``` will use ```process.env.PORT``` or ```80``` by default
- ```serve``` the directory where static files will be served from (default: ```public```) 
- ```bodyParser``` whether json body contents should be parsed (default: ```true```)
- ```staticCache``` enable to serve static files from memory, requires restart to reload files (default: ```false```)

## Test
```
$ npm install -g mocha  
$ mocha
```

## Author
[marc1404](https://github.com/marc1404)

## License
[MIT](https://github.com/marc1404/koa-base/blob/master/LICENSE)

---
_Source: https://npm.io/package/koa-base · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
