Skip to content

Instantly share code, notes, and snippets.

@island205
Created May 5, 2014 14:50
Show Gist options
  • Save island205/918f34a9752bb9bcfab2 to your computer and use it in GitHub Desktop.
Save island205/918f34a9752bb9bcfab2 to your computer and use it in GitHub Desktop.
this context in koa.js
{
request: {
method: 'POST',
url: '/api/forums',
header: {
host: 'localhost:3000',
connection: 'keep-alive',
'content-length': '77',
'cache-control': 'no-cache',
origin: 'chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop',
'content-type': 'application/x-www-form-urlencoded',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.86 Safari/537.36',
'postman-token': '05864929-1913-d999-e8f6-bbe1d835d377',
accept: '*/*',
'accept-encoding': 'gzip,deflate,sdch',
'accept-language': 'zh,en;q=0.8,zh-CN;q=0.6,gl;q=0.4',
cookie: 'koa.sid=DdHi3qfCJT0aoWg06WkXLEVS; koa.sid.sig=gHeD7HjyifeMjTE31rrNSqzHpWw'
}
},
response: {
status: undefined,
string: 'Not Found',
header: {
'x-powered-by': 'koa'
},
body: undefined
},
app: {
env: 'development',
_events: {
error: [Function]
},
outputErrors: true,
subdomainOffset: 2,
poweredBy: true,
middleware: [
[Function: session],
[Function: bodyParser],
[Function],
[Function],
[Function: views],
[Function: dispatch],
[Function: dispatch],
[Function],
[Function]
],
context: {},
request: undefined,
response: undefined,
keys: ['hive']
},
req: {
_readableState: {
highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: true,
endEmitted: true,
reading: false,
sync: true,
needReadable: false,
emittedReadable: false,
readableListening: false,
objectMode: false,
defaultEncoding: 'utf8',
ranOut: false,
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null,
resumeScheduled: false
},
readable: false,
domain: null,
_events: {
data: [Function: onData],
error: [Object],
close: [Object]
},
_maxListeners: undefined,
socket: {
_connecting: false,
_hadError: false,
_handle: [Object],
_host: null,
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: undefined,
_writableState: [Object],
writable: true,
allowHalfOpen: true,
destroyed: false,
bytesRead: 676,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server: [Object],
_idleTimeout: 120000,
_idleNext: [Object],
_idlePrev: [Object],
_idleStart: 35387789,
parser: [Object],
_paused: false,
read: [Function],
_consuming: true,
_httpMessage: [Object]
},
connection: {
_connecting: false,
_hadError: false,
_handle: [Object],
_host: null,
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: undefined,
_writableState: [Object],
writable: true,
allowHalfOpen: true,
destroyed: false,
bytesRead: 676,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server: [Object],
_idleTimeout: 120000,
_idleNext: [Object],
_idlePrev: [Object],
_idleStart: 35387789,
parser: [Object],
_paused: false,
read: [Function],
_consuming: true,
_httpMessage: [Object]
},
httpVersion: '1.1',
complete: true,
headers: {
host: 'localhost:3000',
connection: 'keep-alive',
'content-length': '77',
'cache-control': 'no-cache',
origin: 'chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop',
'content-type': 'application/x-www-form-urlencoded',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.86 Safari/537.36',
'postman-token': '05864929-1913-d999-e8f6-bbe1d835d377',
accept: '*/*',
'accept-encoding': 'gzip,deflate,sdch',
'accept-language': 'zh,en;q=0.8,zh-CN;q=0.6,gl;q=0.4',
cookie: 'koa.sid=DdHi3qfCJT0aoWg06WkXLEVS; koa.sid.sig=gHeD7HjyifeMjTE31rrNSqzHpWw'
},
rawHeaders: ['Host',
'localhost:3000',
'Connection',
'keep-alive',
'Content-Length',
'77',
'Cache-Control',
'no-cache',
'Origin',
'chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop',
'Content-Type',
'application/x-www-form-urlencoded',
'User-Agent',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.86 Safari/537.36',
'Postman-Token',
'05864929-1913-d999-e8f6-bbe1d835d377',
'Accept',
'*/*',
'Accept-Encoding',
'gzip,deflate,sdch',
'Accept-Language',
'zh,en;q=0.8,zh-CN;q=0.6,gl;q=0.4',
'Cookie',
'koa.sid=DdHi3qfCJT0aoWg06WkXLEVS; koa.sid.sig=gHeD7HjyifeMjTE31rrNSqzHpWw'
],
trailers: {},
rawTrailers: [],
_pendings: [],
_pendingIndex: 0,
url: '/api/forums',
method: 'POST',
statusCode: null,
statusMessage: null,
client: {
_connecting: false,
_hadError: false,
_handle: [Object],
_host: null,
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: undefined,
_writableState: [Object],
writable: true,
allowHalfOpen: true,
destroyed: false,
bytesRead: 676,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server: [Object],
_idleTimeout: 120000,
_idleNext: [Object],
_idlePrev: [Object],
_idleStart: 35387789,
parser: [Object],
_paused: false,
read: [Function],
_consuming: true,
_httpMessage: [Object]
},
_consuming: true,
_dumped: false,
httpVersionMajor: 1,
httpVersionMinor: 1,
upgrade: false,
read: [Function],
session: {
cookie: [Object],
passport: [Object]
},
query: {},
body: {
name: 'JavaScript',
description: 'A program language runing in browser',
_parentId: '-1'
},
_passport: {
instance: [Object],
session: [Object]
},
user: {
id: 1,
username: 'test'
}
},
res: {
domain: null,
_events: {
prefinish: [Function: resOnFinish],
finish: [Function: done]
},
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
writable: true,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: true,
_removedHeader: {},
_hasBody: true,
_trailer: '',
finished: false,
_hangupClose: false,
socket: {
_connecting: false,
_hadError: false,
_handle: [Object],
_host: null,
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: undefined,
_writableState: [Object],
writable: true,
allowHalfOpen: true,
destroyed: false,
bytesRead: 676,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server: [Object],
_idleTimeout: 120000,
_idleNext: [Object],
_idlePrev: [Object],
_idleStart: 35387789,
parser: [Object],
_paused: false,
read: [Function],
_consuming: true,
_httpMessage: [Circular]
},
connection: {
_connecting: false,
_hadError: false,
_handle: [Object],
_host: null,
_readableState: [Object],
readable: true,
domain: null,
_events: [Object],
_maxListeners: undefined,
_writableState: [Object],
writable: true,
allowHalfOpen: true,
destroyed: false,
bytesRead: 676,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server: [Object],
_idleTimeout: 120000,
_idleNext: [Object],
_idlePrev: [Object],
_idleStart: 35387789,
parser: [Object],
_paused: false,
read: [Function],
_consuming: true,
_httpMessage: [Circular]
},
_headers: {
'x-powered-by': 'koa'
},
_headerNames: {
'x-powered-by': 'X-Powered-By'
}
},
onerror: [Function],
originalUrl: '/api/forums',
cookies: {
request: {
_readableState: [Object],
readable: false,
domain: null,
_events: [Object],
_maxListeners: undefined,
socket: [Object],
connection: [Object],
httpVersion: '1.1',
complete: true,
headers: [Object],
rawHeaders: [Object],
trailers: {},
rawTrailers: [],
_pendings: [],
_pendingIndex: 0,
url: '/api/forums',
method: 'POST',
statusCode: null,
statusMessage: null,
client: [Object],
_consuming: true,
_dumped: false,
httpVersionMajor: 1,
httpVersionMinor: 1,
upgrade: false,
read: [Function],
session: [Object],
query: {},
body: [Object],
_passport: [Object],
user: [Object]
},
response: {
domain: null,
_events: [Object],
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
writable: true,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: true,
_removedHeader: {},
_hasBody: true,
_trailer: '',
finished: false,
_hangupClose: false,
socket: [Object],
connection: [Object],
_headers: [Object],
_headerNames: [Object]
},
keys: {
sign: [Function],
verify: [Function],
index: [Function]
}
},
accept: {
headers: {
host: 'localhost:3000',
connection: 'keep-alive',
'content-length': '77',
'cache-control': 'no-cache',
origin: 'chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop',
'content-type': 'application/x-www-form-urlencoded',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.86 Safari/537.36',
'postman-token': '05864929-1913-d999-e8f6-bbe1d835d377',
accept: '*/*',
'accept-encoding': 'gzip,deflate,sdch',
'accept-language': 'zh,en;q=0.8,zh-CN;q=0.6,gl;q=0.4',
cookie: 'koa.sid=DdHi3qfCJT0aoWg06WkXLEVS; koa.sid.sig=gHeD7HjyifeMjTE31rrNSqzHpWw'
},
negotiator: {
request: [Object]
}
},
sessionId: 'DdHi3qfCJT0aoWg06WkXLEVS',
session: {
cookie: {
httpOnly: true,
path: '/',
overwrite: true,
signed: true
},
passport: {
user: 1
}
},
login: [Function],
logIn: [Function],
logout: [Function],
logOut: [Function],
isAuthenticated: [Function],
isUnauthenticated: [Function],
render: [Function],
params: [resources: 'forums']
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment