apj
v2.0.3
Published
Start with a complete Koa server with zero configuration.
Downloads
12
Readme
Apj
Start with a complete Koa server with zero configuration.
Apj includes Koa packages:
- koa-body
- koa-helmet
- koa-router
- koa-static
- koa-views
- koa-logger
- koa-json-success
- koa-struct
- koa-incache
- @koa/cors@2
- koa-session
Installation
npm install apj --save
Example
const Apj = require('apj');
new Apj().start(); // Listen on http://localhost:3000
Add routes
const app = new Apj();
app.router.get('/my-route', ctx => {
ctx.body = 'hello';
});
app.start();
Use middleware
new Apj({
use: [
async (ctx, next) => {
const start = Date.now();
await next();
const ms = Date.now() - start;
console.log(`${ctx.method} ${ctx.url} - ${ms}ms`);
}
]
});
API
Apj
Kind: global class
- Apj
- new Apj([opt])
- instance
- inner
- ~apj : object
new Apj([opt])
Create instance
apj.start(port) ⇒ Apj
Start server app
Kind: instance method of Apj
Emits: start
apj.stop() ⇒ Apj
Stop server app
Kind: instance method of Apj
Emits: stop
"start"
Triggered on server start
Kind: event emitted by Apj
"stop"
Triggered on server stop
Kind: event emitted by Apj
Apj~apj : object
Apj instance
Kind: inner typedef of Apj
Properties
Changelog
You can view the changelog here
License
Apj is open-sourced software licensed under the MIT license
Author
Fabio Ricali