agentsclimarketplace

Crear endpoint

Skill eduardo-lezama/intranet-dashboard/.windsurf.bak/skills/crear-endpoint

Usar al crear un nuevo endpoint API en blueprints/main.pyFrom its SKILL.md

Install
npx -y skills add eduardo-lezama/intranet-dashboard --skill crear-endpoint

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.3 KB, 625 tokens by cl100k_base, as published. Nobody here has run it

Cuándo usar esta skill

  • Al crear un nuevo endpoint /api/[recurso]
  • Cuando se necesite exponer datos de un servicio externo
  • Para añadir nuevas rutas al blueprint principal

Contexto necesario antes de empezar

  1. Leer blueprints/main.py para ver patrones existentes
  2. Verificar si ya existe un cliente para el servicio
  3. Comprobar configuración necesaria en config.py

Pasos

1. Definir el endpoint

  • Ruta: /api/[recurso]
  • Método: GET (lectura), POST (crear), DELETE (eliminar)
  • Respuesta: JSON

2. Añadir configuración (si es necesario)

# En config.py, clase Config
NUEVO_SERVICIO_URL = env_target('NUEVO_SERVICIO_URL', 'http://local', 'http://docker')
NUEVO_SERVICIO_TOKEN = env_str('NUEVO_SERVICIO_TOKEN')

3. Crear cliente (si hay API externa)

  • Usar skill @crear-cliente

4. Implementar endpoint en blueprints/main.py

@main_bp.route('/api/nuevo')
@cache.cached(timeout=180)
def api_nuevo():
    """Descripción del endpoint"""
    try:
        url = current_app.config.get('NUEVO_SERVICIO_URL')
        token = current_app.config.get('NUEVO_SERVICIO_TOKEN')
        
        if not url:
            return jsonify({'error': 'NUEVO_SERVICIO_URL no configurado'}), 500
        
        client = NuevoClient(url, token)
        data = client.get_data()
        
        return jsonify(data)
        
    except Exception as e:
        current_app.logger.error(f"Error nuevo: {str(e)}")
        return jsonify({'error': str(e)}), 500

5. Validar

ruff check blueprints/main.py
python -c "from app import app"

<patrones_criticos> SIEMPRE:

  • Usar @cache.cached() para endpoints de lectura
  • Validar configuración antes de usar
  • Logging de errores con current_app.logger.error()
  • Retornar JSON con estructura consistente

NUNCA:

  • Endpoints sin manejo de errores
  • Hardcodear URLs o tokens
  • Usar print() en lugar de logger

PREFERENTEMENTE:

  • Timeout de cache según frecuencia de cambio del dato
  • Docstring describiendo el endpoint </patrones_criticos>

Checklist de validación

  • Endpoint responde correctamente
  • Errores se manejan y loguean
  • Cache configurado apropiadamente
  • ruff check . pasa
  • Documentado en README si es público

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.