✔ returns string with implicit return
✔ returns json for explicit response
✔ returns json for `ok` helper response
✔ returns json for `created` helper response
✔ returns route params
✔ returns query params
✔ returns HTML content
✔ sets security headers by default
✔ accepts POST params as JSON
✔ accepts POST params as Form
✔ compose functions & return string
✔ receives file upload
✖ compose functions & append string Rejected promise returned by test
✖ built-in validation with valid request Rejected promise returned by test
✖ built-in validation strips undefined params Rejected promise returned by test
✖ built-in validation with invalid request
4 tests failed
compose functions & append string
/Users/zaiste/code/huncwotjs/huncwot/node_modules/axios/lib/core/createError.js:16
Rejected promise returned by test. Reason:
Error {
config: {
adapter: Function httpAdapter {},
baseURL: 'http://localhost:3000',
data: undefined,
headers: {
Accept: 'application/json, text/plain, */*',
'User-Agent': 'axios/0.19.0',
},
maxContentLength: -1,
method: 'get',
timeout: 0,
transformRequest: [
Function transformRequest {},
],
transformResponse: [
Function transformResponse {},
],
url: 'http://localhost:3000/prepend-compose',
validateStatus: Function validateStatus {},
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
},
isAxiosError: true,
request: ClientRequest {
_contentLength: 0,
_ended: true,
_events: {
abort: Function {},
aborted: Function {},
error: Function {},
prefinish: Function requestOnPrefinish {},
socket: Function {},
timeout: Function {},
},
_eventsCount: 6,
_hasBody: true,
_header: `GET /prepend-compose HTTP/1.1␍␊
Accept: application/json, text/plain, */*␍␊
User-Agent: axios/0.19.0␍␊
Host: localhost:3000␍␊
Connection: close␍␊
␍␊
`,
_headerSent: true,
_last: true,
_maxListeners: undefined,
_onPendingData: Function noopPendingOutput {},
_redirectable: Writable {
_currentRequest: [Circular],
_currentUrl: 'http://localhost:3000/prepend-compose',
_events: Object { … },
_eventsCount: 2,
_maxListeners: undefined,
_onNativeResponse: Function {},
_options: Object { … },
_redirectCount: 0,
_redirects: [],
_requestBodyBuffers: [],
_requestBodyLength: 0,
_writableState: WritableState [ … ],
writable: true,
},
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_trailer: '',
aborted: false,
agent: Agent {
_events: Object { … },
_eventsCount: 1,
_maxListeners: undefined,
defaultPort: 80,
freeSockets: {},
keepAlive: false,
keepAliveMsecs: 1000,
maxFreeSockets: 256,
maxSockets: Infinity,
options: Object { … },
protocol: 'http:',
requests: {},
sockets: Object { … },
},
chunkedEncoding: false,
connection: Socket {
_events: Object { … },
_eventsCount: 6,
_hadError: false,
_host: 'localhost',
_httpMessage: [Circular],
_maxListeners: undefined,
_parent: null,
_pendingData: null,
_pendingEncoding: '',
_readableState: ReadableState [ … ],
_server: null,
_sockname: null,
_writableState: WritableState [ … ],
allowHalfOpen: false,
connecting: false,
parser: null,
readable: true,
server: null,
writable: false,
[Symbol(asyncId)]: 78,
[Symbol(kHandle)]: TCP { … },
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
},
finished: true,
maxHeadersCount: null,
method: 'GET',
outputData: [],
outputSize: 0,
parser: null,
path: '/prepend-compose',
res: IncomingMessage {
_consuming: false,
_dumped: false,
_events: Object { … },
_eventsCount: 3,
_maxListeners: undefined,
_readableState: ReadableState [ … ],
aborted: false,
client: Socket { … },
complete: true,
connection: Socket { … },
headers: Object { … },
httpVersion: '1.1',
httpVersionMajor: 1,
httpVersionMinor: 1,
method: null,
rawHeaders: Array [ … ],
rawTrailers: [],
readable: false,
redirects: [],
req: [Circular],
responseUrl: 'http://localhost:3000/prepend-compose',
socket: Socket { … },
statusCode: 500,
statusMessage: 'Internal Server Error',
trailers: {},
upgrade: false,
url: '',
},
sendDate: false,
shouldKeepAlive: false,
socket: Socket {
_events: Object { … },
_eventsCount: 6,
_hadError: false,
_host: 'localhost',
_httpMessage: [Circular],
_maxListeners: undefined,
_parent: null,
_pendingData: null,
_pendingEncoding: '',
_readableState: ReadableState [ … ],
_server: null,
_sockname: null,
_writableState: WritableState [ … ],
allowHalfOpen: false,
connecting: false,
parser: null,
readable: true,
server: null,
writable: false,
[Symbol(asyncId)]: 78,
[Symbol(kHandle)]: TCP { … },
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
},
socketPath: undefined,
timeoutCb: null,
upgradeOrConnect: false,
useChunkedEncodingByDefault: false,
writable: true,
[Symbol(kNeedDrain)]: false,
[Symbol(isCorked)]: false,
[Symbol(kOutHeaders)]: {
accept: Array [ … ],
host: Array [ … ],
'user-agent': Array [ … ],
},
},
response: {
config: {
adapter: Function httpAdapter {},
baseURL: 'http://localhost:3000',
data: undefined,
headers: Object { … },
maxContentLength: -1,
method: 'get',
timeout: 0,
transformRequest: Array [ … ],
transformResponse: Array [ … ],
url: 'http://localhost:3000/prepend-compose',
validateStatus: Function validateStatus {},
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
},
data: `␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
TypeError
␊
The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type undefined
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
buffer.js:693:11␊
␊
␊
Function.byteLength␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
index.js:244:47␊
␊
␊
␊
␊
} else {␊
if (!response.getHeader('Content-Type'))␊
response.setHeader('Content-Type', type || 'text/plain');␊
}␊
␊
response.setHeader('Content-Length', Buffer.byteLength(str));␊
response.end(str);␊
};␊
␊
const handleRequest = async context => {␊
const { headers } = context.request;␊
␊
␊
␊
␊
␊
internal/process/task_queues.js:93:5␊
␊
␊
processTicksAndRejections␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
Request
␊
␊
␊
URL | ␊
/prepend-compose | ␊
␊
␊
␊
Method | ␊
GET | ␊
␊
␊
␊
Headers
␊
␊
␊
ACCEPT | ␊
application/json, text/plain, */* | ␊
␊
␊
USER-AGENT | ␊
axios/0.19.0 | ␊
␊
␊
HOST | ␊
localhost:3000 | ␊
␊
␊
␊
Cookies
␊
␊
␊
␊
␊
␊
␊
`,
headers: {
connection: 'close',
'content-type': 'text/html',
date: 'Thu, 03 Oct 2019 09:50:37 GMT',
'transfer-encoding': 'chunked',
},
request: ClientRequest {
_contentLength: 0,
_ended: true,
_events: Object { … },
_eventsCount: 6,
_hasBody: true,
_header: `GET /prepend-compose HTTP/1.1␍␊
Accept: application/json, text/plain, */*␍␊
User-Agent: axios/0.19.0␍␊
Host: localhost:3000␍␊
Connection: close␍␊
␍␊
`,
_headerSent: true,
_last: true,
_maxListeners: undefined,
_onPendingData: Function noopPendingOutput {},
_redirectable: Writable { … },
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_trailer: '',
aborted: false,
agent: Agent { … },
chunkedEncoding: false,
connection: Socket { … },
finished: true,
maxHeadersCount: null,
method: 'GET',
outputData: [],
outputSize: 0,
parser: null,
path: '/prepend-compose',
res: IncomingMessage { … },
sendDate: false,
shouldKeepAlive: false,
socket: Socket { … },
socketPath: undefined,
timeoutCb: null,
upgradeOrConnect: false,
useChunkedEncodingByDefault: false,
writable: true,
[Symbol(kNeedDrain)]: false,
[Symbol(isCorked)]: false,
[Symbol(kOutHeaders)]: Object { … },
},
status: 500,
statusText: 'Internal Server Error',
},
toJSON: Function {},
message: 'Request failed with status code 500',
}
createError (node_modules/axios/lib/core/createError.js:16:15)
settle (node_modules/axios/lib/core/settle.js:17:12)
IncomingMessage.handleStreamEnd (node_modules/axios/lib/adapters/http.js:237:11)
built-in validation with valid request
/Users/zaiste/code/huncwotjs/huncwot/node_modules/axios/lib/core/createError.js:16
Rejected promise returned by test. Reason:
Error {
config: {
adapter: Function httpAdapter {},
baseURL: 'http://localhost:3000',
data: undefined,
headers: {
Accept: 'application/json, text/plain, */*',
'User-Agent': 'axios/0.19.0',
},
maxContentLength: -1,
method: 'get',
timeout: 0,
transformRequest: [
Function transformRequest {},
],
transformResponse: [
Function transformResponse {},
],
url: 'http://localhost:3000/request-validation?name=Zaiste',
validateStatus: Function validateStatus {},
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
},
isAxiosError: true,
request: ClientRequest {
_contentLength: 0,
_ended: true,
_events: {
abort: Function {},
aborted: Function {},
error: Function {},
prefinish: Function requestOnPrefinish {},
socket: Function {},
timeout: Function {},
},
_eventsCount: 6,
_hasBody: true,
_header: `GET /request-validation?name=Zaiste HTTP/1.1␍␊
Accept: application/json, text/plain, */*␍␊
User-Agent: axios/0.19.0␍␊
Host: localhost:3000␍␊
Connection: close␍␊
␍␊
`,
_headerSent: true,
_last: true,
_maxListeners: undefined,
_onPendingData: Function noopPendingOutput {},
_redirectable: Writable {
_currentRequest: [Circular],
_currentUrl: 'http://localhost:3000/request-validation?name=Zaiste',
_events: Object { … },
_eventsCount: 2,
_maxListeners: undefined,
_onNativeResponse: Function {},
_options: Object { … },
_redirectCount: 0,
_redirects: [],
_requestBodyBuffers: [],
_requestBodyLength: 0,
_writableState: WritableState [ … ],
writable: true,
},
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_trailer: '',
aborted: false,
agent: Agent {
_events: Object { … },
_eventsCount: 1,
_maxListeners: undefined,
defaultPort: 80,
freeSockets: {},
keepAlive: false,
keepAliveMsecs: 1000,
maxFreeSockets: 256,
maxSockets: Infinity,
options: Object { … },
protocol: 'http:',
requests: {},
sockets: Object { … },
},
chunkedEncoding: false,
connection: Socket {
_events: Object { … },
_eventsCount: 6,
_hadError: false,
_host: 'localhost',
_httpMessage: [Circular],
_maxListeners: undefined,
_parent: null,
_pendingData: null,
_pendingEncoding: '',
_readableState: ReadableState [ … ],
_server: null,
_sockname: null,
_writableState: WritableState [ … ],
allowHalfOpen: false,
connecting: false,
parser: null,
readable: true,
server: null,
writable: false,
[Symbol(asyncId)]: 84,
[Symbol(kHandle)]: TCP { … },
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
},
finished: true,
maxHeadersCount: null,
method: 'GET',
outputData: [],
outputSize: 0,
parser: null,
path: '/request-validation?name=Zaiste',
res: IncomingMessage {
_consuming: false,
_dumped: false,
_events: Object { … },
_eventsCount: 3,
_maxListeners: undefined,
_readableState: ReadableState [ … ],
aborted: false,
client: Socket { … },
complete: true,
connection: Socket { … },
headers: Object { … },
httpVersion: '1.1',
httpVersionMajor: 1,
httpVersionMinor: 1,
method: null,
rawHeaders: Array [ … ],
rawTrailers: [],
readable: false,
redirects: [],
req: [Circular],
responseUrl: 'http://localhost:3000/request-validation?name=Zaiste',
socket: Socket { … },
statusCode: 500,
statusMessage: 'Internal Server Error',
trailers: {},
upgrade: false,
url: '',
},
sendDate: false,
shouldKeepAlive: false,
socket: Socket {
_events: Object { … },
_eventsCount: 6,
_hadError: false,
_host: 'localhost',
_httpMessage: [Circular],
_maxListeners: undefined,
_parent: null,
_pendingData: null,
_pendingEncoding: '',
_readableState: ReadableState [ … ],
_server: null,
_sockname: null,
_writableState: WritableState [ … ],
allowHalfOpen: false,
connecting: false,
parser: null,
readable: true,
server: null,
writable: false,
[Symbol(asyncId)]: 84,
[Symbol(kHandle)]: TCP { … },
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
},
socketPath: undefined,
timeoutCb: null,
upgradeOrConnect: false,
useChunkedEncodingByDefault: false,
writable: true,
[Symbol(kNeedDrain)]: false,
[Symbol(isCorked)]: false,
[Symbol(kOutHeaders)]: {
accept: Array [ … ],
host: Array [ … ],
'user-agent': Array [ … ],
},
},
response: {
config: {
adapter: Function httpAdapter {},
baseURL: 'http://localhost:3000',
data: undefined,
headers: Object { … },
maxContentLength: -1,
method: 'get',
timeout: 0,
transformRequest: Array [ … ],
transformResponse: Array [ … ],
url: 'http://localhost:3000/request-validation?name=Zaiste',
validateStatus: Function validateStatus {},
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
},
data: `␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
TypeError
␊
The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type undefined
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
buffer.js:693:11␊
␊
␊
Function.byteLength␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
index.js:244:47␊
␊
␊
␊
␊
} else {␊
if (!response.getHeader('Content-Type'))␊
response.setHeader('Content-Type', type || 'text/plain');␊
}␊
␊
response.setHeader('Content-Length', Buffer.byteLength(str));␊
response.end(str);␊
};␊
␊
const handleRequest = async context => {␊
const { headers } = context.request;␊
␊
␊
␊
␊
␊
internal/process/task_queues.js:93:5␊
␊
␊
processTicksAndRejections␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
Request
␊
␊
␊
URL | ␊
/request-validation?name=Zaiste | ␊
␊
␊
␊
Method | ␊
GET | ␊
␊
␊
␊
Headers
␊
␊
␊
ACCEPT | ␊
application/json, text/plain, */* | ␊
␊
␊
USER-AGENT | ␊
axios/0.19.0 | ␊
␊
␊
HOST | ␊
localhost:3000 | ␊
␊
␊
␊
Cookies
␊
␊
␊
␊
␊
␊
␊
`,
headers: {
connection: 'close',
'content-type': 'text/html',
date: 'Thu, 03 Oct 2019 09:50:37 GMT',
'transfer-encoding': 'chunked',
},
request: ClientRequest {
_contentLength: 0,
_ended: true,
_events: Object { … },
_eventsCount: 6,
_hasBody: true,
_header: `GET /request-validation?name=Zaiste HTTP/1.1␍␊
Accept: application/json, text/plain, */*␍␊
User-Agent: axios/0.19.0␍␊
Host: localhost:3000␍␊
Connection: close␍␊
␍␊
`,
_headerSent: true,
_last: true,
_maxListeners: undefined,
_onPendingData: Function noopPendingOutput {},
_redirectable: Writable { … },
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_trailer: '',
aborted: false,
agent: Agent { … },
chunkedEncoding: false,
connection: Socket { … },
finished: true,
maxHeadersCount: null,
method: 'GET',
outputData: [],
outputSize: 0,
parser: null,
path: '/request-validation?name=Zaiste',
res: IncomingMessage { … },
sendDate: false,
shouldKeepAlive: false,
socket: Socket { … },
socketPath: undefined,
timeoutCb: null,
upgradeOrConnect: false,
useChunkedEncodingByDefault: false,
writable: true,
[Symbol(kNeedDrain)]: false,
[Symbol(isCorked)]: false,
[Symbol(kOutHeaders)]: Object { … },
},
status: 500,
statusText: 'Internal Server Error',
},
toJSON: Function {},
message: 'Request failed with status code 500',
}
createError (node_modules/axios/lib/core/createError.js:16:15)
settle (node_modules/axios/lib/core/settle.js:17:12)
IncomingMessage.handleStreamEnd (node_modules/axios/lib/adapters/http.js:237:11)
built-in validation strips undefined params
/Users/zaiste/code/huncwotjs/huncwot/node_modules/axios/lib/core/createError.js:16
Rejected promise returned by test. Reason:
Error {
config: {
adapter: Function httpAdapter {},
baseURL: 'http://localhost:3000',
data: undefined,
headers: {
Accept: 'application/json, text/plain, */*',
'User-Agent': 'axios/0.19.0',
},
maxContentLength: -1,
method: 'get',
timeout: 0,
transformRequest: [
Function transformRequest {},
],
transformResponse: [
Function transformResponse {},
],
url: 'http://localhost:3000/request-validation?name=Zaiste&admin=true',
validateStatus: Function validateStatus {},
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
},
isAxiosError: true,
request: ClientRequest {
_contentLength: 0,
_ended: true,
_events: {
abort: Function {},
aborted: Function {},
error: Function {},
prefinish: Function requestOnPrefinish {},
socket: Function {},
timeout: Function {},
},
_eventsCount: 6,
_hasBody: true,
_header: `GET /request-validation?name=Zaiste&admin=true HTTP/1.1␍␊
Accept: application/json, text/plain, */*␍␊
User-Agent: axios/0.19.0␍␊
Host: localhost:3000␍␊
Connection: close␍␊
␍␊
`,
_headerSent: true,
_last: true,
_maxListeners: undefined,
_onPendingData: Function noopPendingOutput {},
_redirectable: Writable {
_currentRequest: [Circular],
_currentUrl: 'http://localhost:3000/request-validation?name=Zaiste&admin=true',
_events: Object { … },
_eventsCount: 2,
_maxListeners: undefined,
_onNativeResponse: Function {},
_options: Object { … },
_redirectCount: 0,
_redirects: [],
_requestBodyBuffers: [],
_requestBodyLength: 0,
_writableState: WritableState [ … ],
writable: true,
},
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_trailer: '',
aborted: false,
agent: Agent {
_events: Object { … },
_eventsCount: 1,
_maxListeners: undefined,
defaultPort: 80,
freeSockets: {},
keepAlive: false,
keepAliveMsecs: 1000,
maxFreeSockets: 256,
maxSockets: Infinity,
options: Object { … },
protocol: 'http:',
requests: {},
sockets: Object { … },
},
chunkedEncoding: false,
connection: Socket {
_events: Object { … },
_eventsCount: 6,
_hadError: false,
_host: 'localhost',
_httpMessage: [Circular],
_maxListeners: undefined,
_parent: null,
_pendingData: null,
_pendingEncoding: '',
_readableState: ReadableState [ … ],
_server: null,
_sockname: null,
_writableState: WritableState [ … ],
allowHalfOpen: false,
connecting: false,
parser: null,
readable: true,
server: null,
writable: false,
[Symbol(asyncId)]: 87,
[Symbol(kHandle)]: TCP { … },
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
},
finished: true,
maxHeadersCount: null,
method: 'GET',
outputData: [],
outputSize: 0,
parser: null,
path: '/request-validation?name=Zaiste&admin=true',
res: IncomingMessage {
_consuming: false,
_dumped: false,
_events: Object { … },
_eventsCount: 3,
_maxListeners: undefined,
_readableState: ReadableState [ … ],
aborted: false,
client: Socket { … },
complete: true,
connection: Socket { … },
headers: Object { … },
httpVersion: '1.1',
httpVersionMajor: 1,
httpVersionMinor: 1,
method: null,
rawHeaders: Array [ … ],
rawTrailers: [],
readable: false,
redirects: [],
req: [Circular],
responseUrl: 'http://localhost:3000/request-validation?name=Zaiste&admin=true',
socket: Socket { … },
statusCode: 500,
statusMessage: 'Internal Server Error',
trailers: {},
upgrade: false,
url: '',
},
sendDate: false,
shouldKeepAlive: false,
socket: Socket {
_events: Object { … },
_eventsCount: 6,
_hadError: false,
_host: 'localhost',
_httpMessage: [Circular],
_maxListeners: undefined,
_parent: null,
_pendingData: null,
_pendingEncoding: '',
_readableState: ReadableState [ … ],
_server: null,
_sockname: null,
_writableState: WritableState [ … ],
allowHalfOpen: false,
connecting: false,
parser: null,
readable: true,
server: null,
writable: false,
[Symbol(asyncId)]: 87,
[Symbol(kHandle)]: TCP { … },
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: null,
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
},
socketPath: undefined,
timeoutCb: null,
upgradeOrConnect: false,
useChunkedEncodingByDefault: false,
writable: true,
[Symbol(kNeedDrain)]: false,
[Symbol(isCorked)]: false,
[Symbol(kOutHeaders)]: {
accept: Array [ … ],
host: Array [ … ],
'user-agent': Array [ … ],
},
},
response: {
config: {
adapter: Function httpAdapter {},
baseURL: 'http://localhost:3000',
data: undefined,
headers: Object { … },
maxContentLength: -1,
method: 'get',
timeout: 0,
transformRequest: Array [ … ],
transformResponse: Array [ … ],
url: 'http://localhost:3000/request-validation?name=Zaiste&admin=true',
validateStatus: Function validateStatus {},
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
},
data: `␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
TypeError
␊
The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type undefined
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
buffer.js:693:11␊
␊
␊
Function.byteLength␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
index.js:244:47␊
␊
␊
␊
␊
} else {␊
if (!response.getHeader('Content-Type'))␊
response.setHeader('Content-Type', type || 'text/plain');␊
}␊
␊
response.setHeader('Content-Length', Buffer.byteLength(str));␊
response.end(str);␊
};␊
␊
const handleRequest = async context => {␊
const { headers } = context.request;␊
␊
␊
␊
␊
␊
internal/process/task_queues.js:93:5␊
␊
␊
processTicksAndRejections␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
␊
Request
␊
␊
␊
URL | ␊
/request-validation?name=Zaiste&admin=true | ␊
␊
␊
␊
Method | ␊
GET | ␊
␊
␊
␊
Headers
␊
␊
␊
ACCEPT | ␊
application/json, text/plain, */* | ␊
␊
␊
USER-AGENT | ␊
axios/0.19.0 | ␊
␊
␊
HOST | ␊
localhost:3000 | ␊
␊
␊
␊
Cookies
␊
␊
␊
␊
␊
␊
␊
`,
headers: {
connection: 'close',
'content-type': 'text/html',
date: 'Thu, 03 Oct 2019 09:50:37 GMT',
'transfer-encoding': 'chunked',
},
request: ClientRequest {
_contentLength: 0,
_ended: true,
_events: Object { … },
_eventsCount: 6,
_hasBody: true,
_header: `GET /request-validation?name=Zaiste&admin=true HTTP/1.1␍␊
Accept: application/json, text/plain, */*␍␊
User-Agent: axios/0.19.0␍␊
Host: localhost:3000␍␊
Connection: close␍␊
␍␊
`,
_headerSent: true,
_last: true,
_maxListeners: undefined,
_onPendingData: Function noopPendingOutput {},
_redirectable: Writable { … },
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_trailer: '',
aborted: false,
agent: Agent { … },
chunkedEncoding: false,
connection: Socket { … },
finished: true,
maxHeadersCount: null,
method: 'GET',
outputData: [],
outputSize: 0,
parser: null,
path: '/request-validation?name=Zaiste&admin=true',
res: IncomingMessage { … },
sendDate: false,
shouldKeepAlive: false,
socket: Socket { … },
socketPath: undefined,
timeoutCb: null,
upgradeOrConnect: false,
useChunkedEncodingByDefault: false,
writable: true,
[Symbol(kNeedDrain)]: false,
[Symbol(isCorked)]: false,
[Symbol(kOutHeaders)]: Object { … },
},
status: 500,
statusText: 'Internal Server Error',
},
toJSON: Function {},
message: 'Request failed with status code 500',
}
createError (node_modules/axios/lib/core/createError.js:16:15)
settle (node_modules/axios/lib/core/settle.js:17:12)
IncomingMessage.handleStreamEnd (node_modules/axios/lib/adapters/http.js:237:11)
built-in validation with invalid request
/Users/zaiste/code/huncwotjs/huncwot/test/index.js:175
174: } catch ({ response: { status, data } }) {
175: t.is(status, 422);
176: t.deepEqual(data, ['name is required.']);
Difference:
- 500
+ 422