Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications, heavily inspired by Angular.

NPM Version Package License NPM Downloads Travis Linux Coverage Gitter Backers on Open Collective Sponsors on Open Collective

Description

NestJS package for Call Of Duty API

Installation

$ npm install call-of-duty-nestjs

OR

$ yarn add call-of-duty-nestjs

Overview

Configuration

/*app.module.ts*/
import { ActivisionModule } from 'call-of-duty-nestjs';

@Module({
  imports: [ActivisionModule.forRoot({
    login: '<Activision account login>',
    password: '<Password for your account>',
    ratelimit: { maxRequests: 2, perMilliseconds: 1000, maxRPS: 2 } // Optional
  })]
})
export class AppModule {
}

Or async

/*app.module.ts*/
import { ActivisionModule } from 'call-of-duty-nestjs';

@Module({
  imports: [ActivisionModule.forRootAsync({
    useFactory: () => ({
      login: '<Activision account login>',
      password: '<Password for your account>',
      ratelimit: { maxRequests: 2, perMilliseconds: 1000, maxRPS: 2 } // Optional
    })
  })]
})
export class AppModule {
}

Usage

/*app.controller.ts*/

import { Injectable, Logger } from '@nestjs/common';
import { 
  ActivisionService,
  BattleDataResponse,
  MwDataResponse,
  CombatDataResponse
} from 'call-of-duty-nestjs';

@Injectable()
export class AppController {
  private readonly logger = new Logger(AppController.name);

  constructor(
    private readonly activisionService: ActivisionService
  ) {
  }

  /**
   * Get combat multiplayer data
   */
  getMWBattleData(): Promise<BattleDataResponse> {
    return this.activisionService.MWBattleData({
      platform: '<Player platform>',
      playerName: '<Player name>'
    });
  }

  /**
   * Get combat warzone data
   */
  getMWstats(): Promise<MwDataResponse> {
    return this.activisionService.MWstats({
      platform: '<Player platform>',
      playerName: '<Player name>'
    });
  }
  
  /**
   * Get multiplayer stats
   */
  getMWmp(): Promise<MwDataResponse> {
    return this.activisionService.MWmp({
      platform: '<Player platform>',
      playerName: '<Player name>'
    });
  }
  
  /**
   * Get all stats
   */
  getMWcombatwz(): Promise<CombatDataResponse> {
    return this.activisionService.MWcombatwz({
      platform: '<Player platform>',
      playerName: '<Player name>'
    });
  }

  /**
   * Get battle data
   */
  getMWcombatmp(): Promise<CombatDataResponse> {
    return this.activisionService.MWcombatmp({
      platform: '<Player platform>',
      playerName: '<Player name>'
    });
  }
}

License

Nest is MIT licensed.