npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

trailpack-koa

v3.0.2

Published

Koa for Trails.JS (via Trailpack)

Downloads

7

Readme

trailpack-koa

NPM version Build status Dependency Status Code Climate Donate

Use Koa as your Trails server

support web socket, http, https and spdy

Dependencies

  • TrailsJS@^3
  • Koa@^2

Compatibilities

  • Footprint

Install

NPM

$ npm install --save trailpack-koa

Yarn

$ yarn add trailpack-koa

Configure

Main

// config/main.js
module.exports = {
  packs: [
    // ... other trailpacks
    require('trailpack-koa')
  ]
}

Web

const env = require('env-var')

// config/web.js
module.exports = {
  /**
   * Koa package
   * @type {function}
   * @required
   */
  koa: require('koa'),
  /**
   * Better customize Koa
   * @type {function}
   * @required
   */
  init: (trailsApp, koaApp) => {},
  /**
   * SSL options
   * Cert and key or pfx to create HTTPS server
   * @type {object}
   */
  // ssl: {
  //   /**
  //    * Private Key .key
  //    * @type {string}
  //    */
  //   key: '...',
  //   /**
  //    * Certificate PEM .pem
  //    * @type {string}
  //    */
  //   cert: '...'
  // },
  /**
   * SPDY options
   * @type {object}
   */
  // spdy: {
  //   /**
  //    * list of NPN/ALPN protocols to use
  //    * @type {array}
  //    * @default ['h2','spdy/3.1','spdy/3','spdy/2','http/1.1','http/1.0']
  //    */
  //   protocols: ['h2','spdy/3.1','spdy/3','spdy/2','http/1.1','http/1.0'],
  //   /**
  //    * If defined, server will ignore NPN and ALPN data and choose whether to use spdy or plain http by looking at first data packet.
  //    * @type {boolean}
  //    */
  //   plain: false,
  //   /**
  //    * Parse first incoming X_FORWARDED_FOR frame and put it to the
  //    * headers of every request.
  //    * NOTE: Use with care! This should not be used without some proxy that
  //    * will *always* send X_FORWARDED_FOR
  //    */
  //   'x-forwarded-for': false,
  //   /**
  //    * SPDY Connection options
  //    * @type {object}
  //    */
  //   connection: {
  //     /**
  //      * Server's window size
  //      * @type {number}
  //      */
  //     windowSize: 1024 * 1024,
  //     /**
  //      * If true - server will send 3.1 frames on 3.0 *plain* spdy
  //      * @type {boolean}
  //      */
  //     autoSpdy31: false
  //   }
  // },
  /**
   * The port to bind the web server to
   * @type number
   * @default 3000
   */
  port: env.get('PORT', 3000).asIntPositive(),
  /**
   * The host to bind the web server to
   * @type string
   * @default localhost
   */
  host: env.get('HOST', 'localhost').asString(),

  /**
   * Feature for koa.context.onerror handler
   * @type {boolean|function}
   * @default true
   */
  onError: true,
  /**
   * Feature koa-compress
   * https://www.npmjs.com/package/koa-compress
   * @type {boolean|object}
   * @default true
   */
  compress: true,
  /**
   * Feature koa-cors
   * https://www.npmjs.com/package/koa-cors
   * @type {boolean|object}
   * @default true
   */
  cors: true,
  /**
   * Feature koa-session
   * https://www.npmjs.com/package/koa-cors
   * @type {boolean|object}
   */
  session: true,
  /**
   * Feature koa-bodyparser
   * https://www.npmjs.com/package/koa-bodyparser
   * @type {object}
   */
  bodyparser: true,

  /**
   * Middlewares
   * @type {object}
   */
  // middlewares: {},
  /**
   * Middlewares Order
   * @type {object}
   */
  // middlewaresOrder: [
  //   'compress',
  //   'cors',
  //   'session',
  //   'bodyparser',
  //   'router',
  //   '404'
  // ]
}

Socket

// config/socket.js
module.exports = {
  /**
  * Socket.io package
  * @type {function}
  * @required
  */
  scoketIo: require('socket.io'),
  /**
   * Better customize Scoket.io
   * @type {function}
   * @required
   */
  init: (trailsApp, koaApp) => {},
  /**
   * Socket.io parameters
   * https://www.npmjs.com/package/socket.io
   * @type {object}
   */
  // params: {},
  /**
   * Socket.io sticky session parameters
   * https://www.npmjs.com/package/socketio-sticky-session
   * @type {boolean|object}
   * @default false
   */
  cluster: false
}

Controllers / Routes

Doc for Controllers and Routes can be found here!

Policies

Doc for Policies can be found here!

Credits

Please Contribute!

I'm happy to receive contributions of any kind!

Did you like my work?

Help me out with a little donation, press on the button below. Donate