node.js server and HTTP/2 (2.0) with express.js

WHITECOLOR picture WHITECOLOR · Feb 21, 2015 · Viewed 28.4k times · Source

Is it possible currently to get node.js HTTP/2 (HTTP 2.0) server? And http 2.0 version of express.js?

Answer

HDK picture HDK · Mar 2, 2015
var express = require('express');
var app = express();

app.get('/', function (req, res) {
  res.send('hello, http2!');
});

var options = {
  key: fs.readFileSync('./example/localhost.key'),
  cert: fs.readFileSync('./example/localhost.crt')
};

require('http2').createServer(options, app).listen(8080);

EDIT

This code snippet was taken from a conversation on Github.