@candioto/nestjs-hubspot
v0.1.3
Published
Unofficial Hubspot NestJS module that provides Hubspot official client to NestJS applications
Downloads
25
Maintainers
Readme
Unofficial Hubspot NestJS module
❗Module and documentation under development.
A simple NestJS module inspired by Olivier Maréchal's module that provides Hubspot official client to NestJS applications.
Comming soon...
Instalation
npm install --save @candioto/nestjs-hubspot @hubspot/api-client
Getting Started
The simplest way to use @candioto/nestjs-hubspot
is to use HubspotModule.forRoot
import { Module } from '@nestjs/common';
import { HubspotModule } from '@candioto/nestjs-hubspot';
@Module({
imports: [
HubspotModule.forRoot({
apiKey: 'my_secret_key', // it accepts all the same parameters as the official client
}),
],
})
export class AppModule {}
You can then inject the Hubspot client into any of your injectables by using a custom decorator
import { Injectable } from '@nestjs/common';
import { InjectHubspot } from '@candioto/nestjs-hubspot';
import { Client } from '@hubspot/api-client';
@Injectable()
export class AppService {
public constructor(
@InjectHubspot() private readonly hubspotClient: Client,
) {}
}
Asynchronous setup is also supported
import { Module } from '@nestjs/common';
import { HubspotModule } from '@candioto/nestjs-hubspot';
@Module({
imports: [
HubspotModule.forRootAsync({
// inject: [ConfigService], with configService
useFactory: (/* configService: ConfigService */) => ({
apiKey: process.env.API_KEY, // configService.get('hubspot_api_key'),
}),
}),
],
})
export class AppModule {}
See the official docs of the client at https://github.com/HubSpot/hubspot-api-nodejs/tree/master
Author
Contributing
I would greatly appreciate any contributions to make this project better. Please make sure to follow the below guidelines before getting your hands dirty.
- Fork the repository
- Create your branch (
git checkout -b my-branch
) - Commit any changes to your branch
- Push your changes to your remote branch
- Open a pull request