Skip to content
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

ApiClientConfigurator: getCustomMiddleware #561

Merged
merged 8 commits into from
Jan 27, 2025

Conversation

nicolasmondain
Copy link
Contributor

ApiClientConfigurator.getMiddleware is now using:

  • this.getHeaderMiddleware
  • this.getHttpAgentMiddleware
  • this.getCustomMiddleware
nicolasmondain@MBP-de-Nicolas hubspot-api-nodejs % npm run test          

> @hubspot/api-client@12.0.1 test
> ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json

Randomized with seed 63752
Started
......................................................................


70 specs, 0 failures
Finished in 0.081 seconds
Randomized with seed 63752 (jasmine --random=true --seed=63752)

Please note that all our unit tests are passing (using the new config.middleware option).

new Client({
    accessToken: ACCESS_TOKEN,
    middleware: [{
        async pre(ctx) {
            await new Promise(resolve => setTimeout(resolve, 1000));
            return ctx;
        },
        async post(ctx) {
            await new Promise(resolve => setTimeout(resolve, 1000));
            return ctx;
        },
    }],
});

@nicolasmondain
Copy link
Contributor Author

#560

@nicolasmondain
Copy link
Contributor Author

Hello @ksvirkou-hubspot
Is there any chance this one will be merged? WDYT

@ksvirkou-hubspot
Copy link
Collaborator

ksvirkou-hubspot commented Jan 15, 2025

Hi @nicolasmondain,
I see errors when I run it on TypeScript using npx ts-node run.ts.

run.ts
import * as hubspot from './index'
const hubspotClient = new hubspot.Client({
accessToken: 'example',
middleware: [{
  async pre(ctx) {
      await new Promise(resolve => setTimeout(resolve, 1000));
      return ctx;
  },
  async post(ctx) {
      await new Promise(resolve => setTimeout(resolve, 1000));
      return ctx;
  },
}],
})
Could you fix it, please?

@nicolasmondain
Copy link
Contributor Author

nicolasmondain commented Jan 15, 2025

@ksvirkou-hubspot
Done. Tests are ok (as your npx ts-node run.ts)
Much more simpler by the way. Let me know if you want me to do anything else.

@ksvirkou-hubspot
Copy link
Collaborator

Thank you for contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants