Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/DsThakurRawat/Backend-from-first-Principle
/ functions
Functions
414 in github.com/DsThakurRawat/Backend-from-first-Principle
⨍
Functions
414
◇
Types & classes
104
↳
Endpoints
38
↓ 1 callers
Function
run_client
()
24.Web-Sockets-And-Real-time-Communication-with-WebSockets/code/python/a_websocket_client_2.py:4
↓ 1 callers
Function
searchHandler
(pool *pgxpool.Pool)
11.Full text search using Elasticsearch for blazingly fast search/code/go/go_full_text_search_handler_1.go:19
↓ 1 callers
Function
search_reviews
(query: str, sentiment_filter: str = None)
11.Full text search using Elasticsearch for blazingly fast search/code/python/streaming_results_from_two_sources_nodej_2.py:1
↓ 1 callers
Method
serialize
(self, obj)
3.Serialization-and-Deserialization-or-backend-engineers/code/python/serialization_in_python_1.py:10
↓ 1 callers
Function
setup_tracing
(app)
15.Logging, Monitoring and Observability/tracing.py:9
↓ 1 callers
Method
startup
(self)
16.Graceful Shutdown/code/python/72_graceful_shutdown_in_python_1.py:15
↓ 1 callers
Function
step
()
20.Concurrency & Parallelism: IO Bound vs CPU Bound/code/python/two_things_this_explains_4.py:7
↓ 1 callers
Method
to_dict
(self)
3.Serialization-and-Deserialization-or-backend-engineers/code/python/serialization_in_python_1.py:43
↓ 1 callers
Method
trim
(cls, v: str)
5. Validations and transformations for backend engineers/code/python/example_8.py:13
↓ 1 callers
Method
unregister
(self, ws: WebSocket)
24.Web-Sockets-And-Real-time-Communication-with-WebSockets/code/python/connection_management_3.py:11
↓ 1 callers
Function
verify
(token: str)
4.Authentication and authorization for backend engineers/code/python/05_json_web_tokens_jwt_3.py:18
↓ 1 callers
Function
withEmail
(e string)
22.Automated-Testing-Unit-Integration-and-E2E/code/go/fixtures_factories_8.go:9
↓ 1 callers
Function
writeError
(w http.ResponseWriter, status int, code, msg string, details ...FieldError)
7.API-DESIGN-RestAPI/code/go/a_consistent_error_envelope_5.go:6
Function
ApprovePaymentHandler
To send approval signal from your API handler:
10.Task queues and background job/workflows/payment_approval.go:30
Function
ArchiveOrganization
(w http.ResponseWriter, r *http.Request)
7.API-DESIGN-RestAPI/code/go/worked_example_a_pm_platform_4.go:35
Function
AuthMiddleware
(next http.Handler)
6.controllers-services-repositories-middlewares-and-request-context/code/go/12common_middlewares_6.go:13
Function
Authenticate
(w http.ResponseWriter, email, pw string)
4.Authentication and authorization for backend engineers/code/go/17_error_messages_timing_attacks_12.go:4
Function
BadRequest
(msg string, details any)
12. Error Handling and Building Fault Tolerant Systems/errors/types.go:22
Function
BenchmarkParseEvent
Benchmarks live beside tests; the tool tunes b.N until timing is stable.
22.Automated-Testing-Unit-Integration-and-E2E/code/go/performance_load_testing_10.go:2
Function
CORSMiddleware
(next http.Handler)
6.controllers-services-repositories-middlewares-and-request-context/code/go/12common_middlewares_6.go:3
Function
CanEdit
Policy: can `s` perform `action` on `r`, given the environment?
4.Authentication and authorization for backend engineers/code/go/16_authorization_rbac_11.go:5
Function
CheckCSRF
Double-submit: compare the CSRF cookie against the header.
4.Authentication and authorization for backend engineers/code/go/06_cookies_5.go:2
Function
CheckPassword
bcrypt.CompareHashAndPassword is constant-time internally
4.Authentication and authorization for backend engineers/code/go/04_sessions_1.go:30
Function
Conflict
(msg string)
12. Error Handling and Building Fault Tolerant Systems/errors/types.go:19
Function
CreateBookHandler
(w http.ResponseWriter, r *http.Request)
6.controllers-services-repositories-middlewares-and-request-context/code/go/14use_case_passing_authentication_data_7.go:1
Function
CreateBookHandler
(w http.ResponseWriter, r *http.Request)
6.controllers-services-repositories-middlewares-and-request-context/code/go/a_note_on_nodejs_vs_go_python_1.go:7
Function
CreateOrganization
(w http.ResponseWriter, r *http.Request)
7.API-DESIGN-RestAPI/code/go/worked_example_a_pm_platform_4.go:15
Function
CreatePayment
(w http.ResponseWriter, r *http.Request)
7.API-DESIGN-RestAPI/code/go/post_the_only_non_idempotent_one_2.go:1
Function
CreateTodo
(ctx context.Context, req models.CreateTodoRequest, userID string)
15.Logging, Monitoring and Observability/services/todo_service.go:17
Method
DatabaseURL
DatabaseURL constructs the connection URL from the parts.
14.Production-grade Configuration Management/code/go/93_example_yaml_config_file_1.go:38
Function
DeleteOrganization
(w http.ResponseWriter, r *http.Request)
7.API-DESIGN-RestAPI/code/go/worked_example_a_pm_platform_4.go:30
Method
Deserialize
(data []byte, v any)
3.Serialization-and-Deserialization-or-backend-engineers/code/go/serialization_in_go_1.go:22
Function
EmailWorker
Consumer: runs as a separate process (or goroutine)
19.Backend Scaling and Performance Engineering: Part-2/code/go/example_3.go:20
Function
EnhancedTracing
()
15.Logging, Monitoring and Observability/middleware/tracing.go:13
Function
EnqueueEmail
Producer: push job to queue (called from your API handler)
19.Backend Scaling and Performance Engineering: Part-2/code/go/example_3.go:14
Function
EnqueueEmailTask
── PRODUCER ──────────────────────────────────────────
10.Task queues and background job/code/go/how_sqs_visibility_timeout_works_aws_spe_1.go:12
Method
FindBookByID
A SEPARATE method for the single-book case. No optional toggles.
6.controllers-services-repositories-middlewares-and-request-context/code/go/07the_repository_layer_4.go:19
Method
FindByID
(string)
22.Automated-Testing-Unit-Integration-and-E2E/code/go/test_doubles_3.go:14
Function
GET
(req)
11.Full text search using Elasticsearch for blazingly fast search/code/javascript/streaming_results_from_two_sources_nodej_1.js:4
Function
GetPostsWithAuthors
(ctx context.Context, db *sql.DB)
18. Backend Scaling and Performance Engineering-part-1/code/go/example_4.go:1
Function
GetProduct
GetProduct implements Cache-Aside (Lazy) caching. 1. Check Redis first 2. On miss, fetch from DB, store in cache, return
9.Caching, the secret behind it all/code/go/104_session_management_with_redis_python_1.go:25
Function
GetProduct
(ctx context.Context, id string)
18. Backend Scaling and Performance Engineering-part-1/code/go/example_6.go:10
Method
GetRequestMetadata
(ctx context.Context, _ ...string)
13.gRPC-and-Inter-Service-Communication-for-Microservices/code/go/authentication_security_9.go:14
Function
GetSession
GetSession retrieves session data — works regardless of which server the request lands on, because Redis is shared across all instances.
19.Backend Scaling and Performance Engineering: Part-2/code/go/example_1.go:16
Function
GlobalErrorHandler
GlobalErrorHandler wraps a handler that returns an error.
12. Error Handling and Building Fault Tolerant Systems/middleware/error_handler.go:20
Method
Handle
(req Request)
2.Routing-in-backend/Router.go:18
Method
Handle
Handle is the method that satisfies the Handler INTERFACE Because GetUser has Handle(req Request) Response, Go says "GetUser IS-A Handler" — it can be
2.Routing-in-backend/Router.go:207
Method
Handle
(req Request)
2.Routing-in-backend/Router.go:222
Method
Handle
(req Request)
2.Routing-in-backend/code/go/a_router_in_go_1.go:73
Method
Handle
(req Request)
2.Routing-in-backend/code/go/a_router_in_go_1.go:79
Method
HandleDeleteAccount
Go — Idempotent multi-step task with full transaction rollback
10.Task queues and background job/code/go/pattern_4_exactly_once_via_sqs_fifo_dedu_2.go:2
Method
HandleSendEmail
Usage in Asynq handler
10.Task queues and background job/rate/sliding_window.go:38
Method
HandleSendVerificationEmail
HandleSendVerificationEmail — registered with the Asynq server
10.Task queues and background job/handlers/email_handler.go:18
Function
HashArgon
returns an encoded string: salt + params + hash
4.Authentication and authorization for backend engineers/code/go/04_sessions_2.go:28
Function
HashPassword
(password string)
17.Backend Security: Everything You Need to Know/code/go/slow_hashing_defeating_brute_force_3.go:7
Function
HashPassword
hash once at signup; store hash, never the password
4.Authentication and authorization for backend engineers/code/go/04_sessions_1.go:24
Function
Init
()
15.Logging, Monitoring and Observability/logger/logger_1.go:12
Function
Internal
(err error)
12. Error Handling and Building Fault Tolerant Systems/errors/types.go:25
Function
ListBooksHandler
(w http.ResponseWriter, r *http.Request)
6.controllers-services-repositories-middlewares-and-request-context/code/go/a_note_on_nodejs_vs_go_python_2.go:1
Function
ListOrganizations
GET /v1/organizations?status=active&sortBy=name&sortOrder=ascending&page=1&limit=10
7.API-DESIGN-RestAPI/code/go/filtering_3.go:2
Function
Load
Load reads env vars, applies defaults, then VALIDATES before returning. Called once at startup — fail loudly here, never silently in production.
14.Production-grade Configuration Management/code/go/93_example_yaml_config_file_1.go:47
Function
LoggingMiddleware
In Go, middleware wraps the "next" handler. Calling next.ServeHTTP is the equivalent of next(): pass execution along the chain.
6.controllers-services-repositories-middlewares-and-request-context/code/go/10the_next_function_5.go:3
Function
Login
(w http.ResponseWriter, u User)
4.Authentication and authorization for backend engineers/code/go/04_sessions_1.go:40
Function
MustLoad
MustLoad panics if any required variable is missing. Call this once in main() before http.ListenAndServe.
12. Error Handling and Building Fault Tolerant Systems/code/go/go_config_validation_at_boot_1.go:18
Function
New
()
15.Logging, Monitoring and Observability/logger/logger.go:22
Function
NewSendVerificationEmailTask
NewSendVerificationEmailTask creates the Asynq task
10.Task queues and background job/tasks/email.go:21
Function
NotFound
Constructors
12. Error Handling and Building Fault Tolerant Systems/errors/types.go:16
Method
NotifyOwner
A service that needs no database at all is perfectly valid:
6.controllers-services-repositories-middlewares-and-request-context/code/go/06the_service_layer_3.go:14
Function
PaymentApprovalWorkflow
workflows/payment_approval.go — Wait for human signal
10.Task queues and background job/workflows/payment_approval.go:2
Function
PollQueue
── CONSUMER ──────────────────────────────────────────
10.Task queues and background job/code/go/how_sqs_visibility_timeout_works_aws_spe_1.go:25
Function
PrometheusMetrics
()
15.Logging, Monitoring and Observability/middleware/metrics.go:25
Function
RateLimitMiddleware
(rdb *redis.Client)
9.Caching, the secret behind it all/code/go/104_session_management_with_redis_python_2.go:17
Function
RateLimitMiddleware
(next http.Handler)
17.Backend Security: Everything You Need to Know/code/go/three_layers_of_rate_limiting_5.go:24
Function
Refresh
Rotate a refresh token; detect reuse of an already-spent one.
4.Authentication and authorization for backend engineers/code/go/05_json_web_tokens_jwt_4.go:16
Function
RegenerateSession
Regenerate the session ID right after a successful login.
4.Authentication and authorization for backend engineers/code/go/06_cookies_5.go:19
Function
RegisterOrgRoutes
(mux *http.ServeMux)
7.API-DESIGN-RestAPI/code/go/worked_example_a_pm_platform_4.go:1
Function
RequestIDMiddleware
(next http.Handler)
6.controllers-services-repositories-middlewares-and-request-context/code/go/cancellation_abort_signals_deadlines_8.go:1
Function
RequireAPIKey
(lookup func(hash string) (*Client, bool))
4.Authentication and authorization for backend engineers/code/go/10_api_key_authentication_8.go:14
Function
RequireJWT
(next http.HandlerFunc)
4.Authentication and authorization for backend engineers/code/go/08_stateless_authentication_7.go:3
Function
RequireRole
RequireRole runs AFTER an auth middleware that set "user".
4.Authentication and authorization for backend engineers/code/go/16_authorization_rbac_10.go:2
Function
RequireSession
RequireSession reads the sid cookie and looks it up in Redis.
4.Authentication and authorization for backend engineers/code/go/07_stateful_authentication_6.go:2
Method
RequireTransportSecurity
()
13.gRPC-and-Inter-Service-Communication-for-Microservices/code/go/authentication_security_9.go:17
Method
Save
(o Order)
22.Automated-Testing-Unit-Integration-and-E2E/code/go/dependency_injection_for_testability_4.go:15
Method
Send
(to, msg string)
22.Automated-Testing-Unit-Integration-and-E2E/code/go/test_doubles_3.go:17
Method
Serialize
(v any)
3.Serialization-and-Deserialization-or-backend-engineers/code/go/serialization_in_go_1.go:19
Function
Sign
mint a self-contained token carrying the claims
4.Authentication and authorization for backend engineers/code/go/05_json_web_tokens_jwt_3.go:11
Function
StoreSession
StoreSession saves session data in Redis so ANY server can read it.
19.Backend Scaling and Performance Engineering: Part-2/code/go/example_1.go:10
Function
TestApplyDiscount
(t *testing.T)
22.Automated-Testing-Unit-Integration-and-E2E/code/go/table_driven_parametrized_tests_5.go:1
Function
TestCreateUser_Returns201
(t *testing.T)
22.Automated-Testing-Unit-Integration-and-E2E/code/go/testing_http_handlers_apis_7.go:8
Function
TestDiscount_AppliesPercentage
File naming convention: foo.go is tested by foo_test.go in the same package. Test functions are func TestXxx(t *testing.T) — the `go test` tool finds
22.Automated-Testing-Unit-Integration-and-E2E/code/go/anatomy_of_a_test_1.go:3
Function
TestFetchRate
2) Stub an external HTTP API with httptest.Server — no real network.
22.Automated-Testing-Unit-Integration-and-E2E/code/go/mocking_time_randomness_external_apis_9.go:15
Function
TestGreet_SendsEmail
(t *testing.T)
22.Automated-Testing-Unit-Integration-and-E2E/code/go/test_doubles_3.go:19
Function
TestIsStrongPassword
(t *testing.T)
22.Automated-Testing-Unit-Integration-and-E2E/code/go/unit_tests_2.go:12
Function
TestPlace_RejectsInvalidTotal
(t *testing.T)
22.Automated-Testing-Unit-Integration-and-E2E/code/go/dependency_injection_for_testability_4.go:17
Function
TestSignup
(t *testing.T)
22.Automated-Testing-Unit-Integration-and-E2E/code/go/fixtures_factories_8.go:20
Function
TestTokenExpiry
(t *testing.T)
22.Automated-Testing-Unit-Integration-and-E2E/code/go/mocking_time_randomness_external_apis_9.go:6
Function
TestUserRepo_SaveAndFind
Build tag keeps slow integration tests out of the fast unit run: go:build integration → run with: go test -tags=integration ./...
22.Automated-Testing-Unit-Integration-and-E2E/code/go/testing_with_a_real_database_6.go:3
Function
TimingMiddleware
TimingMiddleware logs the duration of every HTTP request.
18. Backend Scaling and Performance Engineering-part-1/code/go/example_2.go:10
Function
UpdateOrganization
(w http.ResponseWriter, r *http.Request)
7.API-DESIGN-RestAPI/code/go/post_the_only_non_idempotent_one_1.go:1
Function
UpdateProduct
Write-Through: update DB and cache simultaneously
9.Caching, the secret behind it all/code/go/104_session_management_with_redis_python_1.go:52
← previous
next →
101–200 of 414, ranked by callers