sprucehttp_sjs 1.0.5 → 1.0.8

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 +21 -0
  2. package/index.js +23 -0
  3. package/package.json +27 -27
package/README.md CHANGED
@@ -13,12 +13,14 @@ A module for responding to requests within SpruceHTTP in an SJS file.
13
13
  - [requestIP()](#requestip)
14
14
  - [method()](#method)
15
15
  - [path()](#path)
16
+ - [pathInfo()](#pathinfo)
16
17
  - [query()](#query)
17
18
  - [queryValue(key)](#queryvaluekey)
18
19
  - [httpVersion()](#httpversion)
19
20
  - [headers()](#headers)
20
21
  - [headerValue(name)](#headervaluename)
21
22
  - [body()](#body)
23
+ - [bodyStream()](#bodystream)
22
24
 
23
25
  ## Documentation:
24
26
  Importing the module:
@@ -143,6 +145,17 @@ console.log(sjs.path());
143
145
  // /index.sjs
144
146
  ```
145
147
 
148
+ ### ``pathInfo()``:
149
+ Returns the request's info path.
150
+
151
+ ```js
152
+ // Using path /index.sjs/info
153
+ console.log(sjs.path());
154
+ console.log(sjs.pathInfo());
155
+ // /index.sjs
156
+ // /info
157
+ ```
158
+
146
159
  ### ``query()``:
147
160
  Returns the request query.
148
161
 
@@ -205,4 +218,12 @@ Returns the request body as a buffer.
205
218
  ```js
206
219
  console.log(sjs.body().toString("utf8"));
207
220
  // Hello, world!
221
+ ```
222
+
223
+ ### ``bodyStream()``:
224
+ Returns the request body as a ReadStream.
225
+
226
+ ```js
227
+ console.log(sjs.bodyStream().read(13).toString("utf8"));
228
+ // Hello, world!
208
229
  ```
package/index.js CHANGED
@@ -99,6 +99,15 @@ module.exports = {
99
99
  return process.env.reqPath;
100
100
  },
101
101
 
102
+ /**
103
+ * Returns the request's info path.
104
+ *
105
+ * @returns {string} The request's info path.
106
+ */
107
+ pathInfo: function() {
108
+ return process.env.reqPathInfo;
109
+ },
110
+
102
111
  /**
103
112
  * Returns the parsed query string of the request.
104
113
  *
@@ -157,5 +166,19 @@ module.exports = {
157
166
  retVal = fs.readFileSync(process.env.reqBody);
158
167
  }
159
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;
160
183
  }
161
184
  }
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
- {
2
- "name": "sprucehttp_sjs",
3
- "version": "1.0.5",
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.8",
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
+ }