refactor: HC-WPの設定値取得をfilter付きGetから一括取得+Codeフィルタに変更
n8nワークフロー構築の基本ルール(Data Table利用最小限)に合わせ、 HEALTHCHECK_WP_API_KEYの取得方法をfilters付き単一キーGetから returnAll:trueの一括取得+Codeノード内find()に変更。ノード数は 5のまま変わらず。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
33057b8dab
commit
c8ce15385a
@ -20,7 +20,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "dt-get-healthcheck_wp_api_key",
|
"id": "dt-get-healthcheck_wp_api_key",
|
||||||
"name": "HEALTHCHECK_WP_API_KEY取得",
|
"name": "設定値一括取得",
|
||||||
"type": "n8n-nodes-base.dataTable",
|
"type": "n8n-nodes-base.dataTable",
|
||||||
"typeVersion": 1,
|
"typeVersion": 1,
|
||||||
"position": [
|
"position": [
|
||||||
@ -34,14 +34,6 @@
|
|||||||
"mode": "id",
|
"mode": "id",
|
||||||
"value": "bNkadTyDgDepYx2p"
|
"value": "bNkadTyDgDepYx2p"
|
||||||
},
|
},
|
||||||
"filters": {
|
|
||||||
"conditions": [
|
|
||||||
{
|
|
||||||
"keyName": "configKey",
|
|
||||||
"keyValue": "HEALTHCHECK_WP_API_KEY"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"returnAll": true
|
"returnAll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -55,7 +47,7 @@
|
|||||||
300
|
300
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"jsCode": "const expectedApiKey = $('HEALTHCHECK_WP_API_KEY取得').item.json.configValue;\nconst headers = $input.first().json.headers || {};\nif (headers[\"x-api-key\"] !== expectedApiKey) {\n throw new Error(\"Unauthorized: invalid API key\");\n}\nconst body = $input.first().json.body || {};\nif (!body.resultId || !body.processId) {\n throw new Error(\"Bad Request: resultId, processId は必須です\");\n}\nreturn [{ json: { resultId: body.resultId, processId: body.processId } }];"
|
"jsCode": "const configRows = $('設定値一括取得').all().map((item) => item.json);\nconst expectedApiKey = configRows.find((row) => row.configKey === \"HEALTHCHECK_WP_API_KEY\")?.configValue;\nconst headers = $input.first().json.headers || {};\nif (headers[\"x-api-key\"] !== expectedApiKey) {\n throw new Error(\"Unauthorized: invalid API key\");\n}\nconst body = $input.first().json.body || {};\nif (!body.resultId || !body.processId) {\n throw new Error(\"Bad Request: resultId, processId は必須です\");\n}\nreturn [{ json: { resultId: body.resultId, processId: body.processId } }];"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -103,14 +95,14 @@
|
|||||||
"main": [
|
"main": [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"node": "HEALTHCHECK_WP_API_KEY取得",
|
"node": "設定値一括取得",
|
||||||
"type": "main",
|
"type": "main",
|
||||||
"index": 0
|
"index": 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"HEALTHCHECK_WP_API_KEY取得": {
|
"設定値一括取得": {
|
||||||
"main": [
|
"main": [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user