Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Require a bearer token for the Express analytics endpoint

Cerrado
#232 2 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@anurag2787 ya está trabajando en esto.

Desde el 20/10/2026.

  • #272 de @anurag2787 — fusionado

Evaluación

Este issue todavía no se ha evaluado.

Descripción

enhancement good first issue hacktoberfest server

chatcopsAnalyticsHandler (packages/server/src/adapters/express.ts, lines 73 to 78) answers anyone who finds the URL. The stats aren't secret, but they show how much traffic and how many leads a site gets, which is nobody else's business.

What to do

  • Add analyticsToken?: string to ChatCopsServerConfig (packages/server/src/config.ts), with a short doc comment.
  • When it's set, chatcopsAnalyticsHandler only answers requests with Authorization: Bearer <token>. Anything else gets 401 with { "error": "unauthorized" } and a WWW-Authenticate: Bearer header.
  • Compare the tokens in constant time. Don't import node:crypto: this file is part of the same bundle Workers load. A small loop that compares every character, and checks the length, is enough.
  • When it isn't set, keep today's behavior so nothing breaks, but log one warning the first time the endpoint is hit, saying anyone can read the stats and how to set analyticsToken.
  • Update the "Reading Stats with Express" section of website/src/content/docs/core/analytics.mdx (line 18) with the option and a curl example.

Where to look

  • packages/server/src/adapters/express.ts, chatcopsAnalyticsHandler
  • packages/server/tests/adapters/express.test.ts, line 322, has the existing analytics test

Acceptance criteria

  • With analyticsToken set: the right token gets the stats, while a missing token, a wrong token and a token of a different length get 401
  • Without it: the stats are returned as today, and the warning is logged once across several requests
  • Docs updated
  • Changeset for @chatcops/server (minor, since it adds an option)
  • pnpm test:coverage and pnpm lint pass

Please get this merged by Oct 31.


Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #<this issue number>. Setup notes (pnpm, build before test) are in CONTRIBUTING.md.

Lenguaje dominante
TypeScript
Estrellas
13
Forks
7
Merge medio
3 h 41 min
PR fusionados (30 d)
155

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de codercops/chatcops

Todos los issues de codercops/chatcops

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.