@akaanakbaik/pterodactyl-gateway 0.9.1 → 1.0.1
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.
- package/README.md +458 -127
- package/add-promt.md +278 -135
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/integrations.d.ts +56 -0
- package/dist/integrations.d.ts.map +1 -0
- package/dist/integrations.js +112 -0
- package/dist/integrations.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,23 +1,54 @@
|
|
|
1
1
|
# Akadev Pterodactyl Gateway
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<b>SDK TypeScript + CLI modern untuk mengelola Pterodactyl Panel dari bot, dashboard, backend, dan terminal.</b>
|
|
5
|
+
</p>
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<code>@akaanakbaik/pterodactyl-gateway</code> · <code>v1.0.0</code> · <code>Node.js >=18</code> · <code>MIT</code>
|
|
9
|
+
</p>
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Status
|
|
11
|
+
Akadev Pterodactyl Gateway membantu kamu menghubungkan aplikasi Node.js ke Pterodactyl Panel dengan flow yang lebih aman dan cepat: cek koneksi, membuat user, membuat server, dry-run payload, mengelola file, startup variables, backup, schedule, power action, sampai CLI admin yang mudah dipakai.
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
> Package ini bukan package resmi dari Pterodactyl dan tidak berafiliasi dengan Pterodactyl Software.
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
15
|
+
## Navigasi
|
|
16
|
+
|
|
17
|
+
- [Fitur utama](#fitur-utama)
|
|
18
|
+
- [Install](#install)
|
|
19
|
+
- [Quick start](#quick-start)
|
|
20
|
+
- [Konfigurasi API key](#konfigurasi-api-key)
|
|
21
|
+
- [Config profile lokal](#config-profile-lokal)
|
|
22
|
+
- [CLI reference](#cli-reference)
|
|
23
|
+
- [Preset dan template](#preset-dan-template)
|
|
24
|
+
- [Wizard interaktif](#wizard-interaktif)
|
|
25
|
+
- [SDK usage](#sdk-usage)
|
|
26
|
+
- [Integration helpers](#integration-helpers)
|
|
27
|
+
- [Contoh integrasi bot WhatsApp](#contoh-integrasi-bot-whatsapp)
|
|
28
|
+
- [Contoh integrasi bot Telegram](#contoh-integrasi-bot-telegram)
|
|
29
|
+
- [Contoh integrasi bot Discord](#contoh-integrasi-bot-discord)
|
|
30
|
+
- [Contoh integrasi website atau API](#contoh-integrasi-website-atau-api)
|
|
31
|
+
- [Tips produksi](#tips-produksi)
|
|
32
|
+
- [Keamanan](#keamanan)
|
|
33
|
+
- [Troubleshooting](#troubleshooting)
|
|
34
|
+
- [Release dan testing](#release-dan-testing)
|
|
35
|
+
|
|
36
|
+
## Fitur utama
|
|
37
|
+
|
|
38
|
+
- SDK TypeScript untuk Application API dan Client API Pterodactyl.
|
|
39
|
+
- CLI global: `ptero-gateway`, alias singkat `ptg`, dan wizard `ptero-wizard`.
|
|
40
|
+
- Config profile lokal agar tidak perlu export env berulang-ulang.
|
|
41
|
+
- Smart user creation dengan password otomatis.
|
|
42
|
+
- Smart server creation dengan dry-run, preset, auto docker image, auto startup, environment, dan allocation.
|
|
43
|
+
- Helper integrasi untuk WhatsApp bot, Telegram bot, Discord bot, Node.js API, website, Python bot, dan blank server.
|
|
44
|
+
- File manager, JSON helper, startup variables, network/ports, databases, backups, schedules, probe, resources, dan power action.
|
|
45
|
+
- Guard keamanan untuk aksi tulis via CLI dan command berbahaya.
|
|
46
|
+
- Release guard, self-check, release-check, dan pack dry-run untuk menjaga package tetap stabil.
|
|
18
47
|
|
|
19
48
|
## Install
|
|
20
49
|
|
|
50
|
+
Install sebagai dependency project:
|
|
51
|
+
|
|
21
52
|
```bash
|
|
22
53
|
npm i @akaanakbaik/pterodactyl-gateway
|
|
23
54
|
```
|
|
@@ -28,7 +59,7 @@ Install global CLI:
|
|
|
28
59
|
npm i -g @akaanakbaik/pterodactyl-gateway
|
|
29
60
|
```
|
|
30
61
|
|
|
31
|
-
Cek
|
|
62
|
+
Cek instalasi:
|
|
32
63
|
|
|
33
64
|
```bash
|
|
34
65
|
ptero-gateway version
|
|
@@ -36,9 +67,34 @@ ptero-gateway self-check
|
|
|
36
67
|
ptero-gateway release-check
|
|
37
68
|
```
|
|
38
69
|
|
|
39
|
-
##
|
|
70
|
+
## Quick start
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
ptero-gateway config init \
|
|
74
|
+
--profile main \
|
|
75
|
+
--domain https://panel.example.com \
|
|
76
|
+
--ptla ptla_xxx \
|
|
77
|
+
--ptlc ptlc_xxx
|
|
78
|
+
|
|
79
|
+
ptero-gateway doctor
|
|
80
|
+
ptero-gateway servers
|
|
81
|
+
ptero-gateway admin users
|
|
82
|
+
ptero-gateway admin servers
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
SDK minimal:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { createPtero } from "@akaanakbaik/pterodactyl-gateway";
|
|
89
|
+
|
|
90
|
+
const ptero = createPtero.fromEnv();
|
|
91
|
+
const doctor = await ptero.doctor();
|
|
92
|
+
console.log(doctor);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Konfigurasi API key
|
|
40
96
|
|
|
41
|
-
Gunakan
|
|
97
|
+
Gunakan environment variable untuk deployment:
|
|
42
98
|
|
|
43
99
|
```env
|
|
44
100
|
PTERO_DOMAIN=https://panel.example.com
|
|
@@ -46,15 +102,22 @@ PTERO_PTLA=ptla_xxxxxxxxxxxxxxxxx
|
|
|
46
102
|
PTERO_PTLC=ptlc_xxxxxxxxxxxxxxxxx
|
|
47
103
|
```
|
|
48
104
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
105
|
+
| Env | Fungsi |
|
|
106
|
+
|---|---|
|
|
107
|
+
| `PTERO_DOMAIN` | Domain panel Pterodactyl. |
|
|
108
|
+
| `PTERO_PTLA` | Application API Key untuk aksi admin seperti user, server, suspend, limits. |
|
|
109
|
+
| `PTERO_PTLC` | Client API Key untuk kontrol server, file manager, backups, schedules, resources. |
|
|
110
|
+
|
|
111
|
+
Tips:
|
|
52
112
|
|
|
53
|
-
|
|
113
|
+
- Pakai PTLA hanya di backend/admin service.
|
|
114
|
+
- Pakai PTLC untuk aksi client server yang memang diperlukan.
|
|
115
|
+
- Jangan pernah hardcode key ke source code, repo, atau pesan bot.
|
|
116
|
+
- Pisahkan key production dan development.
|
|
54
117
|
|
|
55
|
-
## Config profile
|
|
118
|
+
## Config profile lokal
|
|
56
119
|
|
|
57
|
-
|
|
120
|
+
Config profile memudahkan penggunaan CLI di VPS pribadi.
|
|
58
121
|
|
|
59
122
|
```bash
|
|
60
123
|
ptero-gateway config init \
|
|
@@ -62,10 +125,6 @@ ptero-gateway config init \
|
|
|
62
125
|
--domain https://panel.example.com \
|
|
63
126
|
--ptla ptla_xxx \
|
|
64
127
|
--ptlc ptlc_xxx
|
|
65
|
-
|
|
66
|
-
ptero-gateway config doctor
|
|
67
|
-
ptero-gateway config list
|
|
68
|
-
ptero-gateway doctor
|
|
69
128
|
```
|
|
70
129
|
|
|
71
130
|
File config disimpan di:
|
|
@@ -74,13 +133,10 @@ File config disimpan di:
|
|
|
74
133
|
~/.pterodactyl-gateway/config.json
|
|
75
134
|
```
|
|
76
135
|
|
|
77
|
-
File tersebut berisi API key dan otomatis diberi permission `600`.
|
|
78
|
-
|
|
79
136
|
Command config:
|
|
80
137
|
|
|
81
138
|
```bash
|
|
82
139
|
ptero-gateway config path
|
|
83
|
-
ptero-gateway config init --profile main --domain https://panel.example.com --ptla ptla_xxx --ptlc ptlc_xxx
|
|
84
140
|
ptero-gateway config list
|
|
85
141
|
ptero-gateway config show main
|
|
86
142
|
ptero-gateway config use main
|
|
@@ -90,61 +146,41 @@ ptero-gateway config env main
|
|
|
90
146
|
ptero-gateway config doctor
|
|
91
147
|
```
|
|
92
148
|
|
|
93
|
-
|
|
149
|
+
Catatan:
|
|
150
|
+
|
|
151
|
+
- File config mengandung API key, jangan upload atau screenshot penuh.
|
|
152
|
+
- Permission file otomatis dibuat `600` jika filesystem mendukung.
|
|
153
|
+
- CLI akan memakai active profile jika env belum tersedia.
|
|
154
|
+
|
|
155
|
+
## CLI reference
|
|
156
|
+
|
|
157
|
+
Health dan info:
|
|
94
158
|
|
|
95
159
|
```bash
|
|
96
160
|
ptero-gateway help
|
|
161
|
+
ptero-gateway version
|
|
162
|
+
ptero-gateway self-check
|
|
163
|
+
ptero-gateway release-check
|
|
97
164
|
ptero-gateway doctor
|
|
98
165
|
ptero-gateway connect
|
|
99
166
|
ptero-gateway ids
|
|
100
167
|
ptero-gateway ids --nest 5
|
|
101
|
-
ptero-gateway servers
|
|
102
168
|
```
|
|
103
169
|
|
|
104
|
-
|
|
170
|
+
Admin list:
|
|
105
171
|
|
|
106
172
|
```bash
|
|
107
173
|
ptero-gateway admin users
|
|
108
174
|
ptero-gateway admin servers
|
|
109
175
|
```
|
|
110
176
|
|
|
111
|
-
|
|
177
|
+
Client list:
|
|
112
178
|
|
|
113
179
|
```bash
|
|
114
|
-
ptero-gateway
|
|
180
|
+
ptero-gateway servers
|
|
115
181
|
```
|
|
116
182
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
| Preset | Memory | Disk | CPU | Database | Allocation | Backup |
|
|
120
|
-
|---|---:|---:|---:|---:|---:|---:|
|
|
121
|
-
| mini | 512MB | 1GB | 50% | 0 | 1 | 0 |
|
|
122
|
-
| basic | 1GB | 2GB | 100% | 0 | 1 | 0 |
|
|
123
|
-
| standard | 2GB | 5GB | 200% | 1 | 1 | 1 |
|
|
124
|
-
| premium | 4GB | 10GB | 300% | 2 | 2 | 2 |
|
|
125
|
-
| unlimited | 0 | 0 | 0 | 5 | 3 | 3 |
|
|
126
|
-
|
|
127
|
-
Nilai preset tetap bisa dioverride dengan `--memory`, `--disk`, `--cpu`, `--databases`, `--allocations`, dan `--backups`.
|
|
128
|
-
|
|
129
|
-
## Templates
|
|
130
|
-
|
|
131
|
-
Template hanya membuat rekomendasi command create-server. Template tidak membuat node, location, atau allocation.
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
ptero-gateway templates list
|
|
135
|
-
ptero-gateway templates show nodejs-bot
|
|
136
|
-
ptero-gateway templates command nodejs-bot --name "bot saya" --email user@example.com --node 1 --nest 5 --egg 18
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
Template bawaan:
|
|
140
|
-
|
|
141
|
-
- `nodejs-bot`
|
|
142
|
-
- `nodejs-api`
|
|
143
|
-
- `wa-bot`
|
|
144
|
-
- `python-bot`
|
|
145
|
-
- `blank`
|
|
146
|
-
|
|
147
|
-
## Create user
|
|
183
|
+
Create user:
|
|
148
184
|
|
|
149
185
|
```bash
|
|
150
186
|
ptero-gateway admin create-user \
|
|
@@ -154,9 +190,7 @@ ptero-gateway admin create-user \
|
|
|
154
190
|
--yes
|
|
155
191
|
```
|
|
156
192
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
Selalu mulai dengan dry-run:
|
|
193
|
+
Create server dengan dry-run:
|
|
160
194
|
|
|
161
195
|
```bash
|
|
162
196
|
ptero-gateway admin create-server \
|
|
@@ -171,7 +205,7 @@ ptero-gateway admin create-server \
|
|
|
171
205
|
--dry-run
|
|
172
206
|
```
|
|
173
207
|
|
|
174
|
-
|
|
208
|
+
Create server asli:
|
|
175
209
|
|
|
176
210
|
```bash
|
|
177
211
|
ptero-gateway admin create-server \
|
|
@@ -186,20 +220,7 @@ ptero-gateway admin create-server \
|
|
|
186
220
|
--yes
|
|
187
221
|
```
|
|
188
222
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
Wizard membantu input secara interaktif tanpa membuka kontrol node/location/allocation.
|
|
192
|
-
|
|
193
|
-
```bash
|
|
194
|
-
ptero-wizard help
|
|
195
|
-
ptero-wizard create-user --dry-run
|
|
196
|
-
ptero-wizard create-server --dry-run
|
|
197
|
-
ptero-wizard create-server --yes
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
Node ID, Nest ID, dan Egg ID tetap diisi manual oleh admin. Gunakan `ptero-gateway ids` untuk melihat daftar ID.
|
|
201
|
-
|
|
202
|
-
## Admin server
|
|
223
|
+
Admin server:
|
|
203
224
|
|
|
204
225
|
```bash
|
|
205
226
|
ptero-gateway admin server 5 detail
|
|
@@ -210,7 +231,7 @@ ptero-gateway admin server 5 unsuspend --yes
|
|
|
210
231
|
ptero-gateway admin server 5 reinstall --yes
|
|
211
232
|
```
|
|
212
233
|
|
|
213
|
-
|
|
234
|
+
Client server:
|
|
214
235
|
|
|
215
236
|
```bash
|
|
216
237
|
ptero-gateway probe 311d56b7
|
|
@@ -242,30 +263,56 @@ ptero-gateway server 311d56b7 kill --yes
|
|
|
242
263
|
ptero-gateway server 311d56b7 command "npm start" --yes
|
|
243
264
|
```
|
|
244
265
|
|
|
245
|
-
|
|
266
|
+
## Preset dan template
|
|
267
|
+
|
|
268
|
+
Lihat preset resource:
|
|
246
269
|
|
|
247
270
|
```bash
|
|
248
|
-
ptero-gateway
|
|
249
|
-
ptero-gateway server 311d56b7 init-node-alive --yes
|
|
250
|
-
ptero-gateway server 311d56b7 start --yes
|
|
271
|
+
ptero-gateway presets
|
|
251
272
|
```
|
|
252
273
|
|
|
253
|
-
Backup
|
|
274
|
+
| Preset | Memory | Disk | CPU | Database | Allocation | Backup | Cocok untuk |
|
|
275
|
+
|---|---:|---:|---:|---:|---:|---:|---|
|
|
276
|
+
| `mini` | 512MB | 1GB | 50% | 0 | 1 | 0 | Testing dan bot kecil. |
|
|
277
|
+
| `basic` | 1GB | 2GB | 100% | 0 | 1 | 0 | Bot Telegram/Discord sederhana. |
|
|
278
|
+
| `standard` | 2GB | 5GB | 200% | 1 | 1 | 1 | Bot WhatsApp, API, website kecil. |
|
|
279
|
+
| `premium` | 4GB | 10GB | 300% | 2 | 2 | 2 | Project lebih aktif. |
|
|
280
|
+
| `unlimited` | 0 | 0 | 0 | 5 | 3 | 3 | Resource unlimited sesuai aturan panel. |
|
|
281
|
+
|
|
282
|
+
Lihat template:
|
|
254
283
|
|
|
255
284
|
```bash
|
|
256
|
-
ptero-gateway
|
|
257
|
-
ptero-gateway
|
|
258
|
-
ptero-gateway
|
|
259
|
-
|
|
285
|
+
ptero-gateway templates list
|
|
286
|
+
ptero-gateway templates show nodejs-bot
|
|
287
|
+
ptero-gateway templates command nodejs-bot --name "bot saya" --email user@example.com --node 1 --nest 5 --egg 18
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Template bawaan:
|
|
291
|
+
|
|
292
|
+
- `nodejs-bot`
|
|
293
|
+
- `nodejs-api`
|
|
294
|
+
- `wa-bot`
|
|
295
|
+
- `python-bot`
|
|
296
|
+
- `blank`
|
|
297
|
+
|
|
298
|
+
## Wizard interaktif
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
ptero-wizard help
|
|
302
|
+
ptero-wizard create-user --dry-run
|
|
303
|
+
ptero-wizard create-server --dry-run
|
|
304
|
+
ptero-wizard create-server --yes
|
|
260
305
|
```
|
|
261
306
|
|
|
262
|
-
|
|
307
|
+
Wizard tidak mengelola node, location, atau allocation. Node ID, Nest ID, dan Egg ID tetap harus dipilih oleh admin.
|
|
308
|
+
|
|
309
|
+
## SDK usage
|
|
263
310
|
|
|
264
311
|
```ts
|
|
265
312
|
import { createPtero } from "@akaanakbaik/pterodactyl-gateway";
|
|
266
313
|
|
|
267
314
|
const ptero = createPtero({
|
|
268
|
-
domain:
|
|
315
|
+
domain: process.env.PTERO_DOMAIN,
|
|
269
316
|
ptla: process.env.PTERO_PTLA,
|
|
270
317
|
ptlc: process.env.PTERO_PTLC
|
|
271
318
|
});
|
|
@@ -273,37 +320,27 @@ const ptero = createPtero({
|
|
|
273
320
|
await ptero.connect();
|
|
274
321
|
```
|
|
275
322
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
```ts
|
|
279
|
-
import { createPtero } from "@akaanakbaik/pterodactyl-gateway";
|
|
280
|
-
|
|
281
|
-
const ptero = createPtero.fromEnv();
|
|
282
|
-
const doctor = await ptero.doctor();
|
|
283
|
-
console.log(doctor);
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
Create user SDK:
|
|
323
|
+
Create user:
|
|
287
324
|
|
|
288
325
|
```ts
|
|
289
326
|
const user = await ptero.users.createSmart({
|
|
290
327
|
username: "aka_test",
|
|
291
328
|
email: "user@example.com",
|
|
292
329
|
password: "auto",
|
|
293
|
-
administrator:
|
|
330
|
+
administrator: "no"
|
|
294
331
|
});
|
|
295
332
|
```
|
|
296
333
|
|
|
297
|
-
Create server
|
|
334
|
+
Create server:
|
|
298
335
|
|
|
299
336
|
```ts
|
|
300
337
|
const server = await ptero.servers.createSmart({
|
|
301
|
-
name: "Bot
|
|
338
|
+
name: "Bot Aka",
|
|
302
339
|
email: "user@example.com",
|
|
303
340
|
username: "aka_test",
|
|
304
|
-
password: "
|
|
341
|
+
password: "auto",
|
|
305
342
|
autoCreateUser: true,
|
|
306
|
-
description: "Server bot
|
|
343
|
+
description: "Server bot untuk user",
|
|
307
344
|
nodeId: 1,
|
|
308
345
|
nestId: 5,
|
|
309
346
|
eggId: 18,
|
|
@@ -318,14 +355,15 @@ const server = await ptero.servers.createSmart({
|
|
|
318
355
|
});
|
|
319
356
|
```
|
|
320
357
|
|
|
321
|
-
|
|
358
|
+
Preview dan dry-run:
|
|
322
359
|
|
|
323
360
|
```ts
|
|
324
|
-
const preview = await ptero.servers.
|
|
325
|
-
|
|
361
|
+
const preview = await ptero.servers.previewCreate(input);
|
|
362
|
+
const dryRun = await ptero.servers.createSmart(input, { dryRun: true });
|
|
363
|
+
console.log(preview.payload, dryRun.payload);
|
|
326
364
|
```
|
|
327
365
|
|
|
328
|
-
Client
|
|
366
|
+
Client server:
|
|
329
367
|
|
|
330
368
|
```ts
|
|
331
369
|
const server = ptero.server("311d56b7");
|
|
@@ -337,6 +375,7 @@ await server.files.write("/tmp/test.txt", "halo");
|
|
|
337
375
|
await server.startup.variables();
|
|
338
376
|
await server.startup.set("CMD_RUN", "node index.js");
|
|
339
377
|
await server.backups.list();
|
|
378
|
+
await server.start();
|
|
340
379
|
```
|
|
341
380
|
|
|
342
381
|
Raw request:
|
|
@@ -346,18 +385,305 @@ await ptero.raw.application.get("/users");
|
|
|
346
385
|
await ptero.raw.client.get("/servers/311d56b7/resources");
|
|
347
386
|
```
|
|
348
387
|
|
|
388
|
+
## Integration helpers
|
|
389
|
+
|
|
390
|
+
Helper integrasi membuat input server lebih konsisten untuk bot dan website.
|
|
391
|
+
|
|
392
|
+
```ts
|
|
393
|
+
import { createIntegrationServerInput } from "@akaanakbaik/pterodactyl-gateway";
|
|
394
|
+
|
|
395
|
+
const input = createIntegrationServerInput({
|
|
396
|
+
kind: "whatsapp-bot",
|
|
397
|
+
name: "WA Bot Aka",
|
|
398
|
+
email: "user@example.com",
|
|
399
|
+
username: "aka_wa",
|
|
400
|
+
password: "auto",
|
|
401
|
+
autoCreateUser: true,
|
|
402
|
+
nodeId: 1,
|
|
403
|
+
nestId: 5,
|
|
404
|
+
eggId: 18,
|
|
405
|
+
environment: {
|
|
406
|
+
OWNER: "aka"
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
Service helper:
|
|
412
|
+
|
|
413
|
+
```ts
|
|
414
|
+
import { createIntegrationService } from "@akaanakbaik/pterodactyl-gateway";
|
|
415
|
+
|
|
416
|
+
const service = createIntegrationService({
|
|
417
|
+
domain: process.env.PTERO_DOMAIN,
|
|
418
|
+
ptla: process.env.PTERO_PTLA,
|
|
419
|
+
ptlc: process.env.PTERO_PTLC
|
|
420
|
+
}, {
|
|
421
|
+
nodeId: 1,
|
|
422
|
+
nestId: 5,
|
|
423
|
+
eggId: 18,
|
|
424
|
+
preset: "standard",
|
|
425
|
+
autoCreateUser: true
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
const dryRun = await service.dryRun({
|
|
429
|
+
kind: "telegram-bot",
|
|
430
|
+
name: "Telegram Bot User",
|
|
431
|
+
email: "user@example.com",
|
|
432
|
+
username: "user_tg",
|
|
433
|
+
password: "auto"
|
|
434
|
+
});
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
Kind yang tersedia:
|
|
438
|
+
|
|
439
|
+
```ts
|
|
440
|
+
"whatsapp-bot" | "telegram-bot" | "discord-bot" | "nodejs-api" | "website" | "python-bot" | "blank"
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
## Contoh integrasi bot WhatsApp
|
|
444
|
+
|
|
445
|
+
Contoh flow untuk bot store panel WhatsApp:
|
|
446
|
+
|
|
447
|
+
```ts
|
|
448
|
+
import { createIntegrationService, explainError } from "@akaanakbaik/pterodactyl-gateway";
|
|
449
|
+
|
|
450
|
+
const pterodactyl = createIntegrationService({
|
|
451
|
+
domain: process.env.PTERO_DOMAIN,
|
|
452
|
+
ptla: process.env.PTERO_PTLA,
|
|
453
|
+
ptlc: process.env.PTERO_PTLC
|
|
454
|
+
}, {
|
|
455
|
+
nodeId: Number(process.env.PTERO_NODE_ID),
|
|
456
|
+
nestId: Number(process.env.PTERO_NEST_ID),
|
|
457
|
+
eggId: Number(process.env.PTERO_EGG_ID),
|
|
458
|
+
preset: "standard",
|
|
459
|
+
autoCreateUser: true
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
export async function createWaBotPanel(order) {
|
|
463
|
+
try {
|
|
464
|
+
const result = await pterodactyl.create({
|
|
465
|
+
kind: "whatsapp-bot",
|
|
466
|
+
name: `wa-${order.username}`,
|
|
467
|
+
email: order.email,
|
|
468
|
+
username: order.username,
|
|
469
|
+
password: "auto",
|
|
470
|
+
environment: {
|
|
471
|
+
OWNER_NUMBER: order.ownerNumber,
|
|
472
|
+
BOT_NAME: order.botName
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
return { ok: true, result };
|
|
476
|
+
} catch (error) {
|
|
477
|
+
return { ok: false, message: explainError(error) };
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
Saran untuk bot WhatsApp:
|
|
483
|
+
|
|
484
|
+
- Simpan session WhatsApp di volume server, bukan di memory.
|
|
485
|
+
- Jangan kirim password panel ke grup publik.
|
|
486
|
+
- Gunakan queue agar create server tidak bentrok saat order ramai.
|
|
487
|
+
- Selalu dry-run payload untuk paket baru sebelum digunakan production.
|
|
488
|
+
|
|
489
|
+
## Contoh integrasi bot Telegram
|
|
490
|
+
|
|
491
|
+
Contoh handler command Telegram:
|
|
492
|
+
|
|
493
|
+
```ts
|
|
494
|
+
import { Bot } from "grammy";
|
|
495
|
+
import { createIntegrationService, explainError } from "@akaanakbaik/pterodactyl-gateway";
|
|
496
|
+
|
|
497
|
+
const bot = new Bot(process.env.TELEGRAM_BOT_TOKEN);
|
|
498
|
+
|
|
499
|
+
const pterodactyl = createIntegrationService({
|
|
500
|
+
domain: process.env.PTERO_DOMAIN,
|
|
501
|
+
ptla: process.env.PTERO_PTLA,
|
|
502
|
+
ptlc: process.env.PTERO_PTLC
|
|
503
|
+
}, {
|
|
504
|
+
nodeId: Number(process.env.PTERO_NODE_ID),
|
|
505
|
+
nestId: Number(process.env.PTERO_NEST_ID),
|
|
506
|
+
eggId: Number(process.env.PTERO_EGG_ID),
|
|
507
|
+
preset: "basic",
|
|
508
|
+
autoCreateUser: true
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
bot.command("createpanel", async ctx => {
|
|
512
|
+
try {
|
|
513
|
+
const email = `${ctx.from.id}@telegram.local`;
|
|
514
|
+
const result = await pterodactyl.create({
|
|
515
|
+
kind: "telegram-bot",
|
|
516
|
+
name: `tg-${ctx.from.id}`,
|
|
517
|
+
email,
|
|
518
|
+
username: `tg_${ctx.from.id}`,
|
|
519
|
+
password: "auto"
|
|
520
|
+
});
|
|
521
|
+
await ctx.reply(`Panel berhasil dibuat: ${result.identifier ?? result.id}`);
|
|
522
|
+
} catch (error) {
|
|
523
|
+
await ctx.reply(explainError(error));
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
bot.start();
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
Saran untuk bot Telegram:
|
|
531
|
+
|
|
532
|
+
- Batasi command create panel hanya untuk admin atau user yang sudah bayar.
|
|
533
|
+
- Simpan riwayat transaksi di database sendiri.
|
|
534
|
+
- Gunakan `dryRun` saat testing paket baru.
|
|
535
|
+
- Pakai `ctx.from.id` sebagai referensi unik, bukan username Telegram yang bisa berubah.
|
|
536
|
+
|
|
537
|
+
## Contoh integrasi bot Discord
|
|
538
|
+
|
|
539
|
+
```ts
|
|
540
|
+
import { Client, GatewayIntentBits } from "discord.js";
|
|
541
|
+
import { createIntegrationService, explainError } from "@akaanakbaik/pterodactyl-gateway";
|
|
542
|
+
|
|
543
|
+
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
|
|
544
|
+
|
|
545
|
+
const pterodactyl = createIntegrationService({
|
|
546
|
+
domain: process.env.PTERO_DOMAIN,
|
|
547
|
+
ptla: process.env.PTERO_PTLA,
|
|
548
|
+
ptlc: process.env.PTERO_PTLC
|
|
549
|
+
}, {
|
|
550
|
+
nodeId: Number(process.env.PTERO_NODE_ID),
|
|
551
|
+
nestId: Number(process.env.PTERO_NEST_ID),
|
|
552
|
+
eggId: Number(process.env.PTERO_EGG_ID),
|
|
553
|
+
preset: "basic",
|
|
554
|
+
autoCreateUser: true
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
async function createDiscordPanel(interaction) {
|
|
558
|
+
try {
|
|
559
|
+
const result = await pterodactyl.create({
|
|
560
|
+
kind: "discord-bot",
|
|
561
|
+
name: `dc-${interaction.user.id}`,
|
|
562
|
+
email: `${interaction.user.id}@discord.local`,
|
|
563
|
+
username: `dc_${interaction.user.id}`,
|
|
564
|
+
password: "auto"
|
|
565
|
+
});
|
|
566
|
+
await interaction.reply({ content: `Server dibuat: ${result.identifier ?? result.id}`, ephemeral: true });
|
|
567
|
+
} catch (error) {
|
|
568
|
+
await interaction.reply({ content: explainError(error), ephemeral: true });
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
client.login(process.env.DISCORD_TOKEN);
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
Saran untuk bot Discord:
|
|
576
|
+
|
|
577
|
+
- Gunakan ephemeral reply untuk data sensitif.
|
|
578
|
+
- Jangan menampilkan password/API key di channel publik.
|
|
579
|
+
- Batasi role yang boleh create server.
|
|
580
|
+
|
|
581
|
+
## Contoh integrasi website atau API
|
|
582
|
+
|
|
583
|
+
Contoh Express API:
|
|
584
|
+
|
|
585
|
+
```ts
|
|
586
|
+
import express from "express";
|
|
587
|
+
import { createIntegrationService, explainError } from "@akaanakbaik/pterodactyl-gateway";
|
|
588
|
+
|
|
589
|
+
const app = express();
|
|
590
|
+
app.use(express.json());
|
|
591
|
+
|
|
592
|
+
const pterodactyl = createIntegrationService({
|
|
593
|
+
domain: process.env.PTERO_DOMAIN,
|
|
594
|
+
ptla: process.env.PTERO_PTLA,
|
|
595
|
+
ptlc: process.env.PTERO_PTLC
|
|
596
|
+
}, {
|
|
597
|
+
nodeId: Number(process.env.PTERO_NODE_ID),
|
|
598
|
+
nestId: Number(process.env.PTERO_NEST_ID),
|
|
599
|
+
eggId: Number(process.env.PTERO_EGG_ID),
|
|
600
|
+
preset: "standard",
|
|
601
|
+
autoCreateUser: true
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
app.post("/api/panel/preview", async (req, res) => {
|
|
605
|
+
const preview = await pterodactyl.dryRun({
|
|
606
|
+
kind: "website",
|
|
607
|
+
name: req.body.name,
|
|
608
|
+
email: req.body.email,
|
|
609
|
+
username: req.body.username,
|
|
610
|
+
password: "auto"
|
|
611
|
+
});
|
|
612
|
+
res.json(preview);
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
app.post("/api/panel/create", async (req, res) => {
|
|
616
|
+
try {
|
|
617
|
+
const result = await pterodactyl.create({
|
|
618
|
+
kind: "website",
|
|
619
|
+
name: req.body.name,
|
|
620
|
+
email: req.body.email,
|
|
621
|
+
username: req.body.username,
|
|
622
|
+
password: "auto"
|
|
623
|
+
});
|
|
624
|
+
res.json({ ok: true, result });
|
|
625
|
+
} catch (error) {
|
|
626
|
+
res.status(400).json({ ok: false, error: explainError(error) });
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
app.listen(3000);
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
Saran untuk website:
|
|
634
|
+
|
|
635
|
+
- Endpoint create panel wajib dilindungi auth admin atau status pembayaran.
|
|
636
|
+
- Jangan menjalankan create server langsung dari frontend.
|
|
637
|
+
- Simpan audit log order, Telegram ID/Discord ID/user ID, email, server ID, dan identifier.
|
|
638
|
+
- Gunakan rate limit per user/IP.
|
|
639
|
+
|
|
640
|
+
## Tips produksi
|
|
641
|
+
|
|
642
|
+
- Jalankan `ptero-gateway doctor` setelah deploy.
|
|
643
|
+
- Jalankan `ptero-gateway ids --nest <id>` untuk memastikan egg yang dipakai benar.
|
|
644
|
+
- Gunakan `dryRun` untuk semua paket baru.
|
|
645
|
+
- Pisahkan preset produk: mini/basic/standard/premium.
|
|
646
|
+
- Buat queue job untuk create server agar transaksi tidak race condition.
|
|
647
|
+
- Simpan hasil `identifier`, `uuid`, `id`, dan password yang generated hanya sekali.
|
|
648
|
+
- Untuk server bot, start manual setelah file source siap agar status tidak gagal.
|
|
649
|
+
|
|
349
650
|
## Keamanan
|
|
350
651
|
|
|
351
|
-
- Jangan hardcode PTLA/PTLC
|
|
352
|
-
-
|
|
652
|
+
- Jangan hardcode PTLA/PTLC.
|
|
653
|
+
- Jangan kirim API key atau config profile ke user.
|
|
654
|
+
- Jangan log password generated ke public log.
|
|
353
655
|
- Semua aksi tulis/ubah via CLI wajib `--yes`.
|
|
354
|
-
- Write file CLI default hanya boleh ke `/tmp`;
|
|
656
|
+
- Write file CLI default hanya boleh ke `/tmp`; path lain wajib `--allow-any-path`.
|
|
355
657
|
- Command berbahaya seperti `rm -rf /` diblokir oleh guard command.
|
|
356
|
-
-
|
|
357
|
-
- Command node/location/allocation management
|
|
358
|
-
|
|
658
|
+
- Delete user/server permanen tidak dibuka di CLI stabil.
|
|
659
|
+
- Command node/location/allocation management tidak dibuka di CLI stabil.
|
|
660
|
+
|
|
661
|
+
## Troubleshooting
|
|
359
662
|
|
|
360
|
-
|
|
663
|
+
Lihat daftar error:
|
|
664
|
+
|
|
665
|
+
```bash
|
|
666
|
+
ptero-gateway explain DOMAIN_REQUIRED
|
|
667
|
+
ptero-gateway explain DOCKER_IMAGE_NOT_FOUND
|
|
668
|
+
ptero-gateway explain STARTUP_VARIABLE_NOT_FOUND
|
|
669
|
+
ptero-gateway explain EEXIST
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
Masalah umum:
|
|
673
|
+
|
|
674
|
+
| Masalah | Solusi |
|
|
675
|
+
|---|---|
|
|
676
|
+
| `DOMAIN_REQUIRED` | Isi `PTERO_DOMAIN` atau jalankan `ptero-gateway config init`. |
|
|
677
|
+
| PTLA tidak valid | Buat ulang Application API Key dan pastikan permission cukup. |
|
|
678
|
+
| PTLC tidak valid | Buat ulang Client API Key dari account panel. |
|
|
679
|
+
| Docker image tidak ditemukan | Cek egg Docker Images atau isi `--docker-image`. |
|
|
680
|
+
| Tidak ada allocation kosong | Tambahkan allocation di panel admin node. |
|
|
681
|
+
| Backup gagal limit 0 | Naikkan limit backup server dulu. |
|
|
682
|
+
| Binary global konflik | Hapus `/usr/bin/ptero-gateway`, `/usr/bin/ptg`, lalu install ulang. |
|
|
683
|
+
|
|
684
|
+
## Release dan testing
|
|
685
|
+
|
|
686
|
+
Clone dan test lokal:
|
|
361
687
|
|
|
362
688
|
```bash
|
|
363
689
|
git clone https://github.com/akaanakbaik/pterodactyl-gateway.git
|
|
@@ -366,22 +692,27 @@ npm install
|
|
|
366
692
|
npm run verify
|
|
367
693
|
```
|
|
368
694
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
## Release checklist
|
|
695
|
+
Checklist publish:
|
|
372
696
|
|
|
373
697
|
```bash
|
|
374
698
|
npm run verify
|
|
375
699
|
npm publish --access public
|
|
376
|
-
npm view @akaanakbaik/pterodactyl-gateway@0.
|
|
377
|
-
npm i -g @akaanakbaik/pterodactyl-gateway@0.
|
|
700
|
+
npm view @akaanakbaik/pterodactyl-gateway@1.0.1 version --prefer-online --registry=https://registry.npmjs.org/
|
|
701
|
+
npm i -g @akaanakbaik/pterodactyl-gateway@1.0.1 --force --prefer-online --registry=https://registry.npmjs.org/
|
|
378
702
|
ptero-gateway self-check
|
|
379
703
|
ptero-gateway release-check
|
|
704
|
+
ptero-gateway doctor
|
|
380
705
|
```
|
|
381
706
|
|
|
382
|
-
##
|
|
707
|
+
## Versi npm lama
|
|
708
|
+
|
|
709
|
+
Rilis utama yang direkomendasikan adalah `1.0.0` dan tag `latest` harus mengarah ke versi tersebut. Versi lama di npm tidak dipromosikan lagi di dokumentasi ini. Jika perlu menyembunyikan versi lama dari pemakaian user, gunakan `npm deprecate` pada versi lama dengan pesan yang mengarahkan ke `1.0.0`.
|
|
383
710
|
|
|
384
|
-
|
|
711
|
+
Contoh:
|
|
712
|
+
|
|
713
|
+
```bash
|
|
714
|
+
npm deprecate @akaanakbaik/pterodactyl-gateway@"<1.0.0" "Versi lama tidak direkomendasikan. Gunakan @akaanakbaik/pterodactyl-gateway@1.0.1 atau latest."
|
|
715
|
+
```
|
|
385
716
|
|
|
386
717
|
## Lisensi
|
|
387
718
|
|