Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

httpquery

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httpquery - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

5

CHANGES.md
# CHANGES to httpquery
## 0.8.0
- feat: support `directory` and `passthroughErrors`
- fix: indicate character may also be missing in error message
## 0.7.0

@@ -4,0 +9,0 @@

14

Node/bin/optionDefinitions.js

@@ -27,6 +27,18 @@ import {readFileSync} from 'fs';

name: 'path', type: String,
description: 'The path on top of `cwd`. Defaults to the empty string',
description: 'The path on top of `cwd`. This will be used for ' +
'comparisons with `directory`, Defaults to the empty string',
typeLabel: '{underline PATH}'
},
{
name: 'directory', type: String,
description: 'Files not in this path (the `path` + `req.url`) will be ' +
'passed on to `next`. Defaults to none',
typeLabel: '{underline NAMESPACE}'
},
{
name: 'passthroughErrors', type: Boolean,
description: 'Whether to pass through errors with `next()`. Defaults to ' +
'`false`'
},
{
name: 'debug', alias: 'd', type: Boolean,

@@ -33,0 +45,0 @@ description: 'Whether or not to show extra debugging details; not ' +

32

Node/index.js

@@ -27,3 +27,3 @@ // Todo: More middleware passing options besides jsonData; ensure can use

const handleJsonata = ({
req, res, responseHeaders, fileContents, exitError, finish
req, res, responseHeaders, fileContents, exitError, finish, next
}) => {

@@ -44,3 +44,3 @@ const jsonataExpression = jsonata(

if (error) {
exitError(res, responseHeaders, error.message);
exitError(res, responseHeaders, error.message, next);
return;

@@ -135,4 +135,12 @@ }

const debug = cfg.debug ?? false;
const {directory, passthroughErrors} = cfg;
const exitError = (res, responseHeaders, err) => {
const exitError = (res, responseHeaders, err, next) => {
if (passthroughErrors) {
if (next) {
next(err);
return;
}
return;
}
const errorMessage = debug ? err : 'ERROR';

@@ -226,3 +234,8 @@ write(

if (!(/\w/u).test(url[0]) || (/\.\./u).test(url)) {
exitError(res, responseHeaders, 'Disallowed character in file name');
exitError(
res,
responseHeaders,
'Disallowed or missing character in file name',
next
);
return;

@@ -235,5 +248,10 @@ }

try {
fileContents = await readFile(join(cwd, path, url));
const directoryFile = join(path, url);
if (directory && directoryFile.startsWith(directory)) {
next();
return;
}
fileContents = await readFile(join(cwd, directoryFile));
} catch (err) {
exitError(res, responseHeaders, err.message);
exitError(res, responseHeaders, err.message, next);
return;

@@ -262,3 +280,3 @@ }

handleJsonata({
req, res, responseHeaders, fileContents, exitError, finish
req, res, responseHeaders, fileContents, exitError, finish, next
});

@@ -265,0 +283,0 @@ return;

{
"name": "httpquery",
"version": "0.7.0",
"version": "0.8.0",
"author": "Brett Zamir",

@@ -5,0 +5,0 @@ "contributors": [],

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc