chore: add dependencies and configuration
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
f423e1f25d
commit
25c82bcf0b
@@ -0,0 +1,9 @@
|
|||||||
|
BOT_TOKEN=isi_token_bot_telegram
|
||||||
|
STORAGE_CHANNEL_ID=-1001234567890
|
||||||
|
BASE_URL=https://tele.asepharyana.tech
|
||||||
|
DATABASE_URL=postgresql://user:password@localhost:5432/telegram_uploader
|
||||||
|
PORT=3000
|
||||||
|
NODE_ENV=production
|
||||||
|
LOG_LEVEL=info
|
||||||
|
RATE_LIMIT_WINDOW_MS=60000
|
||||||
|
RATE_LIMIT_MAX_REQUESTS=30
|
||||||
@@ -1,15 +1,42 @@
|
|||||||
# teleuploader
|
# Telegram Bot Uploader Backend
|
||||||
|
|
||||||
To install dependencies:
|
Backend production-ready untuk upload file ke Telegram yang tersimpan di private channel.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
1. Install PostgreSQL database
|
||||||
|
2. Buat database: `createdb telegram_uploader`
|
||||||
|
3. Setup environment: `cp .env.example .env`
|
||||||
|
4. Edit `.env` dengan nilai yang sesuai
|
||||||
|
5. Create table: `bun run db:migrate`
|
||||||
|
6. Install dependencies: `bun install`
|
||||||
|
|
||||||
|
## Telegram Private Channel Setup
|
||||||
|
|
||||||
|
1. Buat private channel Telegram
|
||||||
|
2. Tambah bot sebagai admin di channel
|
||||||
|
3. Dapatkan `STORAGE_CHANNEL_ID` (misalnya -1001234567890)
|
||||||
|
|
||||||
|
## Running
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bun install
|
bun run dev # Development mode
|
||||||
|
bun run start # Production mode
|
||||||
```
|
```
|
||||||
|
|
||||||
To run:
|
## API Endpoints
|
||||||
|
|
||||||
```bash
|
- `POST /api/upload` - Upload file
|
||||||
bun run index.ts
|
- `GET /f/:public_id` - Download redirect
|
||||||
```
|
- `GET /file/:public_id/info` - File metadata
|
||||||
|
- `GET /health` - Health check
|
||||||
|
|
||||||
This project was created using `bun init` in bun v1.3.14. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
|
## FAQ
|
||||||
|
|
||||||
|
**URL permanen maksudnya apa?**
|
||||||
|
URL backend tetap permanen: `https://tele.asepharyana.tech/f/{public_id}`
|
||||||
|
Ini berarti URL service Anda fix, bukan jaminan file Telegram abadi.
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
Gunakan bot Telegram untuk upload, atau upload API langsung via HTTP.
|
||||||
|
|||||||
+14
-5
@@ -1,12 +1,21 @@
|
|||||||
{
|
{
|
||||||
"name": "teleuploader",
|
"name": "teleuploader",
|
||||||
"module": "index.ts",
|
"version": "1.0.0",
|
||||||
|
"description": "Telegram file uploader backend",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"scripts": {
|
||||||
|
"dev": "bun --hot index.js",
|
||||||
|
"start": "NODE_ENV=production bun index.js",
|
||||||
|
"db:migrate": "psql $DATABASE_URL -f schema.sql"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"pg": "^8.11.0",
|
||||||
|
"drizzle-orm": "^0.29.0",
|
||||||
|
"telegraf": "^4.15.0",
|
||||||
|
"winston": "^3.11.0",
|
||||||
|
"nanoid": "^5.0.4"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bun": "latest"
|
"@types/bun": "latest"
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"typescript": "^5"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
CREATE TABLE files (
|
||||||
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||||
|
public_id VARCHAR(21) UNIQUE NOT NULL,
|
||||||
|
telegram_file_id VARCHAR NOT NULL,
|
||||||
|
telegram_file_unique_id VARCHAR NOT NULL,
|
||||||
|
storage_chat_id BIGINT NOT NULL,
|
||||||
|
storage_message_id BIGINT NOT NULL,
|
||||||
|
file_name VARCHAR NOT NULL,
|
||||||
|
mime_type VARCHAR NOT NULL,
|
||||||
|
size_bytes BIGINT NOT NULL,
|
||||||
|
file_type VARCHAR NOT NULL,
|
||||||
|
uploader_id BIGINT NOT NULL,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX idx_files_public_id ON files(public_id);
|
||||||
|
CREATE INDEX idx_files_telegram_file_id ON files(telegram_file_id);
|
||||||
|
CREATE INDEX idx_files_uploader_id ON files(uploader_id);
|
||||||
|
CREATE INDEX idx_files_created_at ON files(created_at DESC);
|
||||||
Reference in New Issue
Block a user