-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose axios response #167
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just one minor TS question
type WarnLogsResponse = { | ||
logs: Array<ProjectLog>; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to move this to a types file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm good question. For smaller types that are only used in one file, I generally just keep them in that file. Though thinking from a library perspective it would probably make sense to export all those types.
This is done in a lot of places though so would need a separate PR
api/github.ts
Outdated
export async function fetchRepoAsZip( | ||
zipUrl: string | ||
): Promise<AxiosResponse<Buffer>> { | ||
export async function fetchRepoAsZip(zipUrl: string): AxiosPromise<Buffer> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove the async from these ones too?
const resp = await _createDeveloperTestAccount(accountId, accountName); | ||
return resp; | ||
const { data } = await _createDeveloperTestAccount(accountId, accountName); | ||
return data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned this to @joe-yeager, but these utils are such thin wrappers now that I think we should just delete the entire file. It's not really adding much value at all. We could probably delete lib/sandboxes too, since it's also not doing any additional logic in the api call wrappers.
We can do this in another PR though. It's possible Joe already did it in his error handling PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't done it yet, but I'll add an issue so we don't lose track of it and do it in a follow up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some small comments, but otherwise lgtm!
Description and Context
This updates the
http
module to return full Axios response objects, which will make debugging easier for libraries that consume locla-dev-lib. All API modules will also now return the full response object (they've been updated to use theAxiosPromise
return type thataxios
includes. Their previous return values will now be within thedata
field on the response object.A Few other things...
async
s.__utils__/mockAxiosResponse
. This lets tests easily create type accurate axios responses and use them for mocked return values. There might be a better way to do this, but figured this would get the job done for now.TODO
Need to be very careful to make update all uses of API modules in the CLI to make sure nothing breaks. May also be helpful to PR other HubSpot repos that use local-dev-lib, if needed
Who to Notify
@brandenrodgers @kemmerle @joe-yeager