@timo-bank/nestjs 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/README.vi.md +152 -0
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [English](./README.md) | [Tiếng Việt](./README.vi.md)
2
+
1
3
  # @timo-bank/nestjs
2
4
 
3
5
  NestJS module for Timo Bank SDK integration.
package/README.vi.md ADDED
@@ -0,0 +1,152 @@
1
+ [English](./README.md) | [Tiếng Việt](./README.vi.md)
2
+
3
+ # @timo-bank/nestjs
4
+
5
+ Module NestJS để tích hợp SDK Timo Bank.
6
+
7
+ > **Cảnh báo**: Đây là package không chính thức. Xem [TUYÊN BỐ MIỄN TRỪ](../../DISCLAIMER.vi.md).
8
+
9
+ ## Cài đặt
10
+
11
+ ```bash
12
+ npm install @timo-bank/core @timo-bank/nestjs
13
+ ```
14
+
15
+ ## Thiết lập
16
+
17
+ Trước tiên, chạy CLI thiết lập core:
18
+
19
+ ```bash
20
+ npx @timo-bank/core setup
21
+ ```
22
+
23
+ Thêm credential token vào file `.env`:
24
+
25
+ ```env
26
+ TIMO_CREDENTIALS=timo_v1_eyJ1c2VybmFtZSI6...
27
+ ```
28
+
29
+ ## Sử dụng
30
+
31
+ ### Thiết lập cơ bản
32
+
33
+ ```typescript
34
+ // app.module.ts
35
+ import { Module } from '@nestjs/common';
36
+ import { TimoModule } from '@timo-bank/nestjs';
37
+
38
+ @Module({
39
+ imports: [
40
+ TimoModule.forRoot({
41
+ credentials: process.env.TIMO_CREDENTIALS!,
42
+ }),
43
+ ],
44
+ })
45
+ export class AppModule {}
46
+ ```
47
+
48
+ ### Cấu hình bất đồng bộ
49
+
50
+ ```typescript
51
+ // app.module.ts
52
+ import { Module } from '@nestjs/common';
53
+ import { ConfigModule, ConfigService } from '@nestjs/config';
54
+ import { TimoModule } from '@timo-bank/nestjs';
55
+
56
+ @Module({
57
+ imports: [
58
+ ConfigModule.forRoot(),
59
+ TimoModule.forRootAsync({
60
+ imports: [ConfigModule],
61
+ useFactory: (config: ConfigService) => ({
62
+ credentials: config.get('TIMO_CREDENTIALS')!,
63
+ autoLogin: true, // mặc định
64
+ }),
65
+ inject: [ConfigService],
66
+ }),
67
+ ],
68
+ })
69
+ export class AppModule {}
70
+ ```
71
+
72
+ ### Sử dụng Client
73
+
74
+ ```typescript
75
+ // payment.service.ts
76
+ import { Injectable } from '@nestjs/common';
77
+ import { InjectTimo, TimoClient } from '@timo-bank/nestjs';
78
+
79
+ @Injectable()
80
+ export class PaymentService {
81
+ constructor(@InjectTimo() private readonly timo: TimoClient) {}
82
+
83
+ async getBalance() {
84
+ return this.timo.getBalance();
85
+ }
86
+
87
+ async getRecentTransactions() {
88
+ return this.timo.getTransactions({
89
+ limit: 10,
90
+ });
91
+ }
92
+ }
93
+ ```
94
+
95
+ ## Module Options
96
+
97
+ ### TimoModuleOptions
98
+
99
+ | Option | Type | Bắt buộc | Mô tả |
100
+ |--------|------|----------|-------|
101
+ | `credentials` | `string` | Có | Credential token từ CLI |
102
+ | `logger` | `Logger` | Không | Logger tùy chỉnh |
103
+ | `autoLogin` | `boolean` | Không | Tự động đăng nhập khi khởi tạo (mặc định: true) |
104
+
105
+ ### TimoModuleAsyncOptions
106
+
107
+ | Option | Type | Mô tả |
108
+ |--------|------|-------|
109
+ | `imports` | `any[]` | Modules cần import |
110
+ | `useFactory` | `Function` | Factory function |
111
+ | `useClass` | `Type` | Options provider class |
112
+ | `useExisting` | `Type` | Existing options provider |
113
+ | `inject` | `any[]` | Dependencies cần inject |
114
+
115
+ ## Exports
116
+
117
+ ### Từ @timo-bank/nestjs
118
+
119
+ - `TimoModule` - Module NestJS chính
120
+ - `InjectTimo()` - Decorator để inject TimoClient
121
+ - `TimoClient` - Re-export từ core
122
+ - Types: `Balance`, `Transaction`, `AccountInfo`, `UserProfile`
123
+
124
+ ## Auto-Login
125
+
126
+ Mặc định, module tự động gọi `client.login()` trong quá trình khởi tạo. Điều này có nghĩa service của bạn có thể sử dụng ngay các phương thức của client.
127
+
128
+ Để tắt auto-login:
129
+
130
+ ```typescript
131
+ TimoModule.forRoot({
132
+ credentials: process.env.TIMO_CREDENTIALS!,
133
+ autoLogin: false,
134
+ }),
135
+ ```
136
+
137
+ Sau đó đăng nhập thủ công khi cần:
138
+
139
+ ```typescript
140
+ @Injectable()
141
+ export class PaymentService implements OnModuleInit {
142
+ constructor(@InjectTimo() private readonly timo: TimoClient) {}
143
+
144
+ async onModuleInit() {
145
+ await this.timo.login();
146
+ }
147
+ }
148
+ ```
149
+
150
+ ## Giấy phép
151
+
152
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timo-bank/nestjs",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Unofficial Timo Bank SDK - NestJS module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -39,7 +39,7 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@timo-bank/core": "0.1.3"
42
+ "@timo-bank/core": "0.1.4"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@nestjs/common": ">=9.0.0",