NW
6aa7980ddf
fix: bot no longer crashes container on invalid token
...
- bot.js: 5 retries with 5s delay on init, graceful fallback to null
- errorHandler.js: 5 retries on 404 (invalid token), stops polling after
max retries but keeps process alive for admin panel
- config.js: BOT_TOKEN missing logs warning instead of process.exit
- index.js: bot handlers only registered when bot is available,
admin panel always starts regardless of bot status
2026-06-24 15:05:44 +01:00
NW
6db770b96b
feat: editable settings page with .env write and container restart
...
- Add settings form with all config fields (Bot, Commission, Wallets, WireGuard)
- POST handler writes .env file and restarts container via process.exit(0)
- Secrets (ENCRYPTION_KEY, ADMIN_SECRET, GITEA_TOKEN, WG_PRIVATE_KEY, WG_PRESHARED_KEY)
are never sent to browser - masked placeholders used instead
- PRESERVE_KEYS enforced: secret keys cannot be overwritten via form
- Values sanitized: newlines stripped before writing to .env
- start.sh loads .env file before node to override Docker env_file cache
- Extract shared escapeHtml utility to escape.js (used by 6 view files)
- Update paymentWallets view to link to Settings page instead of .env
- Add .env volume mount for settings panel read/write
- Fix registerRoutes() not being called in index.js (bot menu buttons)
2026-06-23 12:32:25 +01:00
NW
4657b1dfb5
feat: web admin panel + better-sqlite3 migration + Docker fixes
...
- Added Express.js admin panel on port 3001 (ADMIN_PORT env)
- Dashboard: stats (users, products, purchases, revenue)
- Users: list, details, ban/unban toggle
- Products: CRUD by category
- Wallets: list with balances
- Purchases: history with filters
- Audit log: view audit trail
- Auth: token-based login with ADMIN_SECRET env var
- Migrated sqlite3 → better-sqlite3
- database.js: async adapter (runAsync/allAsync/getAsync)
- purchaseService.js: lastID → lastInsertRowid
- userService.js: lastID → lastInsertRowid
- Removed sqlite3 from package.json
- Fixed: dotenv/config import added to index.js
- Fixed: ENCRYPTION_KEY validation (32+ char hex)
- Fixed: Dockerfile multi-stage build (no python needed)
- Fixed: Docker DNS (network: host in build)
- Fixed: docker-compose port 3001, healthcheck on 3001
- Added express, cookie-parser, pino-pretty, better-sqlite3 deps
2026-06-22 10:54:01 +01:00
NW
25d8507b11
fix: Docker multi-stage build for sqlite3, health endpoint, productValidator exports
...
- Dockerfile: multi-stage build (builder with python3+g++ for native addons)
- Dockerfile: wireguard-tools from edge/community repo
- Dockerfile: removed USER appuser (start.sh needs root for wg-quick)
- Dockerfile: health check on port 3000
- Added /health HTTP endpoint in index.js for Docker healthcheck
- Fixed productValidator.js: added named exports (validateProductName, validateProductPrice)
- Added better-sqlite3 as fallback dependency
2026-06-22 10:18:36 +01:00
NW
a04e60d751
feat(state): replace in-memory Map with SQLite-backed stateService ( #59 )
...
- Create src/services/stateService.js with get/set/delete/has API
- Create migration 004_user_states.js (chat_id PK, state_data JSON, updated_at)
- TTL of 24 hours — expired states auto-deleted
- Cleanup job runs every hour (setInterval)
- Replace src/context/userStates.js Map with async stateService proxy
- Add await to all 45 userStates.get/set/delete/has calls across 13 files
- Add initStates() call in index.js startup sequence
- All state survives bot restarts now
18 files changed, 172 insertions, 46 deletions
2026-06-22 10:02:57 +01:00
NW
ce1b6003cb
feat(logging): replace 207 console.log/error/warn with pino structured logger ( #58 )
...
- Add pino + pino-pretty dependencies
- Create src/utils/logger.js with env-based LOG_LEVEL
- Replace all 207 console.log/error/warn calls across 46 source files
- Remove [DEBUG], [ERROR] string prefixes (levels convey this)
- Add pino redact for sensitive fields (mnemonic, privateKey, token, etc.)
- Structured logging with context objects instead of string interpolation
- NODE_ENV=production disables pino-pretty transport
49 files changed, 5601 insertions, 6056 deletions
2026-06-22 01:42:47 +01:00
NW
d0b26dae25
refactor(arch): replace if/else router with Map-based dispatcher ( #53 )
...
- index.js: 394→69 lines (82% reduction)
- callbackRouter.js (36 lines): Map-based dispatch with exact + prefix matching
- Longest-prefix-first for specificity
- Logs warning for unregistered callbacks
- messageRouter.js (27 lines): Ordered input handlers + text command Map
- routes.js (345 lines): All 59 callback routes + 9 text commands + 7 input handlers
- Exact routes: 19 (add_wallet, back_to_balance, etc.)
- Prefix routes: 40 (generate_wallet_, view_product_, etc.)
- Admin text commands with isAdmin guard
- Special cases: view_transaction_history_ page extraction
- Input handler order preserved (location → category → import → edit → dump → bonus)
2026-06-22 01:16:34 +01:00
NW
f8123e42bb
refactor(arch): split userWalletsHandler.js into 7 modular files ( #52 )
...
- 747-line monolith → 8 files (all ≤108 lines)
- balanceHandler (96 lines): showBalance, handleBackToBalance
- historyHandler (107 lines): handleTransactionHistory, handleWalletHistory
- refreshHandler (75 lines): handleRefreshBalance with balance refresh
- createHandler (94 lines): handleAddWallet, handleGenerateWallet
- topUpHandler (60 lines): handleTopUpWallet
- archiveHandler (86 lines): handleViewArchivedWallets
- helpers (19 lines): getNetworkName, getWalletAddress
- index.js (20 lines): re-exports all 11 handler methods
- Removed duplicate getBaseWalletType (now uses WalletUtils)
- Removed duplicate getNetworkName (now in helpers.js)
2026-06-22 01:11:53 +01:00
NW
4b7ed0c251
refactor(arch): split adminProductHandler.js into 13 modular files ( #51 )
...
- 1093-line monolith → 13 files (all ≤97 lines)
- navigationHandler: product management entry + country selection
- districtHandler: city + district selection
- categoryAddHandler: add category input + handler
- categoryEditHandler: edit category input + handler
- categorySelectionHandler: category selection display
- createHandler: add product prompt
- importHandler: product import (JSON/text/file)
- editStartHandler: product edit prompt
- editImportHandler: product edit import
- deleteHandler: product delete + confirm
- viewHandler: product detail view
- listHandler: product list with pagination
- productValidator: shared validation utilities
- index.js: router re-exporting all 17 handler methods
- Removed duplicate handleCategorySelection (subcategories table doesn't exist)
- Removed handleSubcategoryInput/handleAddSubcategory (references non-existent subcategories table)
2026-06-17 22:41:04 +01:00
NW
4b8144ac40
refactor(arch): split database.js into migrations + connection module ( #57 )
...
- database.js: 292→42 lines (connection + async helpers only)
- 001_initial_schema.js: 7 CREATE TABLE statements in transaction
- 002_add_columns.js: 5 ALTER TABLE checks with checkColumnExists
- 003_add_indexes.js: 6 CREATE INDEX statements
- runner.js: versioned migration runner with _meta table
- index.js: calls runMigrations() + cleanUpInvalidForeignKeys()
- ALLOWED_TABLES whitelist preserved in runner.js
- Schema version tracked in _meta table for idempotent runs
2026-06-17 22:28:11 +01:00
23b7f8b4bd
big update WG-TOR bot connecting
2025-02-03 09:43:25 +00:00
633a27164b
upgrade comission wallet function
2025-01-26 22:21:13 +00:00
c9bcb09221
udpdate wallet function
2024-12-24 09:19:14 +00:00
3129525a1e
update user and admin wallet function
2024-12-23 20:44:56 +00:00
9d9e0e80ad
Bug update function
2024-12-14 23:12:36 +00:00
95d5fe644d
Delet Subcategory Function
2024-12-13 16:41:41 +00:00
Artyom Ashirov
82ffa81141
account deletion
2024-12-05 21:29:32 +03:00
0d8230e93c
Add handleCategoryUpdate and handleEditCategory
2024-11-25 23:07:01 +00:00
Artyom Ashirov
5d4f56e265
refactoring
2024-11-23 05:03:30 +03:00
Artyom Ashirov
a760cb2d23
Bonus balance editing
2024-11-21 14:48:45 +03:00
Artyom Ashirov
1cb0467f6c
purchase viewing
2024-11-20 17:43:51 +03:00
Artyom Ashirov
6fa273f0b6
Item purchase
2024-11-19 05:01:13 +03:00
Artyom Ashirov
b45aa35527
Database import
2024-11-16 20:55:47 +03:00
Artyom Ashirov
e3f2e87fcc
export database
2024-11-16 19:18:50 +03:00
Artyom Ashirov
ec96f67dfe
Product edition
2024-11-16 17:53:43 +03:00
Artyom Ashirov
772cd738ca
merge glitch solved
2024-11-15 15:43:00 +03:00
1323ed5
d760c77593
Merge pull request 'feature/admin-section' ( #20 ) from feature/admin-section into main
...
Reviewed-on: #20
2024-11-15 12:34:09 +00:00
Artyom Ashirov
89a7a8b9c5
product deletion
2024-11-15 09:15:44 +03:00
Artyom Ashirov
e1eda05afe
products pagination
2024-11-15 08:19:54 +03:00
Artyom Ashirov
de5e405093
import from json
2024-11-15 07:07:02 +03:00
Artyom Ashirov
4251f1a0bd
user deletion/blocking
2024-11-15 06:18:55 +03:00
Artyom Ashirov
373e8e2567
user deletion/blocking
2024-11-15 02:26:13 +03:00
Artyom Ashirov
ebad9da439
Another back to admin fix
2024-11-15 00:25:34 +03:00
Artyom Ashirov
f504d5fb7b
Back to admin menu fix
2024-11-15 00:15:13 +03:00
Artyom Ashirov
d506d79367
users pagination
2024-11-14 21:27:32 +03:00
Artyom Ashirov
2beaa324fa
Users location edition added
2024-11-14 20:16:17 +03:00
SoftUniq
abfa7b43af
Initial commit
2024-11-13 22:31:18 +00:00