Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@nestjs-twurple/api
Advanced tools
Readme
A NestJS wrapper for @twurple/api package.
This module can be used alone or in combination with other @nestjs-twurple modules.
[!IMPORTANT] These packages require
twurple
version 7.0 or higher.
This module can be used in combination with @nestjs-twurple/auth module. Install it if necessary.
yarn:
yarn add @nestjs-twurple/api @twurple/auth @twurple/api
npm:
npm i @nestjs-twurple/api @twurple/auth @twurple/api
For basic information, check out the general documentation at the root of the repository @nestjs-twurple.
Also take a look at the official @twurple/api
reference and guides: Calling the Twitch API.
The module must be register either with register or registerAsync static methods.
To create an API client, you must provide TwurpleApiOptions
. The options below extended from the ApiConfig interface provided by @twurple/api
package, so the example below may become outdated at some point.
interface TwurpleApiIptions {
authProvider: AuthProvider;
fetchOptions?: TwitchApiCallFetchOptions;
logger?: Partial<LoggerOptions>;
}
Example of using register
method:
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { RefreshingAuthProvider } from '@twurple/auth';
import { TwurpleApiModule } from '@nestjs-twurple/api';
@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
TwurpleApiModule.register({
isGlobal: true,
authProvider: new RefreshingAuthProvider({
// ...
})
})
]
})
export class AppModule {}
You can also use TwurpleAuthModule
from @nestjs-twurple/auth package to inject the auth provider:
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { TWURPLE_AUTH_PROVIDER, TwurpleAuthModule } from '@nestjs-twurple/auth';
import { TwurpleApiModule } from '@nestjs-twurple/api';
import { AuthProvider } from '@twurple/auth';
@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
TwurpleAuthModule.registerAsync({
isGlobal: true,
inject: [ConfigService],
useFactory: (configService: ConfigService) => {
return {
type: 'refreshing',
clientId: configService.get('TWITCH_CLIENT_ID'),
clientSecret: configService.get('TWITCH_CLIENT_SECRET')
};
}
}),
TwurpleApiModule.registerAsync({
isGlobal: true,
inject: [TWURPLE_AUTH_PROVIDER],
useFactory: (authProvider: AuthProvider) => {
// Here we are able to access the auth provider instance
// provided by TwurpleAuthModule
return { authProvider };
}
})
]
})
export class AppModule {}
The module internally creates an ApiClient instance. You can inject it anywhere you need it using @InjectApiClient()
decorator:
import { Injectable } from '@nestjs/common';
import { InjectApiClient } from '@nestjs-twurple/api';
import { ApiClient } from '@twurple/api';
@Injectable()
export class CustomProvider {
constructor(@InjectApiClient() private readonly _apiClient: ApiClient) {}
}
Alternatively, you can use TWURPLE_API_CLIENT
token to inject the ApiClient
instance:
import { Inject, Injectable } from '@nestjs/common';
import { TWURPLE_API_CLIENT } from '@nestjs-twurple/api';
import { ApiClient } from '@twurple/api';
@Injectable()
export class CustomProvider {
constructor(@Inject(TWURPLE_API_CLIENT) private readonly _apiClient: ApiClient) {}
}
FAQs
A NestJS wrapper for @twurple/api package
The npm package @nestjs-twurple/api receives a total of 13 weekly downloads. As such, @nestjs-twurple/api popularity was classified as not popular.
We found that @nestjs-twurple/api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.