solr-proxy
Advanced tools
Comparing version 4.1.1 to 5.0.0
#!/usr/bin/env node | ||
var cli = require('../lib/cli') | ||
var argv = require('minimist')(process.argv.slice(2)) | ||
var SolrProxy = require('../') | ||
const cli = require('../lib/cli') | ||
const argv = require('minimist')(process.argv.slice(2)) | ||
const SolrProxy = require('..') | ||
cli.argv(argv, console.log, SolrProxy) |
@@ -0,1 +1,17 @@ | ||
# [5.0.0](https://github.com/Trott/solr-proxy/compare/v4.1.1...v5.0.0) (2021-01-04) | ||
### config | ||
* use canonical Solr default port for backend ([d581860](https://github.com/Trott/solr-proxy/commit/d5818609380394bd6eb944e340c052f15ab0ff43)) | ||
### BREAKING CHANGES | ||
* If the "backend" (i.e., Solr server) port is not | ||
specified, use the default Solr port of 8983 rather than our own default | ||
of 8080. | ||
Fixes: https://github.com/Trott/solr-proxy/issues/11 | ||
4.1.1 | ||
@@ -2,0 +18,0 @@ ===== |
52
index.js
@@ -1,6 +0,4 @@ | ||
var { URL } = require('url') | ||
var httpProxy = require('http-proxy') | ||
var extend = require('xtend') | ||
var debug = require('debug')('solr-proxy') | ||
var SolrProxy = {} | ||
const httpProxy = require('http-proxy') | ||
const extend = require('xtend') | ||
const debug = require('debug')('solr-proxy') | ||
@@ -13,6 +11,6 @@ /* | ||
*/ | ||
var validateRequest = function (request, options) { | ||
var parsedUrl = new URL(request.url, 'https://www.example.com/') | ||
var path = parsedUrl.pathname | ||
var queryParams = Array.from(parsedUrl.searchParams) | ||
const validateRequest = function (request, options) { | ||
const parsedUrl = new URL(request.url, 'https://www.example.com/') | ||
const path = parsedUrl.pathname | ||
const queryParams = Array.from(parsedUrl.searchParams) | ||
@@ -29,6 +27,6 @@ if (options.validHttpMethods.indexOf(request.method) === -1) { | ||
// This function should return "true" for invalid cases. Confusing, I know. | ||
var paramPrefix = p[0].split('.')[0] // invalidate not just "stream", but "stream.*" | ||
const paramPrefix = p[0].split('.')[0] // invalidate not just "stream", but "stream.*" | ||
if (paramPrefix === 'rows') { | ||
var rows = +p[1] | ||
const rows = +p[1] | ||
if (rows > options.maxRows) { | ||
@@ -40,3 +38,3 @@ return true | ||
if (paramPrefix === 'start') { | ||
var start = +p[1] | ||
const start = +p[1] | ||
if (start > options.maxStart) { | ||
@@ -55,3 +53,3 @@ return true | ||
var defaultOptions = { | ||
const defaultOptions = { | ||
listenPort: 8008, | ||
@@ -63,3 +61,3 @@ validHttpMethods: ['GET'], | ||
host: 'localhost', | ||
port: 8080 | ||
port: 8983 | ||
}, | ||
@@ -70,4 +68,4 @@ maxRows: 200, | ||
var createServer = function (options) { | ||
var proxy = httpProxy.createProxyServer({ target: options.backend }) | ||
const createServer = function (options) { | ||
const proxy = httpProxy.createProxyServer({ target: options.backend }) | ||
@@ -79,3 +77,3 @@ proxy.on('error', function (err, req, res) { | ||
var createServer | ||
let createServer | ||
if (options.ssl) { | ||
@@ -90,3 +88,3 @@ const https = require('https') | ||
// adapted from https://git.io/k5dCxQ | ||
var server = createServer(function (request, response) { | ||
const server = createServer(function (request, response) { | ||
if (validateRequest(request, options)) { | ||
@@ -105,14 +103,16 @@ debug('ALLOWED: ' + request.method + ' ' + request.url) | ||
SolrProxy.start = function (port, options) { | ||
options = options || {} | ||
options.backend = extend(defaultOptions.backend, options.backend) | ||
options = extend(defaultOptions, options) | ||
const SolrProxy = { | ||
start: function (port, options) { | ||
options = options || {} | ||
options.backend = extend(defaultOptions.backend, options.backend) | ||
options = extend(defaultOptions, options) | ||
port = port || options.listenPort | ||
port = port || options.listenPort | ||
var server = createServer(options) | ||
server.listen(port) | ||
return server | ||
const server = createServer(options) | ||
server.listen(port) | ||
return server | ||
} | ||
} | ||
module.exports = SolrProxy |
@@ -1,3 +0,3 @@ | ||
var createProxyOptions = function (argv) { | ||
var proxyOptions = { | ||
const createProxyOptions = function (argv) { | ||
const proxyOptions = { | ||
backend: {} | ||
@@ -38,7 +38,7 @@ } | ||
module.exports = function (argv, stdout, SolrProxy) { | ||
var usageMessage = 'Usage: solr-proxy [options]\n' + | ||
const usageMessage = 'Usage: solr-proxy [options]\n' + | ||
'\n' + | ||
'Options:\n' + | ||
' --port Listen on this port [default: 8008]\n' + | ||
' --backendPort Solr backend port [default: 8080]\n' + | ||
' --backendPort Solr backend port [default: 8983]\n' + | ||
' --backendHost Solr backend host [default: "localhost"]\n' + | ||
@@ -63,3 +63,3 @@ ' --validPaths Allowed paths (comma delimited) [default: "/solr/select"]\n' + | ||
if (argv.version || argv.v) { | ||
var version = require('../../package.json').version | ||
const version = require('../../package.json').version | ||
stdout(version) | ||
@@ -74,3 +74,3 @@ return | ||
var proxyOptions = createProxyOptions(argv) | ||
const proxyOptions = createProxyOptions(argv) | ||
@@ -77,0 +77,0 @@ SolrProxy.start(argv.port, proxyOptions) |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "4.1.1", | ||
"version": "5.0.0", | ||
"author": "Rich Trott <rtrott@gmail.com>", | ||
@@ -26,8 +26,7 @@ "bugs": { | ||
"index.js", | ||
"lib", | ||
"npm-shrinkwrap.json" | ||
"lib" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Trott/solr-proxy.git" | ||
"url": "git://github.com/Trott/solr-proxy.git" | ||
}, | ||
@@ -41,6 +40,9 @@ "dependencies": { | ||
"devDependencies": { | ||
"@hapi/lab": "^23.0.0", | ||
"@hapi/lab": "^24.1.0", | ||
"@semantic-release/changelog": "^5.0.1", | ||
"@semantic-release/git": "^9.0.0", | ||
"code": "^5.2.4", | ||
"dependency-check": "^4.1.0", | ||
"standard": "^14.3.1" | ||
"semantic-release": "^17.1.2", | ||
"standard": "^16.0.0" | ||
}, | ||
@@ -50,3 +52,26 @@ "engines": { | ||
}, | ||
"license": "MIT" | ||
"license": "MIT", | ||
"release": { | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
[ | ||
"@semantic-release/changelog", | ||
{ | ||
"changelogFile": "CHANGELOG.md" | ||
} | ||
], | ||
"@semantic-release/npm", | ||
[ | ||
"@semantic-release/git", | ||
{ | ||
"assets": [ | ||
"CHANGELOG.md", | ||
"package.json" | ||
], | ||
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" | ||
} | ||
] | ||
] | ||
} | ||
} |
@@ -39,3 +39,3 @@ solr-proxy | ||
--port Listen on this port [default: 8008] | ||
--backendPort Solr backend port [default: 8080] | ||
--backendPort Solr backend port [default: 8983] | ||
--backendHost Solr backend host [default: "localhost"] | ||
@@ -42,0 +42,0 @@ --validPaths Allowed paths (comma delimited) [default: "/solr/select"] |
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
12890
7