@ntegral/nestjs-taxjar
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

npm version Codecov Coverage ISC license

@ntegral/nestjs-taxjar

Provides an injectable taxjar client to provide access to taxjar sales tax api in nestjs modules

Table Of Contents

About

@ntegral/nestjs-taxjar implements a module, TaxJarModule, which when imported into your nestjs project provides a Taxjar client to any class that injects it. This lets TaxJar Sales Tax API be worked into your dependency injection workflow without having to do any extra work outside of the initial setup.

Installation

npm install --save @ntegral/nestjs-taxjar taxjar

Getting Started

The simplest way to use @ntegral/nestjs-taxjar is to use TaxJarModule.forRoot

import { Module } from '@nestjs-common';
import { TaxJarModule } from '@ntegral/nestjs-taxjar';

@Module({
  imports: [
    TaxJarModule.forRoot({
      apiKey: 'taxjar_api_key'
    }),
  ],
})
export class AppModule {}

The async way @ntegral/nestjs-taxjar is to use TaxJarModule.forRootAsync

import { Module } from '@nestjs-common';
import { TaxJarModule } from '@ntegral/nestjs-taxjar';
import { ConfigModule } from '@ntegral/nestjs-config';
import { ConfigService } from '@ntegral/nestjs-config';

@Module({
  imports: [
    TaxJarModule.forRootAsync({
      imports: [ConfigModule],
      useFactory: async (cfg:ConfigService) => ({
        apiKey: cfg.get('TAXJAR_API_KEY')
      }),
      inject: [ConfigService],
    })
  ]
})

export class AppModule {}

You can then inject the Taxjar client into any of your injectables by using a custom decorator

import { Injectable } from '@nestjs/common';
import { InjectTaxJar } from '@ntegral/nestjs-taxjar';
import Taxjar = require('taxjar');

@Injectable()
export class AppService {
  public constructor(@InjectTaxJar() private readonly client: Taxjar) {
      client.ratesForLocation('30339').then(res => {
        res.rate; //rate object
      });
      ... and more
  }
}

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.

  1. Fork the repository
  2. Create your branch (git checkout -b my-branch)
  3. Commit any changes to your branch
  4. Push your changes to your remote branch
  5. Open a pull request

License

Distributed under the ISC License. See LICENSE for more information.

Acknowledgements

Copyright © 2020 Ntegral Inc.

Readme

Keywords

Package Sidebar

Install

npm i @ntegral/nestjs-taxjar

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

133 kB

Total Files

63

Last publish

Collaborators

  • ntegral