Code Explainers
Code explainers tagged #dependency-injection
typescript
import { Component, OnInit, inject } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { FormBuilder } from '@angular/forms'; import { debounceTime, map } from 'rxjs/operators';
Syncing an Angular filter form with the URL
reactive-forms
query-params
rxjs
Intermediate
8 steps
typescript
import { inject } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivateFn,
How a functional route guard works in Angular
route-guards
dependency-injection
rxjs
Intermediate
5 steps
java
package com.acme.billing.config; import org.flywaydb.core.Flyway; import org.flywaydb.core.api.MigrationVersion;
Customizing Flyway migrations in Spring
database-migrations
flyway
dependency-injection
Intermediate
6 steps
python
from datetime import date from enum import Enum from typing import Annotated
Reusable query params with Pydantic in FastAPI
query-parameters
validation
pagination
Intermediate
8 steps
ruby
require "digest" class UploadDeduplicator CHUNK_SIZE = 64 * 1024
Deduplicating uploads by content hash
hashing
deduplication
streaming-io
Intermediate
7 steps
typescript
import { Controller, Get, Param, StreamableFile, Res, NotFoundException, Header } from '@nestjs/common'; import { Response } from 'express'; import { createReadStream, promises as fsp } from 'fs'; import { join } from 'path';
Streaming CSV file downloads in NestJS
file-streaming
http-headers
error-handling
Intermediate
7 steps
java
@RestController @RequestMapping("/api/orders") public class OrderController {
Content-negotiated API versioning in Spring
api-versioning
content-negotiation
rest
Intermediate
7 steps
typescript
import { Controller, Get } from '@nestjs/common'; import { HealthCheck, HealthCheckService,
Liveness vs readiness probes in NestJS
health-checks
dependency-injection
observability
Intermediate
6 steps
java
@Target(ElementType.PARAMETER) @Retention(RetentionPolicy.RUNTIME) public @interface CurrentUser { }
Injecting the current user in Spring MVC
annotations
dependency-injection
security
Intermediate
8 steps
typescript
import { Controller, Post, Headers,
Verifying Stripe webhooks in NestJS
webhooks
signature-verification
event-handling
Intermediate
7 steps
python
import os from datetime import datetime, timezone import jwt
JWT bearer auth as a FastAPI dependency
authentication
jwt
dependency-injection
Intermediate
7 steps
go
package middleware import ( "crypto/subtle"
Building an API-key middleware in Gin
middleware
authentication
dependency-injection
Intermediate
5 steps
java
@Component @Order(20) public class ProductSearchIndexRunner implements ApplicationRunner {
Rebuilding a search index at Spring startup
startup-hook
batching
streaming
Intermediate
8 steps
typescript
import { Injectable, signal, computed } from '@angular/core'; import { HttpInterceptorFn, HttpContextToken,
Tracking HTTP loading state in Angular
signals
http-interceptor
reference-counting
Intermediate
8 steps
python
from datetime import datetime from fastapi import APIRouter, Depends, HTTPException, status from pydantic import BaseModel, ConfigDict, EmailStr from sqlalchemy.orm import Session
Building a users router in FastAPI
routing
serialization
dependency-injection
Intermediate
7 steps
java
@Service public class OrderCheckoutService { private final OrderRepository orderRepository;
How @Transactional guards a Spring checkout
dependency-injection
transactions
atomicity
Intermediate
6 steps
java
@Service public class OrderMetricsService { private final MeterRegistry registry;
Instrumenting orders with Micrometer in Spring
metrics
micrometer
observability
Intermediate
8 steps
typescript
import { Processor, WorkerHost, OnWorkerEvent } from '@nestjs/bullmq'; import { Logger } from '@nestjs/common'; import { Job } from 'bullmq'; import { MailerService } from '../mailer/mailer.service';
Processing background email jobs in NestJS
job-queue
background-processing
dependency-injection
Intermediate
7 steps