Code Explainers
Code explainers tagged #dependency-injection
typescript
import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; import { BullModule } from '@nestjs/bullmq';
How a NestJS feature module wires up
dependency-injection
modularity
orm
Intermediate
7 steps
typescript
import { Controller, Get, Query,
Validating paginated queries in NestJS
pagination
validation
pipes
Intermediate
7 steps
python
import pytest from fastapi.testclient import TestClient from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker
Testing FastAPI routes with dependency overrides
testing
fixtures
dependency-injection
Intermediate
7 steps
typescript
import { Controller, Post, UploadedFile,
Handling avatar uploads in NestJS
file-upload
validation
interceptors
Intermediate
7 steps
java
@RestController @RequestMapping("/api/reports") public class OrderReportController {
Streaming a CSV export in Spring
streaming
csv-export
backpressure
Intermediate
9 steps
typescript
import { Injectable, UnauthorizedException } from '@nestjs/common'; import { PassportStrategy } from '@nestjs/passport'; import { ExtractJwt, Strategy } from 'passport-jwt'; import { ConfigService } from '@nestjs/config';
How a JWT strategy authenticates in NestJS
authentication
jwt
passport
Intermediate
7 steps
python
import os from datetime import timedelta
Class-based config in a Flask app factory
configuration
app-factory
inheritance
Intermediate
7 steps
typescript
import { Injectable, Logger, OnApplicationShutdown } from '@nestjs/common'; import { InjectRedis } from '@nestjs-modules/ioredis'; import Redis from 'ioredis'; import { DataSource } from 'typeorm';
Graceful shutdown hooks in NestJS
graceful-shutdown
lifecycle-hooks
dependency-injection
Intermediate
7 steps
typescript
import { Injectable, OnModuleInit, Logger } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { Cron, CronExpression } from '@nestjs/schedule';
A self-refreshing feature flags provider in NestJS
caching
scheduled-tasks
dependency-injection
Intermediate
8 steps
java
@Controller public class BookController { private final BookService bookService;
Solving GraphQL N+1 with batch mapping in Spring
graphql
n+1-problem
batching
Intermediate
8 steps
php
<?php namespace App\View\Composers;
How a Laravel view composer feeds the navigation
view-composer
caching
dependency-injection
Intermediate
5 steps
java
@Component required to import public class OutboxEventPublisher {
The transactional outbox pattern in Spring
transactional-outbox
event-driven
reliability
Advanced
7 steps
typescript
import { Injectable } from '@angular/core'; import { CanDeactivateFn } from '@angular/router'; import { inject } from '@angular/core'; import { MatDialog } from '@angular/material/dialog';
Guarding navigation with CanDeactivate in Angular
route-guards
functional-guards
dependency-injection
Intermediate
7 steps
java
package com.example.payments.config; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean;
Configuring a Stripe RestClient in Spring
dependency-injection
http-client
configuration
Intermediate
7 steps
typescript
import { Controller, Get, Param, Post, Body, Version, VERSION_NEUTRAL } from '@nestjs/common'; import { UsersService } from './users.service'; import { CreateUserDto } from './dto/create-user.dto';
How API versioning works in NestJS
api-versioning
routing
dependency-injection
Intermediate
9 steps
java
@RefreshScope @Component public class FeatureSettings {
Refreshable feature settings in Spring
caching
configuration
dependency-injection
Intermediate
7 steps
typescript
import { Injectable, NotFoundException } from '@nestjs/common'; import { EventEmitter2, OnEvent } from '@nestjs/event-emitter'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm';
Decoupling side effects with NestJS events
event-driven
decoupling
dependency-injection
Intermediate
7 steps
php
<?php namespace App\Jobs;
Building a unique queued job in Laravel
queues
background-jobs
idempotency
Intermediate
7 steps