Add full monorepo: virtual-banker, backend, frontend, docs, scripts, deployment
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
69
backend/api/rest/README.md
Normal file
69
backend/api/rest/README.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# REST API Server
|
||||
|
||||
REST API implementation for the ChainID 138 Explorer Platform.
|
||||
|
||||
## Structure
|
||||
|
||||
- `server.go` - Main server setup and route configuration
|
||||
- `routes.go` - Route handlers and URL parsing
|
||||
- `blocks.go` - Block-related endpoints
|
||||
- `transactions.go` - Transaction-related endpoints
|
||||
- `addresses.go` - Address-related endpoints
|
||||
- `search.go` - Unified search endpoint
|
||||
- `validation.go` - Input validation utilities
|
||||
- `middleware.go` - HTTP middleware (logging, compression)
|
||||
- `errors.go` - Error response utilities
|
||||
|
||||
## API Endpoints
|
||||
|
||||
### Blocks
|
||||
- `GET /api/v1/blocks` - List blocks (paginated)
|
||||
- `GET /api/v1/blocks/{chain_id}/{number}` - Get block by number
|
||||
- `GET /api/v1/blocks/{chain_id}/hash/{hash}` - Get block by hash
|
||||
|
||||
### Transactions
|
||||
- `GET /api/v1/transactions` - List transactions (paginated, filterable)
|
||||
- `GET /api/v1/transactions/{chain_id}/{hash}` - Get transaction by hash
|
||||
|
||||
### Addresses
|
||||
- `GET /api/v1/addresses/{chain_id}/{address}` - Get address information
|
||||
|
||||
### Search
|
||||
- `GET /api/v1/search?q={query}` - Unified search (auto-detects type: block number, address, or transaction hash)
|
||||
|
||||
### Health
|
||||
- `GET /health` - Health check endpoint
|
||||
|
||||
## Features
|
||||
|
||||
- Input validation (addresses, hashes, block numbers)
|
||||
- Pagination support
|
||||
- Query timeouts for database operations
|
||||
- CORS headers
|
||||
- Request logging
|
||||
- Error handling with consistent error format
|
||||
- Health checks with database connectivity
|
||||
|
||||
## Running
|
||||
|
||||
```bash
|
||||
cd backend/api/rest
|
||||
go run main.go
|
||||
```
|
||||
|
||||
Or use the development script:
|
||||
```bash
|
||||
./scripts/run-dev.sh
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Set environment variables:
|
||||
- `DB_HOST` - Database host
|
||||
- `DB_PORT` - Database port
|
||||
- `DB_USER` - Database user
|
||||
- `DB_PASSWORD` - Database password
|
||||
- `DB_NAME` - Database name
|
||||
- `PORT` - API server port (default: 8080)
|
||||
- `CHAIN_ID` - Chain ID (default: 138)
|
||||
|
||||
Reference in New Issue
Block a user