@specter/specter
Advanced tools
Comparing version 0.0.27 to 0.1.0
@@ -8,3 +8,3 @@ declare type SharedRequest = { | ||
declare type SharedResponse = { | ||
header: Record<string, string>; | ||
headers: Record<string, string>; | ||
body: Record<string, string>; | ||
@@ -11,0 +11,0 @@ }; |
@@ -5,7 +5,7 @@ import SpecterRequest from "./request"; | ||
status?: number; | ||
header: H; | ||
headers: H; | ||
body: B; | ||
error?: any; | ||
nextReqs?: SpecterRequest<any, any, any>[]; | ||
constructor(header: H, body: B); | ||
constructor(headers: H, body: B); | ||
setStatus(status: number): void; | ||
@@ -12,0 +12,0 @@ setNextReqs(...reqs: SpecterRequest<any, any, any>[]): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class SpecterResponse { | ||
constructor(header, body) { | ||
this.header = header; | ||
constructor(headers, body) { | ||
this.headers = headers; | ||
this.body = body; | ||
@@ -12,4 +12,4 @@ } | ||
setNextReqs(...reqs) { | ||
this.header = { | ||
...this.header, | ||
this.headers = { | ||
...this.headers, | ||
"x-specter-next-reqs": reqs.map(req => req.toString()).join("__sep__") | ||
@@ -16,0 +16,0 @@ }; |
@@ -46,9 +46,9 @@ "use strict"; | ||
const response = await service.execute(request); | ||
const header = {}; | ||
for (const [key, value] of Object.entries(response.header)) { | ||
header[key] = value; | ||
const headers = {}; | ||
for (const [key, value] of Object.entries(response.headers)) { | ||
headers[key] = value; | ||
} | ||
header["Content-Type"] = DefaultContentType; | ||
header["access-control-expose-headers"] = Object.keys(header).join(","); | ||
res.writeHead(response.status || 200, header); | ||
headers["Content-Type"] = DefaultContentType; | ||
headers["access-control-expose-headers"] = Object.keys(headers).join(","); | ||
res.writeHead(response.status || 200, headers); | ||
if (response.body) { | ||
@@ -55,0 +55,0 @@ res.end(JSON.stringify(response.body)); |
{ | ||
"name": "@specter/specter", | ||
"version": "0.0.27", | ||
"version": "0.1.0", | ||
"description": "> TODO: description", | ||
@@ -36,6 +36,6 @@ "author": "Yosuke Furukawa <yosuke.furukawa@gmail.com>", | ||
"isomorphic-unfetch": "3.0.0", | ||
"jest": "25.2.7", | ||
"jest": "25.3.0", | ||
"typescript": "3.8.3" | ||
}, | ||
"gitHead": "70d8f35e36d37cb08f337079976b35ac0f09aa0d", | ||
"gitHead": "c6566719e94c2c67191a49b27985b8abb17ac6c8", | ||
"publishConfig": { | ||
@@ -42,0 +42,0 @@ "access": "public" |
15106