Skip to content

Commit 934989b

Browse files
committed
fix: added http2, removed proxy protocol support
1 parent 929f315 commit 934989b

File tree

3 files changed

+685
-812
lines changed

3 files changed

+685
-812
lines changed

index.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const http = require('http');
2-
const https = require('https');
3-
// const http2 = require('http2');
2+
const http2 = require('http2');
43
const util = require('util');
54

65
const Cabin = require('cabin');
@@ -20,7 +19,6 @@ const json = require('koa-json');
2019
const koa404Handler = require('koa-404-handler');
2120
const koaConnect = require('koa-connect');
2221
const multimatch = require('multimatch');
23-
const proxyWrap = require('findhit-proxywrap');
2422
const removeTrailingSlashes = require('koa-no-trailing-slash');
2523
const requestId = require('express-request-id');
2624
const requestReceived = require('request-received');
@@ -29,9 +27,6 @@ const sharedConfig = require('@ladjs/shared-config');
2927
const { boolean } = require('boolean');
3028
const { ratelimit } = require('koa-simple-ratelimit');
3129

32-
const proxiedHttp = proxyWrap.proxy(http);
33-
const proxiedHttps = proxyWrap.proxy(https);
34-
3530
class API {
3631
constructor(config) {
3732
this.config = {
@@ -180,20 +175,11 @@ class API {
180175
else app.use(this.config.routes);
181176
}
182177

183-
const createServer =
184-
this.config.protocol === 'https'
185-
? this.config.proxyProtocol
186-
? proxiedHttps.createServer
187-
: https.createServer
188-
: this.config.proxyProtocol
189-
? proxiedHttp.createServer
190-
: http.createServer;
191-
192-
// start server on either http or https
178+
// start server on either http or http2
193179
const server =
194180
this.config.protocol === 'https'
195-
? createServer(this.config.ssl, app.callback())
196-
: createServer(app.callback());
181+
? http2.createSecureServer(this.config.ssl, app.callback())
182+
: http.createServer(app.callback());
197183

198184
// expose app, server, client
199185
this.app = app;

package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@
2323
"@koa/router": "^10.0.0",
2424
"@ladjs/i18n": "^7.0.1",
2525
"@ladjs/redis": "^1.0.7",
26-
"@ladjs/shared-config": "^3.0.10",
26+
"@ladjs/shared-config": "^4.0.0",
2727
"@ladjs/store-ip-address": "^0.0.7",
28-
"boolean": "3.0.1",
28+
"boolean": "^3.0.2",
2929
"cabin": "^9.0.4",
3030
"express-request-id": "^1.4.1",
31-
"findhit-proxywrap": "^0.3.12",
3231
"kcors": "^2.2.2",
3332
"koa": "^2.13.1",
3433
"koa-404-handler": "^0.0.2",
@@ -57,17 +56,17 @@
5756
"eslint": "^7.19.0",
5857
"eslint-config-xo-lass": "^1.0.5",
5958
"fixpack": "^4.0.0",
60-
"husky": "^4.3.8",
61-
"lint-staged": "10.5.3",
62-
"mongoose": "^5.11.14",
59+
"husky": "^5.0.9",
60+
"lint-staged": "10.5.4",
61+
"mongoose": "^5.11.15",
6362
"nyc": "^15.1.0",
6463
"remark-cli": "^9.0.0",
6564
"remark-preset-github": "^4.0.1",
6665
"supertest": "^6.1.3",
6766
"xo": "^0.37.1"
6867
},
6968
"engines": {
70-
"node": ">=8.3"
69+
"node": ">=10.10.0"
7170
},
7271
"files": [
7372
"index.js"

0 commit comments

Comments
 (0)