SShortSingh.
Back to feed

Criteria Pattern in NestJS Offers Cleaner Way to Filter, Sort, and Paginate Lists

0
·2 views

A software development article on DEV Community introduces the Criteria pattern as a structured approach to handling filtering, sorting, and pagination in NestJS applications. The pattern addresses a common problem where query parameters in API endpoints directly expose internal database field names, creating tight coupling between the client and the data layer. Using a library catalogue as a working example, the author demonstrates how a typical endpoint accumulates ad-hoc query logic over time, leaking implementation details into the public URL contract. The Criteria pattern instead represents list queries as explicit objects that are translated at each architectural boundary, keeping the API vocabulary separate from the database schema. This approach aims to make API contracts more intentional and maintainable as applications grow in complexity.

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 ·

How to Evaluate a Transactional Email API Before It Causes an Incident

Choosing a transactional email API requires more than comparing send prices — teams must verify that the service supports custom domain verification, DKIM key rotation with overlapping selectors, and exportable suppression lists with reasons and timestamps. A critical distinction is that API request acceptance and actual message delivery are separate states, and conflating them makes retry logic dangerous, leading to dropped or duplicate messages. Suppression records should differentiate between user unsubscribes, permanent delivery failures, and operator blocks rather than collapsing all three into a single boolean flag. DMARC reporting should be treated as an ongoing operational signal, with a named owner in the team's runbook who monitors aggregate reports and acts on anomalies. Engineers are advised to test each of these capabilities explicitly — including webhook replay, event retention, and rollback procedures — before committing to a provider.

0
ProgrammingDEV Community ·

Criteria Pattern in NestJS: Structuring Flexible, Decoupled API Query Contracts

A developer tutorial on DEV Community demonstrates the Criteria pattern in NestJS using a library book catalogue as a working example. The article shows how a typical query endpoint grows organically, accumulating filter, sort, and pagination parameters directly tied to database field names. This approach creates an implicit, undeclared contract between clients and the database schema, making future changes risky once URLs are shared or scripted externally. The Criteria pattern addresses this by introducing a structured query object that translates client intent into database operations across two explicit boundaries. The result is a more expressive and maintainable API where filters declare their operators and fields are abstracted from underlying collection names.

0
ProgrammingDEV Community ·

Rust Supply Chain Attack Poisons Popular Crates to Steal Developer Credentials

A critical supply chain attack targeted three widely used Rust crates — arrayref, internment, and append-only-vec — by compromising their publisher accounts on crates.io and releasing malicious versions. The tampered crates added hidden dependencies on typosquatted packages and a build.rs script that automatically executed during normal Cargo build or test operations, requiring no additional user action. The malware disabled TLS verification, downloaded a second-stage payload, and collected credentials from browsers and development environments before sending them to attacker-controlled servers. The malicious versions were publicly available for roughly two hours, meaning any developer or CI/CD pipeline that resolved dependencies during that window may be compromised. Security researchers recommend auditing Cargo.lock files for the affected versions, restricting build-time network egress, scoping CI secrets to individual jobs, and rebuilding any potentially affected machines.

0
ProgrammingDEV Community ·

Critical MLflow SSRF Flaw Lets Attackers Steal Cloud IAM Credentials Without Login

A critical unauthenticated server-side request forgery (SSRF) vulnerability, CVE-2026-64849, has been disclosed in MLflow Tracking Server versions 3.14.0 and earlier, with a security advisory published on August 19, 2026. The flaw allows external attackers to create webhooks via an unauthenticated API and redirect MLflow into fetching cloud metadata endpoints, such as AWS EC2 instance metadata, exposing temporary IAM credentials. MLflow fails to re-validate redirect destinations, meaning a 302 redirect from an attacker-controlled server to internal or link-local addresses bypasses protection checks entirely. CISA has added the vulnerability to its Known Exploited Vulnerabilities catalog, confirming active exploitation in the wild. Users are advised to upgrade to MLflow 3.15.0 or later and restrict public access to the tracking server using authenticated reverse proxies and least-privilege IAM roles.