Files
sheetless-server/README.md

74 lines
1.6 KiB
Markdown

# Sheetless Server
A Go-based server for hosting and managing PDF music sheets with user authentication.
## Features
- User registration and JWT-based authentication
- Upload, list, and download PDF music sheets
- SQLite database for data persistence
- RESTful API with Gin framework
## API Endpoints
### Authentication
- `POST /auth/register` - Register a new user
- `POST /auth/login` - Login and get JWT token
### Music Sheets (requires authentication)
- `POST /api/sheets/upload` - Upload a PDF music sheet
- `GET /api/sheets` - List all music sheets
- `GET /api/sheets/download/:id` - Download a specific sheet
## Development Setup
1. Enter the development environment:
```bash
nix develop
```
2. Download dependencies:
```bash
go mod tidy
```
3. Run the server:
```bash
go run main.go
```
## Building
To build the project:
```bash
go build -o sheetless-server main.go
```
## Usage Examples
### Register a user:
```bash
curl -X POST http://localhost:8080/auth/register \
-H "Content-Type: application/json" \
-d '{"username":"testuser","email":"test@example.com","password":"password123"}'
```
### Login:
```bash
curl -X POST http://localhost:8080/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"testuser","password":"password123"}'
```
### Upload a sheet (replace TOKEN with actual JWT):
```bash
curl -X POST http://localhost:8080/api/sheets/upload \
-H "Authorization: Bearer TOKEN" \
-F "title=My Sheet" \
-F "file=@sheet.pdf"
```
### List sheets:
```bash
curl -H "Authorization: Bearer TOKEN" http://localhost:8080/api/sheets
```