vibes-plug 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/BLUEPRINT.md +125 -0
- package/CHANGELOG.md +195 -0
- package/CONTRIBUTING.md +199 -0
- package/LICENSE +21 -0
- package/README.md +263 -0
- package/SECURITY.md +21 -0
- package/banner.png +0 -0
- package/package.json +25 -0
- package/plugin.json +8 -0
- package/scripts/update_skills.js +75 -0
- package/skills/ai-llm-integration-expert/SKILL.md +162 -0
- package/skills/api-design-expert/SKILL.md +310 -0
- package/skills/app-analyzer-optimizer/SKILL.md +189 -0
- package/skills/asisten_ramah/SKILL.md +41 -0
- package/skills/authentication-identity-expert/SKILL.md +45 -0
- package/skills/auto-doc-updater/SKILL.md +204 -0
- package/skills/bootstrap-to-modern/SKILL.md +87 -0
- package/skills/brainstorming/SKILL.md +353 -0
- package/skills/bun-runtime-expert/SKILL.md +211 -0
- package/skills/ci-cd-devops-architect/SKILL.md +45 -0
- package/skills/cloud-hosting-expert/SKILL.md +244 -0
- package/skills/coderabbit/SKILL.md +192 -0
- package/skills/data-telemetry-expert/SKILL.md +213 -0
- package/skills/database-orm-expert/SKILL.md +294 -0
- package/skills/design-system-architect/SKILL.md +243 -0
- package/skills/e2e-testing-expert/SKILL.md +315 -0
- package/skills/event-driven-architect/SKILL.md +81 -0
- package/skills/firebase-security-expert/SKILL.md +195 -0
- package/skills/fullstack-expert/SKILL.md +202 -0
- package/skills/fullstack-expert/references/api_design_guide.md +466 -0
- package/skills/fullstack-expert/references/devops_infrastructure.md +477 -0
- package/skills/fullstack-expert/references/multi_language_backend.md +528 -0
- package/skills/fullstack-expert/references/system_design_patterns.md +358 -0
- package/skills/fullstack-expert/scripts/api_contract_validator.py +253 -0
- package/skills/fullstack-expert/scripts/architecture_analyzer.py +326 -0
- package/skills/gemini-agent-booster/SKILL.md +135 -0
- package/skills/global-a11y-i18n-expert/SKILL.md +81 -0
- package/skills/go-programming-expert/SKILL.md +295 -0
- package/skills/hig/SKILL.md +188 -0
- package/skills/js-backend-expert/SKILL.md +192 -0
- package/skills/mcp-server-architect/SKILL.md +194 -0
- package/skills/mobile-expo-expert/SKILL.md +186 -0
- package/skills/monday-design-aesthetic/SKILL.md +67 -0
- package/skills/monorepo-architect/SKILL.md +227 -0
- package/skills/mpa-orchestrator/SKILL.md +101 -0
- package/skills/multi-agent-orchestration/SKILL.md +234 -0
- package/skills/multiple-entry-points/SKILL.md +55 -0
- package/skills/mvc-expert/SKILL.md +231 -0
- package/skills/payment-gateway-expert/SKILL.md +45 -0
- package/skills/performance-web-vitals/SKILL.md +332 -0
- package/skills/prd-architect/SKILL.md +191 -0
- package/skills/production-ready-hardener/SKILL.md +469 -0
- package/skills/production-ready-hardener/references/performance_optimization.md +441 -0
- package/skills/production-ready-hardener/references/production_checklist.md +161 -0
- package/skills/production-ready-hardener/references/security_hardening_guide.md +379 -0
- package/skills/production-ready-hardener/scripts/production_readiness_scanner.py +875 -0
- package/skills/python-programming-expert/SKILL.md +271 -0
- package/skills/realtime-collaboration-expert/SKILL.md +45 -0
- package/skills/rust-programming-expert/SKILL.md +235 -0
- package/skills/saas-billing/SKILL.md +377 -0
- package/skills/saas-multi-tenant/SKILL.md +237 -0
- package/skills/saas-mvp-launcher/SKILL.md +231 -0
- package/skills/saas-transformer/SKILL.md +446 -0
- package/skills/saas-transformer/references/billing_integration_guide.md +401 -0
- package/skills/saas-transformer/references/feature_gating_patterns.md +137 -0
- package/skills/saas-transformer/references/saas_transformation_checklist.md +121 -0
- package/skills/saas-transformer/scripts/saas_transformation_scanner.py +254 -0
- package/skills/scalability-clean-code/SKILL.md +229 -0
- package/skills/secure-fuzz-testing/SKILL.md +201 -0
- package/skills/senior-frontend/SKILL.md +161 -0
- package/skills/senior-frontend/references/frontend_best_practices.md +806 -0
- package/skills/senior-frontend/references/nextjs_optimization_guide.md +724 -0
- package/skills/senior-frontend/references/react_patterns.md +746 -0
- package/skills/senior-frontend/scripts/bundle_analyzer.py +407 -0
- package/skills/senior-frontend/scripts/component_generator.py +329 -0
- package/skills/senior-frontend/scripts/frontend_scaffolder.py +1005 -0
- package/skills/senior-fullstack/SKILL.md +167 -0
- package/skills/senior-fullstack/references/architecture_patterns.md +160 -0
- package/skills/senior-fullstack/references/development_workflows.md +222 -0
- package/skills/senior-fullstack/references/tech_stack_guide.md +190 -0
- package/skills/senior-fullstack/scripts/code_quality_analyzer.py +114 -0
- package/skills/senior-fullstack/scripts/fullstack_scaffolder.py +114 -0
- package/skills/senior-fullstack/scripts/project_scaffolder.py +114 -0
- package/skills/seo/SKILL.md +225 -0
- package/skills/seo/references/cwv-thresholds.md +108 -0
- package/skills/seo/references/eeat-framework.md +214 -0
- package/skills/seo/references/quality-gates.md +155 -0
- package/skills/seo/references/schema-types.md +118 -0
- package/skills/seo-aeo-landing-page-writer/SKILL.md +97 -0
- package/skills/seo-geo/SKILL.md +188 -0
- package/skills/session-handoff-resume/SKILL.md +158 -0
- package/skills/skill_baru/SKILL.md +147 -0
- package/skills/spa-orchestrator/SKILL.md +288 -0
- package/skills/state-management-expert/SKILL.md +272 -0
- package/skills/supabase-migration/SKILL.md +45 -0
- package/skills/supabase-security-expert/SKILL.md +243 -0
- package/skills/tailwind-expert/SKILL.md +188 -0
- package/skills/tanstack-query-expert/SKILL.md +199 -0
- package/skills/tauri-expert/SKILL.md +97 -0
- package/skills/token-saver/SKILL.md +111 -0
- package/skills/typescript-expert/SKILL.md +279 -0
- package/skills/ui-components-expert/SKILL.md +63 -0
- package/skills/ui-ux-pro-max/SKILL.md +201 -0
- package/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/skills/ui-ux-pro-max/data/prompts.csv +24 -0
- package/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/skills/ui-ux-pro-max/data/styles.csv +59 -0
- package/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-310.pyc +0 -0
- package/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-312.pyc +0 -0
- package/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-310.pyc +0 -0
- package/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-312.pyc +0 -0
- package/skills/ui-ux-pro-max/scripts/core.py +257 -0
- package/skills/ui-ux-pro-max/scripts/design_system.py +493 -0
- package/skills/ui-ux-pro-max/scripts/search.py +81 -0
- package/skills/ui_ux_expert/SKILL.md +114 -0
- package/skills/vibe-code-gardener/SKILL.md +173 -0
- package/skills/web-scraper/SKILL.md +205 -0
- package/skills/web-scraper/references/data-transforms.md +397 -0
- package/skills/web-scraper/references/extraction-patterns.md +475 -0
- package/skills/web-scraper/references/output-templates.md +481 -0
- package/skills/zero-to-prod-orchestrator/SKILL.md +180 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: go-programming-expert
|
|
3
|
+
description: "Expert-level skill for Go programming (Go 1.23/1.24+). Covers high-performance microservices, concurrency patterns, sqlc, net/http, Gin/Echo/Fiber, gRPC, and testing in English and Indonesian."
|
|
4
|
+
author: "Roedy Rustam"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Go Programming Expert (Go 1.24 Edition)
|
|
8
|
+
|
|
9
|
+
[English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<a name="english"></a>
|
|
14
|
+
## English
|
|
15
|
+
|
|
16
|
+
### Description
|
|
17
|
+
Expert-level Go development for building high-performance microservices, APIs, and CLI tools. Covers **Go 1.24** features (range-over-func iterators, generic type aliases, weak pointers), structured logging with `slog`, `net/http` with the new ServeMux patterns, Gin/Echo/Fiber frameworks, sqlc for type-safe SQL, gRPC, and production testing patterns.
|
|
18
|
+
|
|
19
|
+
### Trigger Conditions
|
|
20
|
+
- Writing Go 1.23+ / 1.24+ microservices or APIs.
|
|
21
|
+
- Implementing concurrency patterns with goroutines, channels, and `sync` primitives.
|
|
22
|
+
- Using structured logging with `log/slog`.
|
|
23
|
+
- Building HTTP servers with `net/http` ServeMux (Go 1.22+) or Gin/Echo/Fiber.
|
|
24
|
+
- Writing type-safe SQL with **sqlc** or using **GORM**.
|
|
25
|
+
- Implementing gRPC services with protobuf.
|
|
26
|
+
- Writing Go tests with the standard `testing` package + `testify`.
|
|
27
|
+
|
|
28
|
+
### Go 1.24 — Key Features
|
|
29
|
+
|
|
30
|
+
#### Range-Over-Func (Go 1.22 → Stable in 1.24)
|
|
31
|
+
Range over custom iterators — enables functional-style collection operations:
|
|
32
|
+
```go
|
|
33
|
+
// Define an iterator function
|
|
34
|
+
func Fibonacci() iter.Seq[int] {
|
|
35
|
+
return func(yield func(int) bool) {
|
|
36
|
+
a, b := 0, 1
|
|
37
|
+
for {
|
|
38
|
+
if !yield(a) {
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
a, b = b, a+b
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Range over it naturally
|
|
47
|
+
for n := range Fibonacci() {
|
|
48
|
+
if n > 100 {
|
|
49
|
+
break
|
|
50
|
+
}
|
|
51
|
+
fmt.Println(n)
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### Generic Type Aliases (Go 1.24)
|
|
56
|
+
```go
|
|
57
|
+
// Type alias with generic parameters
|
|
58
|
+
type Set[T comparable] = map[T]struct{}
|
|
59
|
+
type Result[T any] = struct{ Value T; Err error }
|
|
60
|
+
|
|
61
|
+
// Usage
|
|
62
|
+
var s Set[string] = make(map[string]struct{})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Weak Pointers (Go 1.24)
|
|
66
|
+
```go
|
|
67
|
+
import "weak"
|
|
68
|
+
|
|
69
|
+
// Weak pointer — does not prevent GC collection
|
|
70
|
+
ptr := weak.Make(&myStruct{})
|
|
71
|
+
if val := ptr.Value(); val != nil {
|
|
72
|
+
// Still alive
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Structured Logging with `log/slog`
|
|
77
|
+
```go
|
|
78
|
+
package main
|
|
79
|
+
|
|
80
|
+
import (
|
|
81
|
+
"log/slog"
|
|
82
|
+
"os"
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
func main() {
|
|
86
|
+
// Production JSON logger
|
|
87
|
+
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
|
|
88
|
+
Level: slog.LevelInfo,
|
|
89
|
+
AddSource: true, // include file:line
|
|
90
|
+
}))
|
|
91
|
+
slog.SetDefault(logger)
|
|
92
|
+
|
|
93
|
+
slog.Info("server started", "port", 8080, "env", "production")
|
|
94
|
+
slog.Error("database connection failed", "error", err, "host", dbHost)
|
|
95
|
+
|
|
96
|
+
// Grouped context
|
|
97
|
+
reqLogger := logger.WithGroup("request").With(
|
|
98
|
+
"trace_id", traceID,
|
|
99
|
+
"user_id", userID,
|
|
100
|
+
)
|
|
101
|
+
reqLogger.Info("handler called", "method", r.Method, "path", r.URL.Path)
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### HTTP Server — net/http ServeMux (Go 1.22+)
|
|
106
|
+
Go 1.22 upgraded the standard ServeMux with method-based routing and path parameters — reducing the need for external routers:
|
|
107
|
+
```go
|
|
108
|
+
package main
|
|
109
|
+
|
|
110
|
+
import (
|
|
111
|
+
"encoding/json"
|
|
112
|
+
"net/http"
|
|
113
|
+
"log/slog"
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
func main() {
|
|
117
|
+
mux := http.NewServeMux()
|
|
118
|
+
|
|
119
|
+
// Method + path pattern matching (Go 1.22+)
|
|
120
|
+
mux.HandleFunc("GET /api/users", listUsers)
|
|
121
|
+
mux.HandleFunc("POST /api/users", createUser)
|
|
122
|
+
mux.HandleFunc("GET /api/users/{id}", getUser) // path params
|
|
123
|
+
mux.HandleFunc("DELETE /api/users/{id}", deleteUser)
|
|
124
|
+
|
|
125
|
+
slog.Info("starting server", "addr", ":8080")
|
|
126
|
+
http.ListenAndServe(":8080", mux)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
func getUser(w http.ResponseWriter, r *http.Request) {
|
|
130
|
+
id := r.PathValue("id") // Extract path parameter
|
|
131
|
+
// ...
|
|
132
|
+
w.Header().Set("Content-Type", "application/json")
|
|
133
|
+
json.NewEncoder(w).Encode(user)
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Type-Safe SQL with sqlc
|
|
138
|
+
```bash
|
|
139
|
+
# Install sqlc
|
|
140
|
+
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
|
|
141
|
+
|
|
142
|
+
# sqlc.yaml
|
|
143
|
+
version: "2"
|
|
144
|
+
sql:
|
|
145
|
+
- engine: "postgresql"
|
|
146
|
+
queries: "queries/"
|
|
147
|
+
schema: "schema/"
|
|
148
|
+
gen:
|
|
149
|
+
go:
|
|
150
|
+
package: "db"
|
|
151
|
+
out: "internal/db"
|
|
152
|
+
emit_json_tags: true
|
|
153
|
+
emit_interface: true
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
```sql
|
|
157
|
+
-- queries/users.sql
|
|
158
|
+
-- name: GetUser :one
|
|
159
|
+
SELECT * FROM users WHERE id = $1 LIMIT 1;
|
|
160
|
+
|
|
161
|
+
-- name: ListUsers :many
|
|
162
|
+
SELECT * FROM users ORDER BY created_at DESC LIMIT $1 OFFSET $2;
|
|
163
|
+
|
|
164
|
+
-- name: CreateUser :one
|
|
165
|
+
INSERT INTO users (name, email) VALUES ($1, $2) RETURNING *;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
```go
|
|
169
|
+
// Generated type-safe Go code (used in handlers)
|
|
170
|
+
user, err := queries.GetUser(ctx, userID) // Fully typed!
|
|
171
|
+
users, err := queries.ListUsers(ctx, db.ListUsersParams{Limit: 20, Offset: 0})
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Concurrency Patterns
|
|
175
|
+
|
|
176
|
+
#### errgroup for Parallel Work
|
|
177
|
+
```go
|
|
178
|
+
import "golang.org/x/sync/errgroup"
|
|
179
|
+
|
|
180
|
+
g, ctx := errgroup.WithContext(context.Background())
|
|
181
|
+
|
|
182
|
+
g.Go(func() error { return fetchA(ctx) })
|
|
183
|
+
g.Go(func() error { return fetchB(ctx) })
|
|
184
|
+
|
|
185
|
+
if err := g.Wait(); err != nil {
|
|
186
|
+
// First error from any goroutine
|
|
187
|
+
return fmt.Errorf("parallel fetch: %w", err)
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### Worker Pool Pattern
|
|
192
|
+
```go
|
|
193
|
+
func workerPool(jobs <-chan Job, results chan<- Result, numWorkers int) {
|
|
194
|
+
var wg sync.WaitGroup
|
|
195
|
+
for range numWorkers {
|
|
196
|
+
wg.Add(1)
|
|
197
|
+
go func() {
|
|
198
|
+
defer wg.Done()
|
|
199
|
+
for job := range jobs {
|
|
200
|
+
results <- process(job)
|
|
201
|
+
}
|
|
202
|
+
}()
|
|
203
|
+
}
|
|
204
|
+
wg.Wait()
|
|
205
|
+
close(results)
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Testing Best Practices
|
|
210
|
+
```go
|
|
211
|
+
package user_test
|
|
212
|
+
|
|
213
|
+
import (
|
|
214
|
+
"testing"
|
|
215
|
+
"github.com/stretchr/testify/assert"
|
|
216
|
+
"github.com/stretchr/testify/require"
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
func TestGetUser(t *testing.T) {
|
|
220
|
+
t.Parallel() // Always parallelize independent tests
|
|
221
|
+
|
|
222
|
+
// Table-driven tests
|
|
223
|
+
tests := []struct{
|
|
224
|
+
name string
|
|
225
|
+
userID string
|
|
226
|
+
want *User
|
|
227
|
+
wantErr bool
|
|
228
|
+
}{
|
|
229
|
+
{"valid user", "user-123", &User{ID: "user-123"}, false},
|
|
230
|
+
{"not found", "missing", nil, true},
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
for _, tt := range tests {
|
|
234
|
+
t.Run(tt.name, func(t *testing.T) {
|
|
235
|
+
t.Parallel()
|
|
236
|
+
got, err := GetUser(context.Background(), tt.userID)
|
|
237
|
+
if tt.wantErr {
|
|
238
|
+
require.Error(t, err)
|
|
239
|
+
return
|
|
240
|
+
}
|
|
241
|
+
require.NoError(t, err)
|
|
242
|
+
assert.Equal(t, tt.want.ID, got.ID)
|
|
243
|
+
})
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
<a name="bahasa-indonesia"></a>
|
|
251
|
+
## Bahasa Indonesia
|
|
252
|
+
|
|
253
|
+
### Deskripsi
|
|
254
|
+
Panduan Go tingkat ahli untuk membangun microservices, API, dan CLI tool berkinerja tinggi. Mencakup fitur **Go 1.24** (range-over-func, generic type alias, weak pointer), structured logging dengan `slog`, ServeMux `net/http` dengan pola baru (Go 1.22+), framework Gin/Echo/Fiber, sqlc untuk SQL type-safe, gRPC, dan pola pengujian produksi.
|
|
255
|
+
|
|
256
|
+
### Kondisi Pemicu
|
|
257
|
+
- Menulis microservices atau API Go 1.23+/1.24+.
|
|
258
|
+
- Mengimplementasikan pola konkurensi dengan goroutine, channel, dan primitif `sync`.
|
|
259
|
+
- Menggunakan structured logging dengan `log/slog`.
|
|
260
|
+
- Membangun HTTP server dengan ServeMux `net/http` (Go 1.22+) atau Gin/Echo/Fiber.
|
|
261
|
+
- Menulis SQL type-safe dengan **sqlc** atau GORM.
|
|
262
|
+
- Mengimplementasikan layanan gRPC dengan protobuf.
|
|
263
|
+
|
|
264
|
+
### Go 1.24 — Fitur Utama
|
|
265
|
+
|
|
266
|
+
#### Range-Over-Func (Stabil di 1.24)
|
|
267
|
+
Go 1.24 menstabilkan range over iterator function — memungkinkan koleksi gaya fungsional yang idiomatis tanpa mengekspos slice internal.
|
|
268
|
+
|
|
269
|
+
#### Generic Type Alias
|
|
270
|
+
Go 1.24 memungkinkan alias tipe dengan parameter generic, meningkatkan komposibilitas tipe.
|
|
271
|
+
|
|
272
|
+
#### Weak Pointer
|
|
273
|
+
`weak.Make()` membuat pointer lemah yang tidak mencegah GC mengumpulkan objek — berguna untuk cache.
|
|
274
|
+
|
|
275
|
+
### Structured Logging dengan `log/slog`
|
|
276
|
+
Paket `log/slog` bawaan Go (sejak 1.21) mendukung output JSON terstruktur, level log, dan pengelompokan atribut. Gunakan sebagai standar logging di semua proyek Go baru.
|
|
277
|
+
|
|
278
|
+
### HTTP Server — net/http ServeMux (Go 1.22+)
|
|
279
|
+
ServeMux Go 1.22 mendukung pencocokan berdasarkan metode HTTP dan parameter path — mengurangi kebutuhan router eksternal untuk API sederhana.
|
|
280
|
+
|
|
281
|
+
### SQL Type-Safe dengan sqlc
|
|
282
|
+
`sqlc` menghasilkan kode Go yang fully typed dari query SQL dan skema database — menghilangkan kebutuhan ORM untuk sebagian besar kasus.
|
|
283
|
+
|
|
284
|
+
### Pola Konkurensi
|
|
285
|
+
|
|
286
|
+
#### errgroup
|
|
287
|
+
Gunakan `errgroup.WithContext()` dari `golang.org/x/sync/errgroup` untuk menjalankan goroutine paralel dan mengumpulkan error pertama secara aman.
|
|
288
|
+
|
|
289
|
+
#### Worker Pool
|
|
290
|
+
Gunakan pola worker pool dengan channel untuk memproses pekerjaan secara paralel dengan jumlah goroutine yang terkendali.
|
|
291
|
+
|
|
292
|
+
### Best Practices Pengujian
|
|
293
|
+
- Gunakan `t.Parallel()` untuk semua test independen.
|
|
294
|
+
- Gunakan table-driven tests untuk menguji banyak skenario dengan kode minimal.
|
|
295
|
+
- Gunakan `testify/assert` dan `testify/require` untuk assertion yang ekspresif.
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hig
|
|
3
|
+
description: "Applies Human Interface Guidelines (HIG) principles — Hierarchy, Harmony, and Consistency — to UI/UX designs to ensure intuitive and cohesive interfaces / Menerapkan prinsip Human Interface Guidelines (HIG) — Hierarchy, Harmony, dan Consistency — pada desain UI/UX untuk memastikan antarmuka yang intuitif dan kohesif."
|
|
4
|
+
author: "Roedy Rustam"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Human Interface Guidelines (HIG) Expert (2026 Edition)
|
|
8
|
+
|
|
9
|
+
[English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<a name="english"></a>
|
|
14
|
+
## English
|
|
15
|
+
|
|
16
|
+
### Description
|
|
17
|
+
Applies Human Interface Guidelines (HIG) principles to web and mobile UI/UX designs. Covers the core triad (Hierarchy, Harmony, Consistency), Apple's HIG 2025 updates, Google Material Design 3, spatial design for Apple Vision Pro, and modern accessibility requirements.
|
|
18
|
+
|
|
19
|
+
### Trigger Conditions
|
|
20
|
+
- Reviewing or critiquing a UI design for HIG violations.
|
|
21
|
+
- Making design decisions about typography scale, color usage, or layout hierarchy.
|
|
22
|
+
- Designing for multiple platforms (iOS, Android, web) with consistent patterns.
|
|
23
|
+
- Evaluating whether a UI feels "premium" or "amateur".
|
|
24
|
+
- Ensuring UI components follow platform conventions (button placement, nav patterns).
|
|
25
|
+
|
|
26
|
+
### The Core HIG Triad
|
|
27
|
+
|
|
28
|
+
#### 1. Hierarchy — Guide the User's Eye
|
|
29
|
+
Visual hierarchy controls where the user looks first and how they navigate information.
|
|
30
|
+
|
|
31
|
+
**Typography Hierarchy:**
|
|
32
|
+
```css
|
|
33
|
+
/* Clear hierarchy with size and weight — 4 levels max */
|
|
34
|
+
.h1 { font-size: 2.25rem; font-weight: 700; letter-spacing: -0.02em; }
|
|
35
|
+
.h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; }
|
|
36
|
+
.h3 { font-size: 1.25rem; font-weight: 600; }
|
|
37
|
+
.body { font-size: 1rem; font-weight: 400; }
|
|
38
|
+
.caption { font-size: 0.875rem; font-weight: 400; color: var(--color-text-muted); }
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Spatial Hierarchy (Z-axis):**
|
|
42
|
+
- Surface level: cards, panels — `shadow-sm`
|
|
43
|
+
- Raised level: dropdowns, tooltips — `shadow-md`
|
|
44
|
+
- Overlay level: modals, drawers — `shadow-xl`
|
|
45
|
+
- Floating level: toasts, command palette — `shadow-2xl`
|
|
46
|
+
|
|
47
|
+
**Color Hierarchy:**
|
|
48
|
+
- Primary action: brand color (1 per screen)
|
|
49
|
+
- Secondary action: muted/ghost variant
|
|
50
|
+
- Destructive action: red — far from primary CTA
|
|
51
|
+
|
|
52
|
+
#### 2. Harmony — Visual Cohesion
|
|
53
|
+
All elements should feel like they belong to the same family.
|
|
54
|
+
|
|
55
|
+
**Spacing Scale (8pt Grid):**
|
|
56
|
+
```
|
|
57
|
+
4px → xs gaps (icon padding, tight list items)
|
|
58
|
+
8px → sm (between related elements)
|
|
59
|
+
16px → md (card padding, section spacing)
|
|
60
|
+
24px → lg (between sections)
|
|
61
|
+
32px → xl (between major blocks)
|
|
62
|
+
48px → 2xl (page-level separation)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Border Radius Consistency:**
|
|
66
|
+
- Small elements (badges, chips): `rounded-full` or `rounded-sm`
|
|
67
|
+
- Medium elements (inputs, buttons): `rounded-md`
|
|
68
|
+
- Large elements (cards, modals): `rounded-xl`
|
|
69
|
+
- Never mix `rounded-none` with `rounded-2xl` in the same screen
|
|
70
|
+
|
|
71
|
+
**Color Harmony:**
|
|
72
|
+
```
|
|
73
|
+
Analogous: Brand + ±30° hue neighbors (natural, calm)
|
|
74
|
+
Complementary: Brand + 180° (high contrast, CTAs)
|
|
75
|
+
Triadic: Brand + 120°/240° (vibrant, use sparingly)
|
|
76
|
+
Monochromatic: Single hue, varying lightness (professional)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### 3. Consistency — Reduce Cognitive Load
|
|
80
|
+
Users should never wonder "how does this work?" — patterns should be predictable.
|
|
81
|
+
|
|
82
|
+
**Platform Conventions (Web):**
|
|
83
|
+
- Primary CTA: top-right (desktop nav) or bottom-center (mobile)
|
|
84
|
+
- Destructive actions: always require confirmation dialogs
|
|
85
|
+
- Form submission: Enter key submits, Escape cancels/closes
|
|
86
|
+
- Navigation: Breadcrumbs for 3+ depth levels
|
|
87
|
+
- Empty states: Always provide an actionable CTA
|
|
88
|
+
|
|
89
|
+
**Component Consistency Checklist:**
|
|
90
|
+
- [ ] All buttons use the same radius (`rounded-md` everywhere).
|
|
91
|
+
- [ ] All modals have the same padding (`p-6`) and close behavior (Escape key).
|
|
92
|
+
- [ ] All form inputs have the same height (`h-9`) and focus ring style.
|
|
93
|
+
- [ ] All error messages appear in the same position (below the input field).
|
|
94
|
+
- [ ] All tables use the same row height and hover style.
|
|
95
|
+
|
|
96
|
+
### Apple HIG 2025 Updates
|
|
97
|
+
|
|
98
|
+
#### Spatial Design (Vision Pro)
|
|
99
|
+
- Use **depth** as an organizational tool — foreground elements are more important.
|
|
100
|
+
- Avoid placing interactive elements outside comfortable viewing angles (±45° center).
|
|
101
|
+
- Use **glass morphism** (`backdrop-blur`) for panels to maintain spatial context.
|
|
102
|
+
- Prefer indirect input (gaze + pinch) over precise pointer interactions.
|
|
103
|
+
|
|
104
|
+
#### iOS 18 Design Patterns
|
|
105
|
+
- **Liquid Glass**: Full glass-morphism on navigation bars and toolbars.
|
|
106
|
+
- **Adaptive layouts**: Single codebase adapts from iPhone to iPad to Mac.
|
|
107
|
+
- **Symbols**: SF Symbols 6 with variable rendering (multicolor, hierarchical).
|
|
108
|
+
- **Menu patterns**: Context menus replace modal bottom sheets where possible.
|
|
109
|
+
|
|
110
|
+
### Material Design 3 (Google)
|
|
111
|
+
|
|
112
|
+
#### Dynamic Color (M3)
|
|
113
|
+
Generate a full color system from a single seed color:
|
|
114
|
+
```typescript
|
|
115
|
+
import { argbFromHex, themeFromSourceColor } from '@material/material-color-utilities';
|
|
116
|
+
|
|
117
|
+
const theme = themeFromSourceColor(argbFromHex('#6750A4'));
|
|
118
|
+
// Generates: primary, secondary, tertiary, error + all tonal palettes
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### Key M3 Components
|
|
122
|
+
- **Cards**: 3 variants — Elevated (shadow), Filled (surface variant), Outlined (border)
|
|
123
|
+
- **Chips**: Filter, Input, Suggestion, Assist — each with distinct purpose
|
|
124
|
+
- **Navigation**: Bottom bar (≤5 items), Rail (tablet), Drawer (desktop)
|
|
125
|
+
|
|
126
|
+
### HIG Audit Protocol
|
|
127
|
+
When reviewing a design, check:
|
|
128
|
+
1. **Hierarchy**: Is the primary action immediately obvious? Is text contrast sufficient?
|
|
129
|
+
2. **Harmony**: Is spacing consistent (8pt grid)? Are border radii uniform?
|
|
130
|
+
3. **Consistency**: Do interactive elements follow platform conventions?
|
|
131
|
+
4. **Accessibility**: Does it pass WCAG 2.2? Are touch targets ≥ 24×24px?
|
|
132
|
+
5. **Platform fit**: Does it feel native to its target platform?
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
<a name="bahasa-indonesia"></a>
|
|
137
|
+
## Bahasa Indonesia
|
|
138
|
+
|
|
139
|
+
### Deskripsi
|
|
140
|
+
Menerapkan prinsip Human Interface Guidelines (HIG) pada desain UI/UX web dan mobile. Mencakup triad inti (Hierarchy, Harmony, Consistency), pembaruan Apple HIG 2025, Google Material Design 3, desain spasial untuk Apple Vision Pro, dan persyaratan aksesibilitas modern.
|
|
141
|
+
|
|
142
|
+
### Kondisi Pemicu
|
|
143
|
+
- Meninjau atau mengkritik desain UI untuk pelanggaran HIG.
|
|
144
|
+
- Membuat keputusan desain tentang skala tipografi, penggunaan warna, atau hierarki tata letak.
|
|
145
|
+
- Merancang untuk berbagai platform (iOS, Android, web) dengan pola yang konsisten.
|
|
146
|
+
- Mengevaluasi apakah UI terasa "premium" atau "amatir".
|
|
147
|
+
- Memastikan komponen UI mengikuti konvensi platform.
|
|
148
|
+
|
|
149
|
+
### Triad HIG Inti
|
|
150
|
+
|
|
151
|
+
#### 1. Hierarki — Pandu Mata Pengguna
|
|
152
|
+
Hierarki visual mengontrol di mana pengguna melihat pertama dan bagaimana mereka menavigasi informasi.
|
|
153
|
+
- **Hierarki tipografi**: 4 level maksimal — H1 (2.25rem, 700), H2 (1.5rem, 600), H3 (1.25rem, 600), body (1rem, 400).
|
|
154
|
+
- **Hierarki spasial (sumbu-Z)**: Surface (shadow-sm), Raised (shadow-md), Overlay (shadow-xl), Floating (shadow-2xl).
|
|
155
|
+
- **Hierarki warna**: Satu warna brand per layar, aksi sekunder dengan varian muted/ghost, aksi destruktif dengan merah — jauh dari CTA utama.
|
|
156
|
+
|
|
157
|
+
#### 2. Harmoni — Kohesi Visual
|
|
158
|
+
Semua elemen harus terasa seperti milik keluarga yang sama.
|
|
159
|
+
- **Skala spacing (grid 8pt)**: 4px, 8px, 16px, 24px, 32px, 48px.
|
|
160
|
+
- **Konsistensi border radius**: Elemen kecil (rounded-full), sedang (rounded-md), besar (rounded-xl). Jangan campurkan rounded-none dengan rounded-2xl di layar yang sama.
|
|
161
|
+
- **Harmoni warna**: Analogis, komplementer, triadik, atau monokromatik — pilih satu skema dan patuhi.
|
|
162
|
+
|
|
163
|
+
#### 3. Konsistensi — Kurangi Beban Kognitif
|
|
164
|
+
Pengguna tidak pernah bertanya-tanya "bagaimana cara ini bekerja?" — pola harus dapat diprediksi.
|
|
165
|
+
- Konvensi platform: CTA utama di kanan atas (nav desktop) atau bawah tengah (mobile).
|
|
166
|
+
- Aksi destruktif selalu memerlukan dialog konfirmasi.
|
|
167
|
+
- Semua komponen sejenis menggunakan radius, padding, dan perilaku yang sama.
|
|
168
|
+
|
|
169
|
+
### Pembaruan Apple HIG 2025
|
|
170
|
+
|
|
171
|
+
#### Desain Spasial (Vision Pro)
|
|
172
|
+
Gunakan kedalaman sebagai alat organisasi. Gunakan glass-morphism (`backdrop-blur`) untuk panel. Hindari elemen interaktif di luar sudut pandang yang nyaman.
|
|
173
|
+
|
|
174
|
+
#### Pola iOS 18
|
|
175
|
+
Liquid Glass untuk navigation bar. Tata letak adaptif dari iPhone ke iPad ke Mac. SF Symbols 6 dengan rendering variabel.
|
|
176
|
+
|
|
177
|
+
### Material Design 3 (Google)
|
|
178
|
+
|
|
179
|
+
#### Warna Dinamis (M3)
|
|
180
|
+
Hasilkan sistem warna penuh dari satu warna seed menggunakan `@material/material-color-utilities`.
|
|
181
|
+
|
|
182
|
+
#### Komponen M3 Utama
|
|
183
|
+
- **Kartu**: Elevated (bayangan), Filled (varian permukaan), Outlined (batas).
|
|
184
|
+
- **Chip**: Filter, Input, Saran, Bantuan — masing-masing dengan tujuan berbeda.
|
|
185
|
+
- **Navigasi**: Bottom bar (≤5 item), Rail (tablet), Drawer (desktop).
|
|
186
|
+
|
|
187
|
+
### Protokol Audit HIG
|
|
188
|
+
Saat meninjau desain, periksa: Hierarki (apakah aksi utama langsung terlihat jelas?), Harmoni (apakah spacing konsisten?), Konsistensi (apakah elemen interaktif mengikuti konvensi platform?), Aksesibilitas (lulus WCAG 2.2? Target sentuh ≥ 24×24px?), dan Kesesuaian Platform (apakah terasa native untuk platform target?).
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: js-backend-expert
|
|
3
|
+
description: "Expert-level skill for Node.js 22+, Bun 1.2+, and Deno 2.x backend development. Covers Express 5, Fastify 5, Hono, NestJS, Prisma 6, Drizzle ORM, WebSockets, and microservices in English and Indonesian."
|
|
4
|
+
author: "Roedy Rustam"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# JS Backend Expert (Node.js 24 / Bun 1.2 / Deno 2.x Edition)
|
|
8
|
+
|
|
9
|
+
[English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
<a name="english"></a>
|
|
14
|
+
## English
|
|
15
|
+
|
|
16
|
+
### Description
|
|
17
|
+
Production-grade guidance for building fast, scalable, and resilient JavaScript/TypeScript backend APIs, microservices, and serverless functions across **Node.js 24 (LTS)**, **Bun 1.2+**, and **Deno 2.x**. Covers high-throughput frameworks (Fastify 5, Hono, Express 5, NestJS), type-safe ORMs (Drizzle, Prisma 6), **Hono RPC** for type-safe full-stack communication, Edge Runtime patterns, WebSockets, BullMQ background jobs, and graceful shutdown handling.
|
|
18
|
+
|
|
19
|
+
### Trigger Conditions
|
|
20
|
+
- Bootstrapping or refactoring a Node.js, Bun, or Deno backend application or microservice.
|
|
21
|
+
- Writing RESTful, GraphQL, WebSocket, or SSE (Server-Sent Events) API endpoints.
|
|
22
|
+
- Developing web servers using **Fastify 5**, **Hono**, **Express 5**, or **NestJS**.
|
|
23
|
+
- Building type-safe full-stack apps with **Hono RPC** or **tRPC**.
|
|
24
|
+
- Deploying backend logic to Edge Runtimes (Cloudflare Workers, Vercel Edge).
|
|
25
|
+
- Interacting with databases using **Drizzle ORM**, **Prisma 6**, or **Kysely**.
|
|
26
|
+
- Setting up background job processing with **BullMQ** and **Redis**.
|
|
27
|
+
- Implementing rate limiting, CORS, Content Security Policy (CSP), and JWT/Session authentication.
|
|
28
|
+
- Writing backend tests using **Vitest**, **Supertest**, or Node's native `node:test` runner.
|
|
29
|
+
|
|
30
|
+
### Runtime Matrix (Node.js 24 vs Bun 1.2 vs Deno 2.x)
|
|
31
|
+
|
|
32
|
+
| Feature / Runtime | Node.js 24 (LTS) | Bun 1.2+ | Deno 2.x |
|
|
33
|
+
|---|---|---|---|
|
|
34
|
+
| Module Standard | Native ESM / CJS | Native ESM / CJS | Native ESM |
|
|
35
|
+
| `.env` Loading | Native `--env-file` | Native | Native |
|
|
36
|
+
| TypeScript Execution | Native `--experimental-strip-types` / `tsx` | Native (Zero-config) | Native (Zero-config) |
|
|
37
|
+
| HTTP Server | `node:http` / `Fastify` | `Bun.serve()` / `Hono` | `Deno.serve()` / `Hono` |
|
|
38
|
+
| Native WebSockets | Built-in (`WebSocket`) | Built-in (`Bun.serve`) | Built-in (`Deno.upgradeWebSocket`) |
|
|
39
|
+
| Package Manager | npm / pnpm | bun (built-in) | npm / jsr |
|
|
40
|
+
| Test Runner | `node:test` / Vitest | `bun test` | `deno test` |
|
|
41
|
+
| Edge Deploy | Vercel Serverless | Railway / Fly.io | Deno Deploy |
|
|
42
|
+
|
|
43
|
+
### Framework Guidance
|
|
44
|
+
|
|
45
|
+
#### 1. Fastify 5 (High-Throughput & Schema Validation)
|
|
46
|
+
Use Fastify for performance-critical REST APIs. Always validate input using **TypeBox** or **Zod**:
|
|
47
|
+
```typescript
|
|
48
|
+
import Fastify from 'fastify';
|
|
49
|
+
import { z } from 'zod';
|
|
50
|
+
|
|
51
|
+
const app = Fastify({ logger: true });
|
|
52
|
+
|
|
53
|
+
app.post('/api/users', async (request, reply) => {
|
|
54
|
+
const bodySchema = z.object({
|
|
55
|
+
email: z.string().email(),
|
|
56
|
+
name: z.string().min(2),
|
|
57
|
+
});
|
|
58
|
+
const data = bodySchema.parse(request.body);
|
|
59
|
+
return reply.status(201).send({ status: 'created', user: data });
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
#### 2. Hono (Multi-Runtime & Hono RPC)
|
|
64
|
+
Use Hono for cross-runtime backends. The killer feature in 2026 is **Hono RPC** — end-to-end type-safe API calls without code generation:
|
|
65
|
+
```typescript
|
|
66
|
+
// server.ts
|
|
67
|
+
import { Hono } from 'hono';
|
|
68
|
+
import { zValidator } from '@hono/zod-validator';
|
|
69
|
+
import { z } from 'zod';
|
|
70
|
+
|
|
71
|
+
const app = new Hono()
|
|
72
|
+
.get('/health', (c) => c.json({ status: 'ok' }))
|
|
73
|
+
.post(
|
|
74
|
+
'/users',
|
|
75
|
+
zValidator('json', z.object({ name: z.string(), email: z.string().email() })),
|
|
76
|
+
async (c) => {
|
|
77
|
+
const body = c.req.valid('json');
|
|
78
|
+
const user = await db.user.create({ data: body });
|
|
79
|
+
return c.json(user, 201);
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
export type AppType = typeof app;
|
|
84
|
+
export default app;
|
|
85
|
+
|
|
86
|
+
// client.ts — fully type-safe, no codegen needed
|
|
87
|
+
import { hc } from 'hono/client';
|
|
88
|
+
import type { AppType } from './server';
|
|
89
|
+
|
|
90
|
+
const client = hc<AppType>('http://localhost:3000');
|
|
91
|
+
const res = await client.users.$post({ json: { name: 'Alice', email: 'alice@example.com' } });
|
|
92
|
+
const user = await res.json(); // Fully typed!
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### 3. Express 5
|
|
96
|
+
Express 5 natively catches rejected promises in async route handlers — eliminating the need for `express-async-errors`. It's ideal for teams already familiar with Express.
|
|
97
|
+
|
|
98
|
+
#### 4. Edge Runtime (Cloudflare Workers / Vercel Edge)
|
|
99
|
+
For ultra-low latency at the edge, use **Hono** (runs natively on all edge platforms):
|
|
100
|
+
```typescript
|
|
101
|
+
// Cloudflare Worker
|
|
102
|
+
export default {
|
|
103
|
+
async fetch(request: Request, env: Env): Promise<Response> {
|
|
104
|
+
return app.fetch(request, env);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
```
|
|
108
|
+
Edge Runtime restrictions: No Node.js built-ins (`fs`, `path`), limited memory, no long-running processes. Use `fetch`, Web Crypto API, and Cloudflare KV/D1/R2.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
### Type-Safe Data Layer (Drizzle ORM & Prisma 6)
|
|
113
|
+
- **Drizzle ORM**: Prefer for zero-overhead, SQL-like TypeScript query building in serverless/edge applications.
|
|
114
|
+
- **Prisma 6**: Prefer for complex relational schema modeling, auto-generated TypeScript client, and rich `prisma studio` tooling.
|
|
115
|
+
- **Connection Pooling**: Always use connection poolers (PgBouncer, Supavisor, Neon Hyperdrive) when deploying serverless handlers.
|
|
116
|
+
|
|
117
|
+
### Background Jobs (BullMQ + Redis)
|
|
118
|
+
```typescript
|
|
119
|
+
import { Queue, Worker } from 'bullmq';
|
|
120
|
+
import { Redis } from 'ioredis';
|
|
121
|
+
|
|
122
|
+
const connection = new Redis({ maxRetriesPerRequest: null });
|
|
123
|
+
const emailQueue = new Queue('email', { connection });
|
|
124
|
+
|
|
125
|
+
// Enqueue
|
|
126
|
+
await emailQueue.add('welcome-email', { userId: '123' }, { delay: 1000 });
|
|
127
|
+
|
|
128
|
+
// Worker
|
|
129
|
+
const worker = new Worker('email', async (job) => {
|
|
130
|
+
await sendWelcomeEmail(job.data.userId);
|
|
131
|
+
}, { connection, concurrency: 5 });
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Graceful Shutdown & Resilience
|
|
135
|
+
Never terminate the process abruptly. Clean up database pools, HTTP listeners, and Redis queues:
|
|
136
|
+
```typescript
|
|
137
|
+
const shutdown = async (signal: string) => {
|
|
138
|
+
console.log(`Received ${signal}. Shutting down gracefully...`);
|
|
139
|
+
await server.close();
|
|
140
|
+
await dbPool.end();
|
|
141
|
+
await worker.close();
|
|
142
|
+
process.exit(0);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
146
|
+
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
<a name="bahasa-indonesia"></a>
|
|
152
|
+
## Bahasa Indonesia
|
|
153
|
+
|
|
154
|
+
### Deskripsi
|
|
155
|
+
Panduan tingkat produksi untuk membangun API backend JavaScript/TypeScript yang cepat, skalabel, dan tangguh di lingkungan **Node.js 24 (LTS)**, **Bun 1.2+**, dan **Deno 2.x**. Mencakup framework berkinerja tinggi (Fastify 5, Hono, Express 5, NestJS), ORM type-safe (Drizzle, Prisma 6), **Hono RPC** untuk komunikasi full-stack type-safe, pola Edge Runtime, WebSocket, background jobs (BullMQ), dan penanganan *graceful shutdown*.
|
|
156
|
+
|
|
157
|
+
### Kondisi Pemicu
|
|
158
|
+
- Merancang atau merefaktor aplikasi backend Node.js, Bun, atau Deno.
|
|
159
|
+
- Menulis endpoint RESTful, GraphQL, WebSocket, atau SSE.
|
|
160
|
+
- Membangun web server dengan Fastify 5, Hono, Express 5, atau NestJS.
|
|
161
|
+
- Membangun aplikasi full-stack type-safe dengan **Hono RPC** atau tRPC.
|
|
162
|
+
- Men-deploy logika backend ke Edge Runtime (Cloudflare Workers, Vercel Edge).
|
|
163
|
+
- Berinteraksi dengan database menggunakan Drizzle ORM, Prisma 6, atau Kysely.
|
|
164
|
+
- Mengatur background job dengan BullMQ dan Redis.
|
|
165
|
+
|
|
166
|
+
### Matriks Runtime
|
|
167
|
+
Node.js 24 sebagai LTS terbaru, Bun 1.2+ untuk performa maksimal dan zero-config TypeScript, Deno 2.x untuk keamanan bawaan dan kompatibilitas npm.
|
|
168
|
+
|
|
169
|
+
### Panduan Framework
|
|
170
|
+
|
|
171
|
+
#### 1. Fastify 5 — Kinerja Tinggi & Validasi Skema
|
|
172
|
+
Gunakan untuk REST API dengan throughput tinggi. Selalu validasi input menggunakan TypeBox atau Zod.
|
|
173
|
+
|
|
174
|
+
#### 2. Hono & Hono RPC — Multi-Runtime & Type-Safe Full-Stack
|
|
175
|
+
Hono berjalan di Node.js, Bun, Cloudflare Workers, dan Deno. **Hono RPC** adalah fitur unggulan 2026 — panggilan API end-to-end yang fully type-safe tanpa code generation. Klien mendapatkan tipe yang tepat dari definisi server secara otomatis.
|
|
176
|
+
|
|
177
|
+
#### 3. Express 5
|
|
178
|
+
Express 5 otomatis menangkap rejected promises di async route handler tanpa butuh library tambahan.
|
|
179
|
+
|
|
180
|
+
#### 4. Edge Runtime (Cloudflare Workers / Vercel Edge)
|
|
181
|
+
Gunakan Hono untuk latensi ultra-rendah di edge. Batasan edge: tanpa built-in Node.js (`fs`, `path`), memori terbatas, tanpa proses long-running. Gunakan `fetch`, Web Crypto API, dan Cloudflare KV/D1/R2.
|
|
182
|
+
|
|
183
|
+
### Lapisan Data Type-Safe
|
|
184
|
+
- **Drizzle ORM**: Ideal untuk serverless/edge dengan query bergaya SQL dan zero overhead.
|
|
185
|
+
- **Prisma 6**: Ideal untuk pemodelan skema relasional kompleks dan tooling prisma studio yang kaya.
|
|
186
|
+
- **Connection Pooling**: Wajib di lingkungan serverless — gunakan PgBouncer, Supavisor, atau Neon Hyperdrive.
|
|
187
|
+
|
|
188
|
+
### Background Jobs (BullMQ + Redis)
|
|
189
|
+
Gunakan BullMQ dengan Redis untuk pemrosesan tugas latar belakang yang andal dengan retry otomatis, delay, dan konkurensi yang dapat dikonfigurasi.
|
|
190
|
+
|
|
191
|
+
### Graceful Shutdown
|
|
192
|
+
Jangan hentikan proses secara mendadak. Bersihkan connection pool, HTTP server, dan worker queue sebelum keluar.
|