
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
bulltrackers-module
Advanced tools
Policy-driven Express API for Bulltrackers: centralized auth/capability rules, Zod validation, domain read/write services, and OpenAPI derived from the same handler schemas.
Runs as part of bulltrackers-module (parent package.json provides express, firebase-admin, pino, zod, BigQuery/Firestore clients, etc.). Tests expect Node ≥ 20 and Jest 30+.
const http = require('http');
const { createApiV4App, attachGracefulShutdown } = require('./core-api');
const clients = {
firestore: /* admin.firestore() */,
bigquery: /* BigQuery client */,
storage: /* optional Storage */,
};
const app = createApiV4App(clients);
const server = http.createServer(app);
attachGracefulShutdown(server); // SIGTERM / SIGINT — use for long-lived processes (Cloud Run, k8s)
server.listen(process.env.PORT || 8080);
Exports from core-api.js:
| Export | Purpose |
|---|---|
createApiV4App(clients) | Express app with middleware, req.services, routes |
createApiV4Server(clients) | Same as createApiV4App today (alias) |
attachGracefulShutdown(server, options?) | Drain HTTP on shutdown |
X-Request-ID) + req.log (Pino child) → express.jsonreq.services injection (db, dataService, writeService, domains, billingService, authService)ROUTE_KEYS_BEFORE_BUILD_CONTEXT)buildContext — Firebase token / test auth, CID lookup, tier, dev/test shadowvalidate → handlerAll routes are declared in config/accessPolicies.js as ROUTE_POLICIES: HTTP method + path string → guard (public | authenticated | verified | pro), optional capability, featureFlag, extraGuards.
Registration order is not manual: registerFromPolicies.js sorts keys so static path segments beat :params and longer paths win (see utils/routeRegistrationSort.js).
Handlers live under routes/handlers/, merged by collectHandlers() (routes/handlers/index.js). Each export key must match a ROUTE_POLICIES entry exactly. Parity is enforced by:
npm test → testing/accessPolicyHandlerParity.test.jsnode scripts/verify-route-policy-parity.js (from this directory)Handlers may be a function or { schema: { body|query|params }, handler } using shared Zod pieces in schemas/.
req.app.locals.config — frozen config from config/index.jspathsFromRequest(req) — Firestore path resolution from injected config (config/firestorePaths.js); avoid static require('../config') in handlersreq.services.dataService / writeService — facades for backward compatibilityreq.services.domains.read — { billing, firestore, computation } (prefer for new features)req.services.domains.write — { watchlists, reviews, alerts, analytics, settings, devOverrides, masterList }req.services.billingService — Stripe portal + checkout session docsGET /openapi.json — built from policies + handler Zod via utils/generateOpenApi.js (Zod 4 toJSONSchema; transforms may omit some request bodies). Serves a public-only spec (excludes /dev/*, /settings/dev/*, /workspace/admin/*) to avoid leaking internal endpoints. Use scripts/export-openapi-spec.js for full spec (frontend codegen); add --public to export public-only.jsconfig.json + types/express-services.d.ts — IDE autocomplete for req.services and req.log without a TS buildPrimary module: config/index.js (Stripe URLs, BigQuery dataset, Firestore collection map, CORS origins, billing usersCollection override, etc.). Override via environment variables documented in that file.
Useful env vars for ops:
| Variable | Effect |
|---|---|
LOG_LEVEL | Pino level (info, debug, silent, …) |
ENABLE_TEST_AUTH | X-Test-Firebase-User header (CI / emulator only) |
UPSTASH_REDIS_* | Redis: tier cache, idempotency, verification tickets |
GOOGLE_APPLICATION_CREDENTIALS | GCP clients (outside Firebase Functions) |
Pino logs JSON lines suitable for Cloud Logging / Datadog. Child loggers include requestId and service: 'api-v4'. Sensitive headers are redacted in config.
For POST /sync/request and POST /billing/purchase, if Idempotency-Key is sent (≤ 128 chars) and Upstash Redis is configured, the first successful res.json body is cached 24h and replayed for the same user + path + key (SHA-256 scoped key).
Opaque base64url cursors (utils/firestoreTimelineCursor.js) tie-break orderBy(time, 'desc').orderBy(documentId, 'desc'). Legacy plain document IDs still work as cursors. Deploy composite indexes for those query shapes before production.
Use attachGracefulShutdown(server) so SIGTERM stops accepting new connections and finishes in-flight work before exit. Upstash is HTTP-based; no Redis socket to close.
From functions/api-v4:
npx jest --config jest.config.js testing
testing/setup.js wires theFirestore emulator and test env as needed. Integration tests use supertest against createApiV4App.
| Path | Role |
|---|---|
core-api.js | App factory, service graph, middleware order |
config/ | accessPolicies, firestorePaths, env-backed index |
middleware/ | buildContext, guard, validate, errorHandler, idempotency, … |
routes/handlers/ | Route implementations (keys = policy keys) |
routes/registerFromPolicies.js | Binds policies → Express |
schemas/ | Shared Zod fragments |
services/ | DataService, WriteService, BillingService, AuthService, data/*, write/* |
utils/ | OpenAPI gen, route sort, logger, cursors, graceful shutdown |
functions/ | Side-effect triggers (sync, computation, notifications) used by handlers |
websocket/ | Verification WS glue (thin) |
scripts/ | CI helpers (verify-route-policy-parity.js) |
testing/ | Jest tests + Firestore helpers |
scripts/verify-route-policy-parity.js in CI after changing policies or handlers.Core/config/collection_registry.js and downstream ETL alignment.Part of the Bulltrackers backend monorepo; internal use unless the repository root states otherwise.
FAQs
Helper Functions for Bulltrackers.
We found that bulltrackers-module demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.