Code Explainers
Code explainers tagged #configuration
typescript
import { Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import * as Joi from 'joi';
Validating env config at boot in NestJS
configuration
schema-validation
environment-variables
Intermediate
8 steps
java
package com.example.api.config; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean;
Configuring CORS in Spring MVC
cors
configuration
dependency-injection
Intermediate
6 steps
go
package config import ( "os"
Layered config resolution in Go
configuration
closures
higher-order-functions
Intermediate
8 steps
java
@Configuration public class ValidationConfig implements WebMvcConfigurer { @Bean
Localized bean validation messages in Spring
internationalization
bean-validation
configuration
Intermediate
6 steps
rust
use serde_json::{Map, Value}; pub fn merge_config(base: &mut Value, override_with: Value) { match (base, override_with) {
Deep-merging JSON config layers in Rust
recursion
json
pattern-matching
Intermediate
9 steps
javascript
const legacyRedirects = [ { from: '/blog/:slug', to: '/articles/:slug' }, { from: '/shop/product/:id', to: '/store/items/:id' }, { from: '/about-us', to: '/about' },
How redirects work in Next.js config
redirects
routing
configuration
Intermediate
7 steps
python
import json import logging import threading from pathlib import Path
A hot-reloading config file watcher
file-watching
thread-safety
hot-reload
Intermediate
7 steps
typescript
import { InjectionToken, inject, Provider, isDevMode } from '@angular/core'; import { WINDOW } from './window.token'; export interface AnalyticsConfig {
Layered config with an Angular InjectionToken
dependency-injection
configuration
factory-provider
Intermediate
8 steps
java
public record AppConfig( String host, int port, String databaseUrl,
Loading typed config from env vars in Java
records
configuration
environment-variables
Intermediate
6 steps
php
<?php namespace App\FeatureFlags;
How a feature flag evaluator decides
feature-flags
rollout
hashing
Intermediate
8 steps
java
package com.example.uploads.config; import jakarta.servlet.MultipartConfigElement; import org.springframework.boot.web.servlet.MultipartConfigFactory;
Configuring upload size limits in Spring
file-upload
exception-handling
http-errors
Intermediate
6 steps
java
public interface GitHubClient { @GetExchange("/users/{username}") GitHubUser getUser(@PathVariable String username);
Declarative HTTP clients in Spring
http-client
declarative-api
proxy
Intermediate
8 steps
python
import os from pathlib import Path BASE_DIR = Path(__file__).resolve().parent.parent.parent
How a Django settings module is wired
configuration
environment-variables
middleware
Intermediate
8 steps
typescript
import { Module } from '@nestjs/common'; import { ConfigModule, ConfigService } from '@nestjs/config'; import { createClient, RedisClientType } from 'redis';
Provide a Redis client with a NestJS factory
dependency-injection
async-factory
redis
Intermediate
6 steps
python
from configparser import ConfigParser, ExtendedInterpolation from pathlib import Path
Layered INI config loading in Python
configuration
parsing
defaults
Intermediate
8 steps
ruby
module AppConfig module_function def fetch(key, default: nil, required: false)
Typed environment variable config in Ruby
environment-variables
type-coercion
configuration
Intermediate
7 steps
java
@Configuration @EnableRedisHttpSession(namespace = "myapp:sessions", maxInactiveIntervalInSeconds = 1800, flushMode = FlushMode.IMMEDIATE) public class SessionConfig {
Backing HTTP sessions with Redis in Spring
session-management
redis
distributed-state
Intermediate
7 steps
go
package config import ( "fmt"
Parsing timeout config in Go
configuration
validation
error-wrapping
Intermediate
7 steps