java
@RestController
@RequestMapping("/api/customers")
public class CsvImportController {

    private final CsvImportService importService;

Streaming CSV Import in Spring Boot with MultipartFile and JDBC Batch Inserts

spring-boot csv jdbc
by codesnips 4 tabs
typescript
import { Injectable } from '@nestjs/common';
import { HealthIndicator, HealthIndicatorResult, HealthCheckError } from '@nestjs/terminus';
import { PrismaService } from '../prisma/prisma.service';

@Injectable()
export class PrismaHealthIndicator extends HealthIndicator {

NestJS Health Checks With Terminus and a Custom Prisma Indicator

nestjs terminus health-checks
by codesnips 3 tabs
php
<?php

namespace App\Console\Commands;

use App\Jobs\CompileReportJob;
use Carbon\CarbonImmutable;

Schedule a Recurring Report Job in Laravel's Console Kernel

laravel scheduler cron
by codesnips 3 tabs
go
package apiclient

import (
	"context"
	"fmt"
	"io"

Sharing a golang.org/x/time/rate Limiter Across Goroutines for Outbound API Calls

go rate-limiting concurrency
by codesnips 3 tabs
ruby
class ParamSchema
  def initialize(fields)
    @fields = fields
  end

  def coerce(params)

Typed Query Param Coercion in a Sinatra before Filter with Schema Defaults

sinatra rack params
by codesnips 2 tabs
python
import asyncio
from typing import Awaitable, Callable, Dict, TypeVar

T = TypeVar("T")

Coalesce Duplicate In-Flight Requests with an Asyncio Single-Flight Cache

asyncio concurrency caching
by codesnips 3 tabs
typescript
import { RequestHandler } from 'express';
import { ZodTypeAny, ZodError } from 'zod';

export class ValidationError extends Error {
  status = 422;
  constructor(public issues: unknown) {

Composable Express Request Validation with Zod Schema Middleware

express validation zod
by codesnips 3 tabs
rust
use pulldown_cmark::{html, Options, Parser};
use std::collections::HashSet;

pub struct SafeHtml(String);

impl SafeHtml {

Rendering Untrusted Markdown to Sanitized HTML with pulldown-cmark and ammonia

rust markdown html-sanitization
by codesnips 3 tabs
java
@Configuration
@EnableScheduling
@EnableConfigurationProperties(CleanupProperties.class)
public class SchedulingConfig {

    @Bean(destroyMethod = "shutdown")

Recurring Cleanup Job with Spring @Scheduled and a Shutdown-Aware Executor

spring spring-boot scheduling
by codesnips 3 tabs
typescript
import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
import { FeatureFlagGuard } from './feature-flag.guard';
import { RequireFeature } from './feature-flag.decorator';

@Controller('experiments')
@UseGuards(FeatureFlagGuard)

Per-Request Feature Flags in NestJS with a Custom Decorator and Resolution Guard

nestjs feature-flags guards
by codesnips 4 tabs
php
<?php

namespace App\ValueObjects;

final readonly class NotificationSettings
{

Cast a JSON Column to an Immutable Value Object with a Custom Eloquent Cast in Laravel

laravel eloquent value-object
by codesnips 3 tabs
ruby
module Result
  def self.Success(value)
    Success.new(value)
  end

  def self.Failure(error)

Railway-Oriented Result Monad for Chaining Lead Enrichment Steps in Ruby

result-monad railway-oriented functional
by codesnips 3 tabs