Skip to content

Commit db2256e

Browse files
author
Jerzy
committed
Enable HTTP/2
1 parent e3850d7 commit db2256e

File tree

3 files changed

+124
-5
lines changed

3 files changed

+124
-5
lines changed

package-lock.json

Lines changed: 113 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
"name": "bandwidth-hero-proxy",
33
"main": "server.js",
44
"private": true,
5-
"version": "1.0.1",
6-
"description":
7-
"Data compression service that converts images to low-res WebP or JPEG on the fly. Used in Bandwidth-Hero browser extension.",
5+
"version": "1.0.2",
6+
"description": "Data compression service that converts images to low-res WebP or JPEG on the fly. Used in Bandwidth-Hero browser extension.",
87
"author": "Anatoliy Yastreb",
98
"license": "MIT",
109
"scripts": {
@@ -15,7 +14,8 @@
1514
"express": "4.16.2",
1615
"lodash": "^4.17.4",
1716
"request": "^2.83.0",
18-
"sharp": "^0.18.4"
17+
"sharp": "^0.18.4",
18+
"spdy": "^3.4.7"
1919
},
2020
"engines": {
2121
"node": "^8.6.0"

server.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ const app = require('express')()
44
const authenticate = require('./src/authenticate')
55
const params = require('./src/params')
66
const proxy = require('./src/proxy')
7+
const spdy = require('spdy');
8+
const fs = require('fs');
9+
const ssl = {
10+
key: fs.readFileSync('./cert/privkey.pem'),
11+
cert: fs.readFileSync('./cert/fullchain.pem')
12+
}
713

814
const PORT = process.env.PORT || 8080
915

1016
app.enable('trust proxy')
1117
app.get('/', authenticate, params, proxy)
1218
app.get('/favicon.ico', (req, res) => res.status(204).end())
13-
app.listen(PORT, () => console.log(`Listening on ${PORT}`))
19+
spdy.createServer(ssl, app).listen(PORT, () => console.log(`Listening on ${PORT}`))

0 commit comments

Comments
 (0)