比較の例

以下の各例は、ホームのワンクリックボタンが読み込む組と同じです。短い計画用の見本であり、本番ファイルでも、特定の製品や構成の推薦でもありません。

JSON 設定

チェックアウト API の設定です。修正稿はレート制限を上げ、機能フラグを切り替え、CORS のオリジンを 1 つ追加します。

原文

{
  "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

チェッカーに戻る

質問

このページでサンプルを編集できますか?

このページは静的な読み取り用です。ホームのチェッカーを開き、ワンクリックのサンプルボタンで同じ組を編集欄へ読み込んでください。