@ladjs/proxy
Advanced tools
Comparing version 2.0.1 to 2.0.2
24
index.js
@@ -40,5 +40,5 @@ const http = require('http'); | ||
`/.well-known/acme-challenge/${this.config.certbot.name}`, | ||
(req, res) => { | ||
res.setHeader('Content-Type', 'text/plain; charset=utf-8'); | ||
res.end(this.config.certbot.contents); | ||
(request, response) => { | ||
response.setHeader('Content-Type', 'text/plain; charset=utf-8'); | ||
response.end(this.config.certbot.contents); | ||
} | ||
@@ -48,13 +48,13 @@ ); | ||
if (this.config.redirect) | ||
router.use((req, res) => { | ||
router.use((request, response) => { | ||
if (this.config.removeWwwPrefix) | ||
req.headers.host = req.headers.host.replace('www.', ''); | ||
res.writeHead(301, { | ||
Location: parse(`https://${req.headers.host}${req.url}`).href | ||
request.headers.host = request.headers.host.replace('www.', ''); | ||
response.writeHead(301, { | ||
Location: parse(`https://${request.headers.host}${request.url}`).href | ||
}); | ||
res.end(); | ||
response.end(); | ||
}); | ||
else | ||
router.use((req, res) => { | ||
res.end(); | ||
router.use((request, response) => { | ||
response.end(); | ||
}); | ||
@@ -66,4 +66,4 @@ | ||
this.server = createServer((req, res) => { | ||
router(req, res, finalhandler(req, res)); | ||
this.server = createServer((request, response) => { | ||
router(request, response, finalhandler(request, response)); | ||
}); | ||
@@ -70,0 +70,0 @@ |
{ | ||
"name": "@ladjs/proxy", | ||
"description": "Proxy for Lad", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)", | ||
@@ -26,3 +26,3 @@ "ava": { | ||
"findhit-proxywrap": "^0.3.12", | ||
"lodash": "^4.17.15", | ||
"lodash": "^4.17.19", | ||
"router": "^1.3.5", | ||
@@ -32,8 +32,8 @@ "url-parse": "^1.4.7" | ||
"devDependencies": { | ||
"@commitlint/cli": "^9.0.1", | ||
"@commitlint/config-conventional": "^9.0.1", | ||
"ava": "^3.10.0", | ||
"codecov": "^3.7.0", | ||
"@commitlint/cli": "^9.1.1", | ||
"@commitlint/config-conventional": "^9.1.1", | ||
"ava": "^3.10.1", | ||
"codecov": "^3.7.1", | ||
"cross-env": "^7.0.2", | ||
"eslint": "^6.7.2", | ||
"eslint": "^7.5.0", | ||
"eslint-config-xo-lass": "^1.0.3", | ||
@@ -44,6 +44,7 @@ "fixpack": "^3.0.6", | ||
"nyc": "^15.1.0", | ||
"remark-cli": "^8.0.0", | ||
"remark-cli": "^8.0.1", | ||
"remark-preset-github": "^2.0.2", | ||
"sinon": "^9.0.2", | ||
"supertest": "^4.0.2", | ||
"xo": "^0.25.3" | ||
"xo": "^0.32.1" | ||
}, | ||
@@ -50,0 +51,0 @@ "engines": { |
@@ -6,3 +6,3 @@ const test = require('ava'); | ||
test('starts and stops server', async t => { | ||
test('starts and stops server', async (t) => { | ||
const proxy = new ProxyServer(); | ||
@@ -14,19 +14,19 @@ await proxy.listen(); | ||
test('redirects http to https', async t => { | ||
test('redirects http to https', async (t) => { | ||
const proxy = new ProxyServer(); | ||
await proxy.listen(); | ||
const res = await request(proxy.server).get('/foobar'); | ||
const response = await request(proxy.server).get('/foobar'); | ||
const { port } = proxy.server.address(); | ||
t.is(res.status, 301); | ||
t.is(res.headers.location, `https://127.0.0.1:${port}/foobar`); | ||
t.is(response.status, 301); | ||
t.is(response.headers.location, `https://127.0.0.1:${port}/foobar`); | ||
}); | ||
test('does not redirect http to https', async t => { | ||
test('does not redirect http to https', async (t) => { | ||
const proxy = new ProxyServer({ redirect: false }); | ||
await proxy.listen(); | ||
const res = await request(proxy.server).get('/foobar'); | ||
t.is(res.status, 200); | ||
const response = await request(proxy.server).get('/foobar'); | ||
t.is(response.status, 200); | ||
}); | ||
test('serves acme challenge', async t => { | ||
test('serves acme challenge', async (t) => { | ||
const config = { | ||
@@ -39,8 +39,24 @@ certbot: { | ||
const proxy = new ProxyServer(config); | ||
const res = await request(proxy.server).get( | ||
const response = await request(proxy.server).get( | ||
`/.well-known/acme-challenge/${config.certbot.name}` | ||
); | ||
t.is(res.status, 200); | ||
t.is(res.headers['content-type'], 'text/plain; charset=utf-8'); | ||
t.is(res.text, config.certbot.contents); | ||
t.is(response.status, 200); | ||
t.is(response.headers['content-type'], 'text/plain; charset=utf-8'); | ||
t.is(response.text, config.certbot.contents); | ||
}); | ||
test('redirects http to https and does not remove prefix', async (t) => { | ||
const proxy = new ProxyServer({ removeWwwPrefix: false }); | ||
await proxy.listen(); | ||
const response = await request(proxy.server).get('/foobar'); | ||
const { port } = proxy.server.address(); | ||
t.is(response.status, 301); | ||
t.is(response.headers.location, `https://127.0.0.1:${port}/foobar`); | ||
}); | ||
test('starts and stops server with proxyProtocol = true', async (t) => { | ||
const proxy = new ProxyServer({ proxyProtocol: true }); | ||
await proxy.listen(); | ||
await proxy.close(); | ||
t.pass(); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9562
122
16
Updatedlodash@^4.17.19