Camel case the response

This commit is contained in:
joshaber 2016-11-18 15:12:30 -05:00
parent 5a40cdd2dc
commit 2585253e6b
3 changed files with 35 additions and 2 deletions

View file

@ -1,7 +1,12 @@
{
"name": "desktop",
"version": "0.0.13",
"version": "0.0.15",
"dependencies": {
"ansi-html": {
"version": "0.0.6",
"from": "ansi-html@0.0.6",
"resolved": "https://registry.npmjs.org/ansi-html/-/ansi-html-0.0.6.tgz"
},
"ansi-regex": {
"version": "2.0.0",
"from": "ansi-regex@>=2.0.0 <3.0.0",
@ -898,6 +903,21 @@
"from": "timed-out@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/timed-out/-/timed-out-2.0.0.tgz"
},
"to-camel-case": {
"version": "1.0.0",
"from": "to-camel-case@latest",
"resolved": "https://registry.npmjs.org/to-camel-case/-/to-camel-case-1.0.0.tgz"
},
"to-no-case": {
"version": "1.0.2",
"from": "to-no-case@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/to-no-case/-/to-no-case-1.0.2.tgz"
},
"to-space-case": {
"version": "1.0.0",
"from": "to-space-case@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/to-space-case/-/to-space-case-1.0.0.tgz"
},
"tough-cookie": {
"version": "2.3.2",
"from": "tough-cookie@>=2.3.0 <2.4.0",

View file

@ -31,6 +31,7 @@
"react-dom": "^15.3.2",
"react-virtualized": "^8.0.11",
"textarea-caret": "^3.0.1",
"to-camel-case": "^1.0.0",
"untildify": "^3.0.2",
"username": "^2.2.2"
},

View file

@ -9,6 +9,7 @@ import * as appProxy from '../ui/lib/app-proxy'
const Octokat = require('octokat')
const got = require('got')
const username: () => Promise<string> = require('username')
const camelCase: (str: string) => string = require('to-camel-case')
/** The response from `got` requests. */
interface IHTTPResponse extends HTTP.IncomingMessage {
@ -279,7 +280,7 @@ export async function fetchUser(endpoint: string, token: string): Promise<User>
/** Get metadata from the server. */
export async function fetchMetadata(endpoint: string): Promise<IServerMetadata> {
const response = await request(endpoint, null, 'GET', 'meta', null)
return response.body
return toCamelCase(response.body)
}
/**
@ -330,6 +331,17 @@ async function getNote(): Promise<string> {
return `GitHub Desktop on ${localUsername}@${OS.hostname()}`
}
/** Turn keys into camel case. */
function toCamelCase(body: any): any {
const result: any = {}
for (const key in body) {
const value = body[key]
result[camelCase(key)] = value
}
return result
}
/**
* Get the URL for the HTML site. For example:
*