Skip to content

Instantly share code, notes, and snippets.

@tim-rohrer
Created June 6, 2020 01:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tim-rohrer/02175203641b25a7cf31d17f587d1416 to your computer and use it in GitHub Desktop.
Save tim-rohrer/02175203641b25a7cf31d17f587d1416 to your computer and use it in GitHub Desktop.
import { DirectionsResponse } from "@googlemaps/google-maps-services-js"
export const foo: DirectionsResponse = { status: 200,
statusText: 'OK',
headers:
{ 'content-type': 'application/json; charset=UTF-8',
date: 'Fri, 05 Jun 2020 22:25:12 GMT',
pragma: 'no-cache',
expires: 'Fri, 01 Jan 1990 00:00:00 GMT',
'cache-control': 'no-cache, must-revalidate',
vary: 'Accept-Language',
server: 'mafe',
'x-xss-protection': '0',
'x-frame-options': 'SAMEORIGIN',
'server-timing': 'gfet4t7; dur=157',
'alt-svc':
'h3-27=":443"; ma=2592000,h3-25=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"',
'transfer-encoding': 'chunked' },
config:
{ url: 'https://maps.googleapis.com/maps/api/directions/json',
method: 'get',
params:
{ origin: 'place_id:ChIJK-0sC0Fl1oYRFccWTTgtw3M',
destination: 'place_id:ChIJgdL4flSKrYcRnTpP0XQSojM',
key: 'MYKEY' },
headers:
{ Accept: 'application/json, text/plain, */*',
'User-Agent': 'google-maps-services-node-2.6.1',
'Accept-Encoding': 'gzip' },
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
paramsSerializer: [Function],
timeout: 10000,
adapter: [Function: httpAdapter],
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
validateStatus: [Function: validateStatus],
httpsAgent:
HttpsAgent {
_events: [Object],
_eventsCount: 1,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object],
requests: {},
sockets: {},
freeSockets: [Object],
keepAliveMsecs: 1000,
keepAlive: true,
maxSockets: Infinity,
maxFreeSockets: 256,
createSocketCount: 1,
createSocketCountLastCheck: 0,
createSocketErrorCount: 0,
createSocketErrorCountLastCheck: 0,
closeSocketCount: 0,
closeSocketCountLastCheck: 0,
errorSocketCount: 0,
errorSocketCountLastCheck: 0,
requestCount: 1,
requestCountLastCheck: 0,
timeoutSocketCount: 0,
timeoutSocketCountLastCheck: 0,
maxCachedSessions: 100,
_sessionCache: [Object],
[Symbol(agentkeepalive#currentId)]: 1 },
data: undefined },
request:
ClientRequest {
_events:
[Object: null prototype] {
socket: [Array],
abort: [Function],
aborted: [Function],
error: [Function],
timeout: [Array],
prefinish: [Function: requestOnPrefinish] },
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'maps.googleapis.com',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 9,
connecting: false,
_hadError: false,
_handle: [TLSWrap],
_parent: null,
_host: 'maps.googleapis.com',
_readableState: [ReadableState],
readable: true,
_maxListeners: undefined,
_writableState: [WritableState],
writable: true,
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: [TLSWrap],
_requestCert: true,
_rejectUnauthorized: true,
timeout: 15000,
parser: null,
_httpMessage: null,
[Symbol(res)]: [TLSWrap],
[Symbol(asyncId)]: -1,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]:
Timeout {
_called: false,
_idleTimeout: 15000,
_idlePrev: [TimersList],
_idleNext: [TimersList],
_idleStart: 3317,
_onTimeout: [Function: bound ],
_timerArgs: undefined,
_repeat: null,
_destroyed: false,
[Symbol(unrefed)]: true,
[Symbol(asyncId)]: 316,
[Symbol(triggerId)]: 315 },
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(connect-options)]: [Object],
[Symbol(agentkeepalive#socketName)]: 'sock[0#maps.googleapis.com:443::::::::::::::::::]',
[Symbol(agentkeepalive#socketRequestCount)]: 1,
[Symbol(agentkeepalive#socketRequestFinishedCount)]: 1 },
connection:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: 'maps.googleapis.com',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 9,
connecting: false,
_hadError: false,
_handle: [TLSWrap],
_parent: null,
_host: 'maps.googleapis.com',
_readableState: [ReadableState],
readable: true,
_maxListeners: undefined,
_writableState: [WritableState],
writable: true,
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: [TLSWrap],
_requestCert: true,
_rejectUnauthorized: true,
timeout: 15000,
parser: null,
_httpMessage: null,
[Symbol(res)]: [TLSWrap],
[Symbol(asyncId)]: -1,
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]:
Timeout {
_called: false,
_idleTimeout: 15000,
_idlePrev: [TimersList],
_idleNext: [TimersList],
_idleStart: 3317,
_onTimeout: [Function: bound ],
_timerArgs: undefined,
_repeat: null,
_destroyed: false,
[Symbol(unrefed)]: true,
[Symbol(asyncId)]: 316,
[Symbol(triggerId)]: 315 },
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(connect-options)]: [Object],
[Symbol(agentkeepalive#socketName)]: 'sock[0#maps.googleapis.com:443::::::::::::::::::]',
[Symbol(agentkeepalive#socketRequestCount)]: 1,
[Symbol(agentkeepalive#socketRequestFinishedCount)]: 1 },
_header:
'GET /maps/api/directions/json?destination=place_id%3AChIJgdL4flSKrYcRnTpP0XQSojM&key=MYKEY&origin=place_id%3AChIJK-0sC0Fl1oYRFccWTTgtw3M HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nUser-Agent: google-maps-services-node-2.6.1\r\nAccept-Encoding: gzip\r\nHost: maps.googleapis.com\r\nConnection: keep-alive\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent:
HttpsAgent {
_events: [Object],
_eventsCount: 1,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object],
requests: {},
sockets: {},
freeSockets: [Object],
keepAliveMsecs: 1000,
keepAlive: true,
maxSockets: Infinity,
maxFreeSockets: 256,
createSocketCount: 1,
createSocketCountLastCheck: 0,
createSocketErrorCount: 0,
createSocketErrorCountLastCheck: 0,
closeSocketCount: 0,
closeSocketCountLastCheck: 0,
errorSocketCount: 0,
errorSocketCountLastCheck: 0,
requestCount: 1,
requestCountLastCheck: 0,
timeoutSocketCount: 0,
timeoutSocketCountLastCheck: 0,
maxCachedSessions: 100,
_sessionCache: [Object],
[Symbol(agentkeepalive#currentId)]: 1 },
socketPath: undefined,
timeout: undefined,
method: 'GET',
insecureHTTPParser: undefined,
path:
'/maps/api/directions/json?destination=place_id%3AChIJgdL4flSKrYcRnTpP0XQSojM&key=MYKEY&origin=place_id%3AChIJK-0sC0Fl1oYRFccWTTgtw3M',
_ended: true,
res:
IncomingMessage {
_readableState: [ReadableState],
readable: false,
_events: [Object],
_eventsCount: 1,
_maxListeners: undefined,
socket: [TLSSocket],
connection: [TLSSocket],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
headers: [Object],
rawHeaders: [Array],
trailers: {},
rawTrailers: [],
aborted: false,
upgrade: false,
url: '',
method: null,
statusCode: 200,
statusMessage: 'OK',
client: [TLSSocket],
_consuming: true,
_dumped: false,
req: [Circular],
responseUrl:
'https://maps.googleapis.com/maps/api/directions/json?destination=place_id%3AChIJgdL4flSKrYcRnTpP0XQSojM&key=MYKEY&origin=place_id%3AChIJK-0sC0Fl1oYRFccWTTgtw3M',
redirects: [] },
aborted: undefined,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
_redirectable:
Writable {
_writableState: [WritableState],
writable: true,
_events: [Object],
_eventsCount: 2,
_maxListeners: undefined,
_options: [Object],
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 0,
_requestBodyBuffers: [],
_onNativeResponse: [Function],
_currentRequest: [Circular],
_currentUrl:
'https://maps.googleapis.com/maps/api/directions/json?destination=place_id%3AChIJgdL4flSKrYcRnTpP0XQSojM&key=MYKEY&origin=place_id%3AChIJK-0sC0Fl1oYRFccWTTgtw3M' },
[Symbol(isCorked)]: false,
[Symbol(outHeadersKey)]:
[Object: null prototype] {
accept: [Array],
'user-agent': [Array],
'accept-encoding': [Array],
host: [Array] } },
data:
{ geocoded_waypoints: [ [Object], [Object] ],
routes: [ [Object] ],
status: 'OK' } }
@fuckOffNino09
Copy link

``import { DirectionsResponse } from "@googlemaps/google-maps-services-js"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment