Socket
Socket
Sign inDemoInstall

eobject

Package Overview
Dependencies
63
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.3 to 0.3.4

2

.upm/store.json

@@ -1,1 +0,1 @@

{"version":2,"languages":{"nodejs-npm":{"specfileHash":"62ed00a06529c2c14d59b4b412ab0448","lockfileHash":"86cb68b90f92d7ef218d86826bd74fdc"}}}
{"version":2,"languages":{"nodejs-npm":{"specfileHash":"5525695fdf691fea35a745776354bcdf","lockfileHash":"f17c32bd10deafa2c8d7752bb9df81fb"}}}
var object = {}
var setup = false;
var settings = {
"debug": false,
"secureonly": false,
"rootpagedisplay": true,
"ifnotfoundsendtonext": true,
"ifemptyobjectstillsend": true,
"acceptqueryfunctionarguments": true,
"acceptbodyfunctionarguments": false,
"requestdata": false,
"executefunctionintrycatch": true,
"functionerrormessage": {error:"There was an issue."},
"validtypes": {
"function": true,
"object": true,
"string": true,
"number": true
debug: false,
secureonly: false,
rootpagedisplay: true,
ifnotfoundsendtonext: true,
ifemptyobjectstillsend: true,
acceptqueryfunctionarguments: true,
acceptbodyfunctionarguments: false,
requestdata: false,
responsedata: false,
executefunctionintrycatch: true,
functionerrormessage: (err) => {return {error:err}},
validtypes: {
function: true,
object: true,
string: true,
number: true
}

@@ -124,9 +125,26 @@ };

if(settings.requestdata === true) {
var lastargument = functionArguments[functionArguments.length-1]
var lastargumentdata = functionArgumentsData[functionArgumentsData.length-1]
debug("Checking if last argument is 'req'",lastargument,lastargumentdata)
for(argument in functionArguments) {
var lastargument = functionArguments[argument]
var lastargumentdata = functionArgumentsData[argument]
debug("Checking if argument is 'req'",lastargument,lastargumentdata)
if((lastargument === "req")&&(lastargumentdata === undefined)) {
functionArgumentsData[argument] = req
}
}
}
if((lastargument === "req")&&(lastargumentdata === undefined)) {
functionArgumentsData[functionArgumentsData.length-1] = req
// RESPONSE DATA
if(settings.responsedata === true) {
for(argument in functionArguments) {
var lastargument = functionArguments[argument]
var lastargumentdata = functionArgumentsData[argument]
debug("Checking if argument is 'res'",lastargument,lastargumentdata)
if((lastargument === "res")&&(lastargumentdata === undefined)) {
functionArgumentsData[argument] = res
}
}

@@ -140,2 +158,3 @@ }

if(settings.executefunctionintrycatch) {
debug("Function excecuting in a try/catch")
try {

@@ -145,5 +164,9 @@ functionResult = await currentPathData(...functionArgumentsData)

debug("Function execution resulted in a error",e)
return res.json(settings.functionerrormessage)
var errormessage = settings.functionerrormessage(e)
return res.json(errormessage)
}
} else {
debug("Function excecuting without try/catch")
functionResult = await currentPathData(...functionArgumentsData)

@@ -150,0 +173,0 @@ }

{
"name": "eobject",
"version": "0.3.3",
"version": "0.3.4",
"description": "Generate Express.js routes easily and automatically from a object.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -16,3 +16,3 @@ # eobject

[Learn more about the usage of functions in eobject in the dedicated section] (#functions)
[Learn more about the usage of functions in eobject in the dedicated section](#functions)

@@ -68,14 +68,18 @@

{
"debug": false,
"secureonly": false,
"rootpagedisplay": true,
"ifnotfoundsendtonext": true,
"ifemptyobjectstillsend": true,
"acceptqueryfunctionarguments": true,
"acceptbodyfunctionarguments": true,
"validtypes": {
"function": true,
"object": true,
"string": true,
"number": true
debug: false,
secureonly: false,
rootpagedisplay: true,
ifnotfoundsendtonext: true,
ifemptyobjectstillsend: true,
acceptqueryfunctionarguments: true,
acceptbodyfunctionarguments: false,
requestdata: false,
responsedata: false,
executefunctionintrycatch: true,
functionerrormessage: (err) => {return {error:err}},
validtypes: {
function: true,
object: true,
string: true,
number: true
}

@@ -85,3 +89,3 @@ }

#### Settings Options
The following table specifies each settings option:
The following table specifies each settings option: (See above for default settings)

@@ -93,6 +97,9 @@ | Name | Description |

| rootpagedisplay | Option to display the root 'welcome' screen. |
| ifnotfoundsendtonext | Option to not send any unresolved requests beyond eobject. |
| ifnotfoundsendtonext | Option to send any unresolved requests beyond eobject to other Express.js routes. |
| ifemptyobjectstillsend | Option to still send any empty objects (empty object: {}) back to the client. |
| acceptqueryfunctionarguments | Option to disable accepting function arguments from URL query strings. |
| acceptbodyfunctionarguments | Option to enable accepting function arguments from the request body. ([Read enabling function argument matching from body](#Pulling-arguments-from-the-query-string-of-the-requested-URL)) |
| acceptbodyfunctionarguments | Option to enable accepting function arguments from the request body. ([See: "Pulling Arguments From the Query String of the Requested URL"](#Pulling-arguments-from-the-query-string-of-the-requested-URL)) |
| requestdata | Option to provide the [Express.js request (req)](https://expressjs.com/en/4x/api.html#req) object as the last parameter in a given function, if said last parameter is named `req`. |
| executefunctionintrycatch | Option to execute [functions](#functions) in a `try/catch`, where eobject will return a error message (which can be configured in the `functionerrormessage` option, see below) or not. If the function is not executed in a `try/catch`, if the function throws an error, the entire program will exit. |
| functionerrormessage | A function that configures the error message that is displayed when a function returns an error. |
| validtypes | Options to independently disable any specific data type from being used in eobject. |

@@ -113,3 +120,3 @@

**Example:**
If the argument name is firstName:
If the argument name is `firstName`:
`/users/add?firstName=example@example.com` - *Will Work*

@@ -119,2 +126,4 @@ `/users/add?FirstName=example@example.com` - Will Not Work

Thus, it is recommended that function names do be named in lower-case. In the future, function names will become case-insensitive.
### Pulling arguments from the request body

@@ -121,0 +130,0 @@ eobject also has the option of pulling argument data from a JSON-formatted body of a HTTP request. **This functionality must be enabled via the `acceptbodyfunctionarguments` option in the [settings] (#settings-options) in order to be used.**

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc