- Express server with CORS, JSON middleware - Auth middleware (Bearer token) - Document CRUD with markdown storage - Library CRUD with nested support - Tag indexing and search - Error handler middleware - Config from env vars - Init script for data structure
103 lines
2.1 KiB
Markdown
103 lines
2.1 KiB
Markdown
# SimpleNote Web
|
|
|
|
REST API para gestión de documentos basada en archivos Markdown con soporte para librerías anidadas y tags.
|
|
|
|
## Características
|
|
|
|
- API REST completa (Express.js)
|
|
- Almacenamiento en archivos Markdown + JSON
|
|
- Soporte para librerías anidadas
|
|
- Indexación de tags
|
|
- Autenticación por tokens Bearer
|
|
|
|
## Requisitos
|
|
|
|
- Node.js 18+
|
|
|
|
## Instalación
|
|
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
## Configuración
|
|
|
|
Copia `.env.example` a `.env` y ajusta las variables:
|
|
|
|
```env
|
|
PORT=3000
|
|
HOST=0.0.0.0
|
|
DATA_ROOT=./data
|
|
ADMIN_TOKEN=snk_your_initial_token
|
|
CORS_ORIGIN=*
|
|
API_PREFIX=/api/v1
|
|
```
|
|
|
|
## Inicialización
|
|
|
|
```bash
|
|
npm run init
|
|
```
|
|
|
|
Esto crea la estructura inicial de datos y una librería "Default Library".
|
|
|
|
## Uso
|
|
|
|
### Desarrollo
|
|
|
|
```bash
|
|
npm run dev
|
|
```
|
|
|
|
### Producción
|
|
|
|
```bash
|
|
npm start
|
|
```
|
|
|
|
## API Endpoints
|
|
|
|
### Auth
|
|
- `POST /api/v1/auth/token` - Generar token (admin)
|
|
- `GET /api/v1/auth/verify` - Verificar token
|
|
|
|
### Documents
|
|
- `GET /api/v1/documents` - Listar documentos (filtros: tag, library, type, status)
|
|
- `GET /api/v1/documents/:id` - Obtener documento
|
|
- `POST /api/v1/documents` - Crear documento
|
|
- `PUT /api/v1/documents/:id` - Actualizar documento
|
|
- `DELETE /api/v1/documents/:id` - Eliminar documento
|
|
- `GET /api/v1/documents/:id/export` - Exportar como Markdown
|
|
- `POST /api/v1/documents/:id/tags` - Agregar tags
|
|
|
|
### Libraries
|
|
- `GET /api/v1/libraries` - Listar librerías raíz
|
|
- `GET /api/v1/libraries/:id` - Ver contenido de librería
|
|
- `POST /api/v1/libraries` - Crear librería
|
|
- `GET /api/v1/libraries/:id/tree` - Árbol completo
|
|
- `DELETE /api/v1/libraries/:id` - Eliminar librería
|
|
|
|
### Tags
|
|
- `GET /api/v1/tags` - Listar todos los tags
|
|
- `GET /api/v1/tags/:tag` - Documentos con tag específico
|
|
|
|
## Estructura de Datos
|
|
|
|
```
|
|
data/
|
|
├── .auth-tokens.json # Tokens de API
|
|
├── .tag-index.json # Índice global de tags
|
|
└── libraries/
|
|
└── {id}/
|
|
├── .library.json
|
|
├── documents/
|
|
│ └── {doc-id}/
|
|
│ ├── index.md
|
|
│ └── .meta.json
|
|
└── sub-libraries/
|
|
```
|
|
|
|
## Licencia
|
|
|
|
MIT
|