diff --git a/package.json b/package.json index d77a6d7..a3dd389 100644 --- a/package.json +++ b/package.json @@ -55,5 +55,8 @@ "gulp-stylus": "^2.1.1", "mocha": "^2.3.4", "supertest": "^1.1.0" + }, + "optionalDependencies": { + "http2": "^3.3.2" } } diff --git a/src/index.coffee b/src/index.coffee index 3ad4178..fa96d3e 100644 --- a/src/index.coffee +++ b/src/index.coffee @@ -10,6 +10,10 @@ tiny_lr = require("tiny-lr") lr = undefined apps = [] +http2 = undefined +try + http2 = require('http2') + class ConnectApp constructor: (options) -> @port = options.port || "8080" @@ -37,7 +41,7 @@ class ConnectApp @app.use middleware if @https - @server = https.createServer + @server = (http2 || https).createServer key: @https.key || fs.readFileSync __dirname + '/certs/server.key' cert: @https.cert || fs.readFileSync __dirname + '/certs/server.crt' ca: @https.ca || fs.readFileSync __dirname + '/certs/ca.crt'