Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apj

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apj

Start with a complete Koa server with zero configuration.

  • 2.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22
increased by266.67%
Maintainers
1
Weekly downloads
 
Created
Source

Apj

Start with a complete Koa server with zero configuration.

Apj includes Koa packages:

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

new Apj([opt])

Create instance

ParamTypeDefaultDescription
[opt]object

options

[opt.host]string"localhost"

host

[opt.port]number3000

port

[opt.serverOptions]object

server options

[opt.helmetSettings]object

koa-helmet settings

[opt.routerSettings]object

koa-router settings

[opt.bodySettings]object

koa-body settings

[opt.successSettings]object

koa-json-success settings

[opt.structSettings]object

koa-struct settings

[opt.cacheSettings]object

koa-incache settings

[opt.corsSettings]object

@koa/cors@2 settings

[opt.sessionSettings]object

koa-session settings

[opt.viewsSettings]object

koa-views settings

[opt.loggerSettings]object

koa-logger settings

[opt.logger]objectfalse

active koa-logger

[opt.ctx]object

Koa context

[opt.viewsPath]string"./views/"

path to views

[opt.staticPath]string"./public/"

path to static resources

[opt.use]array

array of middleware

[opt.autoStart]booleanfalse

start on create

[opt.responseErrorHandler]boolean

manipulate message and code

[opt.exposeError]boolean

expose all errors

apj.start(port) ⇒ Apj

Start server app

Kind: instance method of Apj
Emits: start

Param
port

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

NameTypeDescription
appobject

Koa instance

routerobject

router object

serverobject

server instance

Changelog

You can view the changelog here

License

Apj is open-sourced software licensed under the MIT license

Author

Fabio Ricali

Keywords

FAQs

Package last updated on 09 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc