sprucehttp_sjs 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +9 -0
  2. package/index.js +14 -0
  3. package/package.json +27 -27
package/README.md CHANGED
@@ -20,6 +20,7 @@ A module for responding to requests within SpruceHTTP in an SJS file.
20
20
  - [headers()](#headers)
21
21
  - [headerValue(name)](#headervaluename)
22
22
  - [body()](#body)
23
+ - [bodyStream()](#bodystream)
23
24
 
24
25
  ## Documentation:
25
26
  Importing the module:
@@ -217,4 +218,12 @@ Returns the request body as a buffer.
217
218
  ```js
218
219
  console.log(sjs.body().toString("utf8"));
219
220
  // Hello, world!
221
+ ```
222
+
223
+ ### ``bodyStream()``:
224
+ Returns the request body as a buffer.
225
+
226
+ ```js
227
+ console.log(sjs.bodyStream().read(13).toString("utf8"));
228
+ // Hello, world!
220
229
  ```
package/index.js CHANGED
@@ -166,5 +166,19 @@ module.exports = {
166
166
  retVal = fs.readFileSync(process.env.reqBody);
167
167
  }
168
168
  return retVal;
169
+ },
170
+
171
+ /**
172
+ * Returns the body of the request as an fs.ReadStream.
173
+ *
174
+ * @param {string | Object} [options] The options to pass to fs.createReadStream.
175
+ * @returns {fs.ReadStream} A ReadStream of the body of the request.
176
+ */
177
+ bodyStream: function(options) {
178
+ let retVal = undefined;
179
+ if (process.env.reqBody) {
180
+ retVal = fs.createReadStream(process.env.reqBody, options);
181
+ }
182
+ return retVal;
169
183
  }
170
184
  }
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
- {
2
- "name": "sprucehttp_sjs",
3
- "version": "1.0.6",
4
- "description": "A module for responding to requests within SpruceHTTP in an SJS file",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "keywords": [
10
- "http",
11
- "server",
12
- "https",
13
- "spruce",
14
- "sprucehttp"
15
- ],
16
- "homepage": "https://stibarc.dev/spruce/",
17
- "bugs": {
18
- "url": "https://stibarc.dev/spruce/reportbug/",
19
- "email": "herronjo@stibarc.dev"
20
- },
21
- "author": {
22
- "name": "Joshua Herron",
23
- "email": "herronjo@stibarc.dev",
24
- "url": "https://stibarc.dev"
25
- },
26
- "license": "Copyright (c) STiBaRC LLC. All rights reserved."
27
- }
1
+ {
2
+ "name": "sprucehttp_sjs",
3
+ "version": "1.0.7",
4
+ "description": "A module for responding to requests within SpruceHTTP in an SJS file",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [
10
+ "http",
11
+ "server",
12
+ "https",
13
+ "spruce",
14
+ "sprucehttp"
15
+ ],
16
+ "homepage": "https://stibarc.dev/spruce/",
17
+ "bugs": {
18
+ "url": "https://stibarc.dev/spruce/reportbug/",
19
+ "email": "herronjo@stibarc.dev"
20
+ },
21
+ "author": {
22
+ "name": "Joshua Herron",
23
+ "email": "herronjo@stibarc.dev",
24
+ "url": "https://stibarc.dev"
25
+ },
26
+ "license": "Copyright (c) STiBaRC LLC. All rights reserved."
27
+ }