Code Monkey home page Code Monkey logo

koa-h2-man-pusher's Introduction

koa-h2-man-pusher

server push middleware for koa w/ manifest support

Note: This is an unstable WIP. Don't go prod.

also holds true for the readme. it is very sparse right now.

Installation

npm install koa-h2-man-pusher --save

API

manpusher([opts])

opts.root

Type: string
Default: .

Root path to read from.

opts.manifest

Type: string
Default: push_manifest.json

Path to your http2-push-manifest.

Usage

const spdy = require('spdy');
const Koa = require('koa');
const manpusher = require('koa-h2-man-pusher');

const app = new Koa();

app.use(manpusher({
  manifest: 'stuff/manifest.json',
  root: 'dist'
}));

const server = spdy.createServer({
  key: 'path/to/ssl.key',
  cert: 'path/to/ssl.crt'
}, app.callback());

server.listen(3000);

Copyright

MIT

koa-h2-man-pusher's People

Contributors

kasperlewau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

koa-h2-man-pusher's Issues

Wrapper API

Original Issue: #4

I suggest making a nice little wrapper for this common setup.

const manpusher = manpush.create(app).configure({ 
  manifest: 'manifest.json', 
  key: 'path/to/ssl.key', 
  cert: 'path/to/ssl.crt' 
})

app
  .use(manpusher.manifestor)
  .use(manpusher.push)

// or using koa-combine
app
  .use(combine(...manpusher.mw)) // returns all middleware in a list

manpusher.server.listen(3000)

Cheers!


  • Wrap common Koa libs into a "sane defaults" koa app.
    • Expose & make it extendable.
  • Pre-package spdy and feed it the prebuilt koa app.
  • [insert-more-thoughts]

FLOW_CONTROL_ERROR

Need to identify a reproducible case of this error and handle it accordingly.

RST_PROTOCOL_ERROR

Need to identify a reproducible case of this error and handle it accordingly.

Error in Readme and suggestions

koa.callback() should be app.callback() since const app = new Koa();

const spdy = require('spdy');
const Koa = require('koa');
const manpush = require('koa-h2-man-pusher');

const app = new Koa();

app.use(manpush.manifestor({ manifest: 'manifest.json' }));
app.use(manpush.push());

const server = spdy.createServer({ key: 'path/to/ssl.key', cert: 'path/to/ssl.crt' }, app.callback());

server.listen(3000);

I suggest making a nice little wrapper for this common setup.

const manpusher = manpush.create(app).configure({ 
  manifest: 'manifest.json', 
  key: 'path/to/ssl.key', 
  cert: 'path/to/ssl.crt' 
})

app
  .use(manpusher.manifestor)
  .use(manpusher.push)

// or using koa-combine
app
  .use(combine(...manpusher.mw)) // returns all middleware in a list

manpusher.server.listen(3000)

Cheers!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.