Skip to main content

Cài đặt & Cấu hình

Cài đặt​

npm install @tingee/sdk-node
# hoặc
yarn add @tingee/sdk-node
# hoặc
pnpm add @tingee/sdk-node

Yêu cầu: Node.js ≥ 18


Cấu hình Client​

import { TingeeClient } from '@tingee/sdk-node';

const client = new TingeeClient({
secretKey: process.env.TINGEE_SECRET_KEY!,
clientId: process.env.TINGEE_CLIENT_ID!,
environment: 'production', // 'uat' | 'production'
timeout: 90000, // ms, mặc định 90000
// baseUrl: 'https://custom-url.example.com', // ghi đè environment
});
Tùy chọnKiểuMặc địnhMô tả
secretKeystring—Bắt buộc. Secret key từ Tingee Dashboard
clientIdstring—Bắt buộc. Client ID từ Tingee Dashboard
environment'uat' | 'production''production'Môi trường API
baseUrlstring—Ghi đè URL (bỏ qua environment)
timeoutnumber90000Timeout (ms)
Bảo mật quan trọng

secretKey chỉ được dùng phía server. Không nhúng vào frontend, mobile app hay bất kỳ môi trường client-side nào.


Tích hợp Framework​

// tingee.module.ts
import { Module, Global } from '@nestjs/common';
import { TingeeClient } from '@tingee/sdk-node';

@Global()
@Module({
providers: [
{
provide: TingeeClient,
useFactory: () => new TingeeClient({
secretKey: process.env.TINGEE_SECRET_KEY!,
clientId: process.env.TINGEE_CLIENT_ID!,
}),
},
],
exports: [TingeeClient],
})
export class TingeeModule {}