use a proper readme
This commit is contained in:
parent
f83a70a685
commit
8bec591238
76
README.md
76
README.md
@ -1,3 +1,75 @@
|
||||
# Termcord
|
||||
# Termcloud
|
||||
|
||||
im just bored, this isnt gonna go anywhere.
|
||||
A simple file storage service with user buckets and usage limits.
|
||||
|
||||
## Setup
|
||||
|
||||
1. Set up PostgreSQL database and run the schema:
|
||||
|
||||
```bash
|
||||
psql -d termcloud -f internal/db/schema.sql
|
||||
```
|
||||
|
||||
2. Set environment variables:
|
||||
|
||||
```bash
|
||||
# .env.example
|
||||
DATABASE_URL="postgres://user:password@localhost/termcloud"
|
||||
PORT="8080"
|
||||
```
|
||||
|
||||
3. Build and run:
|
||||
|
||||
```bash
|
||||
make build
|
||||
make run
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Create a user and get API key:
|
||||
|
||||
```bash
|
||||
make admin ARGS="create-user mai sakurajima@waifu.club 5"
|
||||
```
|
||||
|
||||
### API Endpoints
|
||||
|
||||
All API endpoints require `X-API-Key` header.
|
||||
|
||||
**Buckets:**
|
||||
|
||||
- `GET /api/v1/buckets` - List user buckets
|
||||
- `POST /api/v1/buckets` - Create bucket `{"name": "my-bucket"}`
|
||||
- `DELETE /api/v1/buckets/:bucket` - Delete bucket
|
||||
|
||||
**Objects:**
|
||||
|
||||
- `GET /api/v1/buckets/:bucket/objects` - List objects in bucket
|
||||
- `PUT /api/v1/buckets/:bucket/objects/*` - Upload file (multipart form with "file" field)
|
||||
- `GET /api/v1/buckets/:bucket/objects/*` - Download file
|
||||
- `DELETE /api/v1/buckets/:bucket/objects/*` - Delete file
|
||||
|
||||
**User Info:**
|
||||
|
||||
- `GET /api/v1/user` - Get user info and usage stats
|
||||
|
||||
### Example Usage
|
||||
|
||||
```bash
|
||||
# Create bucket
|
||||
curl -X POST http://localhost:8080/api/v1/buckets \
|
||||
-H "X-API-Key: your-api-key" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name": "my-files"}'
|
||||
|
||||
# Upload file
|
||||
curl -X PUT http://localhost:8080/api/v1/buckets/my-files/objects/test.txt \
|
||||
-H "X-API-Key: your-api-key" \
|
||||
-F "file=@test.txt"
|
||||
|
||||
# Download file
|
||||
curl http://localhost:8080/api/v1/buckets/my-files/objects/test.txt \
|
||||
-H "X-API-Key: your-api-key" \
|
||||
-o downloaded.txt
|
||||
```
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user