SShortSingh.
Back to feed

Why the Repository Pattern in NestJS Deserves a Second Look

0
·1 views

NestJS applications backed by TypeORM commonly inject repositories directly into services, allowing developers to query and persist data with minimal setup. While this approach works reliably in production, it tightly couples business logic to persistence concerns such as ORM-specific query syntax, null-return behavior, and implicit save semantics. A key structural issue arises when the domain entity doubles as the database schema definition, blending business rules with persistence annotations in the same class. This design carries little visible cost on simple, single-table modules but creates measurable complexity as entities accumulate invariants, shared queries, and rules that must be testable without a database. The article argues that deliberately separating the business model from the persistence model becomes worthwhile once those three conditions emerge in a real-world domain.

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 ·

Developer Shares Playwright Solution for Visual Testing with API Mocking

A developer has published their solution to Challenge 3, focused on visual testing combined with API mocking using Playwright. The approach addresses real-world problems such as missing chart renders and overlapping UI buttons caused by frequent API changes in dashboard applications. The solution involves mocking API endpoints to return fixed data, then capturing and comparing screenshot snapshots to detect unintended UI changes. A custom VisualHelper class was built with methods to check full-page or element-level snapshots, with configurable timeout and pixel-difference thresholds. Playwright's built-in toHaveScreenshot() function serves as the free alternative to paid visual testing tools like Percy, Applitools Eyes, and Sauce Visual.

0
ProgrammingDEV Community ·

Developer recreates kulhad chai in pure CSS for frontend art challenge

A developer built a detailed CSS illustration of a kulhad of masala chai for DEV Community's Frontend Challenge: Comfort Food Edition. The artwork depicts a hand-thrown terracotta cup surrounded by whole spices and a half-eaten biscuit, rendered entirely using divs, gradients, clip-paths, and shadows — no SVG, images, or canvas. The kulhad's irregular silhouette was achieved with an 18-point polygon clip-path, while five stacked gradient layers simulate the texture of matte clay. Steam wisps required three iterations to look realistic, ultimately using individual horizontal origins and mix-blend-mode: screen to mimic rising vapour. A CSS mask-image technique was used to punch a clean bite-shaped hole through the biscuit, preserving its crumb texture and shadow details.

0
ProgrammingDEV Community ·

DEV Community Post Shares CSS Code for Arabic-Themed Restaurant Landing Page

A developer published a front-end project on DEV Community showcasing a landing page concept called 'Comfort Table,' styled around an Arabic home-cooking theme. The post consists almost entirely of raw CSS and HTML code rather than written editorial content. The design uses a warm, earthy color palette with serif typography to evoke a cozy, home-style dining atmosphere. The project appears to be a personal or portfolio exercise demonstrating responsive web design techniques. No additional context, author background, or publication date was provided in the source material.

0
ProgrammingDEV Community ·

Developer Compares Rule-Based and ML Anomaly Detection in Custom Log Analysis Tool

A software developer added an Isolation Forest machine learning model to Log Sentinel, a self-built Apache log analysis dashboard originally designed to detect brute force attacks and directory scans using rule-based logic. The experiment used a labelled dataset of 230 IP addresses — 200 normal and 30 simulated attackers — to fairly evaluate both detection approaches. Rule-based detectors achieved perfect precision and recall because the evaluation data was deliberately structured around known attack patterns the rules were written to catch. The ML model matched on recall by catching all 30 attackers but produced five false positives, flagging normal IPs with statistically unusual behaviour. The developer concluded both methods are complementary: rules reliably catch known threats with no false alarms, while ML can surface unexpected anomalies that no predefined rule would cover.