비교 예제

아래 각 예제는 홈의 원클릭 단추가 불러오는 쌍과 같습니다. 짧은 기획용 샘플이며, 운영 파일도 아니고 특정 공급업체나 구성에 대한 추천도 아닙니다.

JSON 설정

결제 API 설정입니다. 수정본은 요청 한도를 높이고, 기능 플래그를 바꾸며, CORS 출처를 하나 추가합니다.

원문

{
  "service": "checkout-api",
  "version": "1.4.0",
  "rateLimit": {
    "windowSeconds": 60,
    "maxRequests": 120
  },
  "featureFlags": {
    "newCheckout": false,
    "legacyCart": true,
    "auditLog": true
  },
  "cors": {
    "origins": [
      "shop.example.com",
      "admin.example.com"
    ],
    "allowCredentials": true
  }
}

수정본

{
  "service": "checkout-api",
  "version": "1.5.0",
  "rateLimit": {
    "windowSeconds": 60,
    "maxRequests": 200
  },
  "featureFlags": {
    "newCheckout": true,
    "legacyCart": false,
    "auditLog": true,
    "expressPay": true
  },
  "cors": {
    "origins": [
      "shop.example.com",
      "admin.example.com",
      "preview.example.com"
    ],
    "allowCredentials": true
  }
}

Nginx 서버 블록

가상 호스트입니다. 수정본은 HTTP/2와 gzip을 켜고, 프록시 제한 시간을 늘리며, 정적 자산의 캐시 헤더를 더 엄격하게 만듭니다.

원문

upstream shop_app {
    server 127.0.0.1:8080;
}

server {
    listen 80;
    server_name shop.example.com;
    root /var/www/shop;
    index index.html;

    location / {
        proxy_pass shop_app;
        proxy_set_header Host $host;
        proxy_read_timeout 30s;
    }

    location /assets/ {
        expires 1h;
        add_header Cache-Control "public";
    }
}

수정본

upstream shop_app {
    server 127.0.0.1:8080;
}

server {
    listen 443 ssl http2;
    server_name shop.example.com;
    root /var/www/shop;
    index index.html;

    gzip on;
    gzip_types text/css application/javascript application/json;

    location / {
        proxy_pass shop_app;
        proxy_set_header Host $host;
        proxy_read_timeout 90s;
        proxy_http_version 1.1;
    }

    location /assets/ {
        expires 30d;
        add_header Cache-Control "public, immutable";
        add_header X-Content-Type-Options nosniff;
    }
}

SQL 변경

주문 보고서 쿼리입니다. 수정본은 인덱스를 추가하고, 조인을 바꾸며, 날짜와 상태 조건을 더 좁힙니다.

원문

SELECT
  o.id,
  o.created_at,
  c.email,
  SUM(i.qty * i.unit_price) AS total
FROM orders o
INNER JOIN customers c ON c.id = o.customer_id
INNER JOIN order_items i ON i.order_id = o.id
WHERE o.created_at >= '2024-01-01'
  AND o.status <> 'cancelled'
GROUP BY o.id, o.created_at, c.email
ORDER BY o.created_at DESC;

수정본

CREATE INDEX idx_orders_created_status
  ON orders (created_at, status);

SELECT
  o.id,
  o.created_at,
  c.email,
  SUM(i.qty * i.unit_price) AS total
FROM orders o
LEFT JOIN customers c ON c.id = o.customer_id
INNER JOIN order_items i ON i.order_id = o.id
WHERE o.created_at >= '2025-01-01'
  AND o.status IN ('paid', 'shipped')
GROUP BY o.id, o.created_at, c.email
ORDER BY o.created_at DESC;

Markdown 메모

짧은 변경 기록입니다. 수정본은 버전을 올리고, 새 --dry-run 플래그를 적으며, 사용법 줄을 업데이트합니다.

원문

# Release notes

## 1.2.0

- Format and minify a query in the browser.
- Add a --watch flag for local previews.
- Document the default port in the README.

Usage:

    desk format --file query.sql

수정본

# Release notes

## 1.3.0

- Format and minify a query in the browser.
- Add a --dry-run flag before writing a file.
- Add a --watch flag for local previews.
- Document the default port and locale prefix in the README.

Usage:

    desk format --file query.sql --dry-run

비교 도구로 돌아가기

질문

이 페이지에서 예제를 편집할 수 있나요?

이 페이지는 정적 열람용입니다. 홈의 비교 도구를 열고 원클릭 예제 단추로 같은 쌍을 편집기에 불러오세요.