TypeError: dest.end is not a function
It seems node-http2 has not been supported by Express yet. Please track this issue Support for module http on github.
In the meanwhile, you can stay with node-spdy.
const spdy = require('spdy');const options = { key: fs.readFileSync(path.join(__dirname, 'private', 'server.key')), cert: fs.readFileSync(path.join(__dirname, 'private', 'server.crt'))};const server = spdy .createServer(options, app) .listen(3000, err => { if (err) throw new Error(err); console.log('Listening...'); });
With Express 5.0 we have another solution :
express = require( 'express' ), //Web framework// Solution express.request.__proto__ = http2.IncomingMessage.prototype;express.response.__proto__ = http2.ServerResponse.prototype;// Create app for server http/2var apph2 = express();
And this is the server code :
var application_root = __dirname, express = require( 'express' ), //Web framework http2 = require('http2') logger = require('morgan') fs = require('fs') constants = require('constants');// Bunyan loggervar bunyan = require('bunyan');var app = require('./apps/app_name');var bunlog = bunyan.createLogger({name: "brqx_app"});var credentials = {// log : bunlog , key : fs.readFileSync('/etc/letsencrypt/live/domain/privkey.pem' ), cert : fs.readFileSync('/etc/letsencrypt/live/domain/fullchain.pem' ), ca : fs.readFileSync("/etc/letsencrypt/live/domain/chain.pem" ), dhparam : fs.readFileSync("/etc/letsencrypt/archive/domain/dh1.pem" ), secureOptions: constants.SSL_OP_NO_SSLv3 | constants.SSL_OP_NO_SSLv2};// Configure serverserver = http2.createServer( credentials , app); server.listen(PORT , function () { console.log('Started Brqx http/2!');} )
I hope these easy lines helps to people.
One thing is important when we search information on Internet is the date of test when code was tested : 2017 - October.
Regards.
Ricardo/Brqx.