Comparing version 0.2.0 to 0.3.0
10
index.js
@@ -22,2 +22,12 @@ module.exports.html = (body, statusCode = 200, response = {}, cookie = false) => { | ||
module.exports.text = (body, statusCode = 200, response = {}, cookie = false) => { | ||
response.headers = Object.assign({ 'content-type': 'application/text; charset=utf8' }, response.headers); | ||
response.body = body; | ||
response.statusCode = statusCode; | ||
if (cookie) { | ||
response.cookie = cookie; | ||
} | ||
return response; | ||
}; | ||
module.exports.redirect = (location, type = 'permanent', response = {}, cookie = false) => { | ||
@@ -24,0 +34,0 @@ response.headers = Object.assign({ Location: location }, response.headers); |
{ | ||
"name": "arc-reply", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "helper library that simplifies HTTP responses from arc/lambda", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -38,2 +38,12 @@ const tap = require('tap'); | ||
tap.test('text', t => { | ||
const r = reply.text('two pints of lager'); | ||
t.match(r, { | ||
headers: { 'content-type': 'application/text; charset=utf8' }, | ||
body: 'two pints of lager', | ||
statusCode: 200 | ||
}); | ||
t.end(); | ||
}); | ||
tap.test('json w cookies and header', t => { | ||
@@ -40,0 +50,0 @@ const r = reply.json({ packet: 'crisps' }, 200, { headers: { 'blah-blah': 'blah' } }, 'token=blah123'); |
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
5161
127