Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
@nestjs-twurple/api
Advanced tools
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 registered 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 0 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 0 open source maintainers 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.