Code Explainers
Code explainers tagged #controllers
typescript
import { Controller, Get, Param,
HTTP conditional caching in a NestJS controller
http-caching
etag
conditional-requests
Intermediate
7 steps
ruby
class Admin::AccountsController < Admin::BaseController before_action :set_account, only: :destroy def destroy
A guarded destroy action in Rails
controllers
callbacks
transactions
Intermediate
8 steps
ruby
class SearchController < ApplicationController def index @query = params[:q].to_s.strip end
Live search suggestions in a Rails controller
controllers
sql-injection
query-building
Intermediate
6 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
ruby
class HealthController < ApplicationController skip_before_action :authenticate_user!, raise: false skip_forgery_protection
Building a health check endpoint in Rails
health-check
monitoring
error-handling
Intermediate
7 steps
ruby
module Api module V1 class BaseController < ActionController::API rescue_from StandardError, with: :render_internal_error
Centralized API error handling in Rails
error-handling
rescue-from
json-api
Intermediate
7 steps
php
<?php namespace App\Http\Controllers;
Handling avatar uploads in Laravel
file-upload
image-processing
validation
Intermediate
8 steps