SShortSingh.
Back to feed

Developer shares JavaScript lessons from building a simple counter app with Cloudflare

0
·1 views

A developer built a small counter app using vanilla JavaScript, Tailwind CSS, and Cloudflare Workers to practice state encapsulation, DOM event handling, and static app deployment. The project evolved from a constructor function to a class-based approach using JavaScript's private field syntax (#count) to protect state from direct external access. Instead of attaching separate click listeners to each button, the developer used event delegation — a single listener on the parent element — to simplify and future-proof the code. Deployment to Cloudflare Workers initially failed repeatedly because the Wrangler config pointed to the project root, causing node_modules files exceeding 25 MiB to be treated as deployable assets. The fix was straightforward: redirecting the assets directory to the actual build output folder resolved the error and completed the deployment.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

X-Forwarded-For misconfiguration can silently break your app's rate limiter

When an application runs behind a reverse proxy or tunnel, incoming TCP connections appear to originate from the relay server rather than the real client. This causes rate limiters to throttle the proxy instead of individual users, meaning one bad actor can block all traffic or bad actors can bypass limits entirely. Proxies typically pass the original client IP via the X-Forwarded-For header, but blindly trusting this header allows clients to spoof any IP address. The correct fix is to configure a trusted proxy list in your framework so that forwarded headers are only accepted from relay servers you control. As tunnels become standard for webhook testing and local development, choosing tools that correctly set and document forwarded headers is increasingly important for application security.

0
ProgrammingDEV Community ·

How to Build Cost Forecasting Into AI Agent Workflows Before They Run

Developers building AI agent products often discover costs only after a workflow completes, leaving no chance to warn users or prevent overspending. Unlike simple API calls, agent workflows branch across multiple steps — including retrieval, tool calls, retries, and validation — each adding tokens and cost unpredictably. A proposed forecasting framework treats every agent run like a job with a cost contract, cycling through quote, reserve, run, and reconcile phases. Before execution, the system estimates a cost range covering likely, low, and high scenarios, then reserves budget and enforces limits during the run. This approach allows products to route, cap, queue, or seek approval for expensive workflows before spend damages pricing, margins, or user trust.

0
ProgrammingDEV Community ·

Developer Builds Contextual Permission Engine to Govern AI Agent Tool Calls

A developer released Agent ToolTrust, an open-source permission engine designed to intercept and evaluate AI agent tool calls before they execute. The tool runs each call through a five-stage pipeline — normalize, score, decide, explain, and audit — returning one of four decisions: allow, audit, escalate, or deny. The project was motivated by repeated failures where unit tests and mock agents masked real integration problems in production environments. The developer validated the release by testing 83 real agents across 10 frameworks, achieving 2,490 passing tests before publishing to PyPI. The tool addresses a widely reported gap: roughly 80% of organizations report AI agents have taken actions beyond their intended scope, while only about 18% of MCP server deployments implement any access scoping.

0
ProgrammingDEV Community ·

Developer Builds Open-Source Tool ArtifactSweep to Reclaim Disk Space from Build Folders

A developer created ArtifactSweep, a free open-source utility designed to help programmers identify and delete auto-generated folders like node_modules, dist, and framework caches that accumulate across project directories. The tool was born out of frustration with manually hunting down these folders every few months to recover disk space. ArtifactSweep offers both a command-line interface called 'sweep' and a desktop GUI, supporting Windows, Linux, and macOS. In one test, the tool recovered nearly 5 GB from a single project directory. Released under the MIT license, the tool is available for download and welcomes community feedback via GitHub.