Files
alist-serve-resource/n8n/gen_w5.js
T
hoelee 414bf31ba0 feat(n8n): W5 footer purchase-check webhook (公开只读) + docs
- W5 gets username ?u= → Customers→CustomerProducts → {username,known,purchases}
- 无 HMAC(密钥会下发客户端): 改用 CORS 限 drive.digikedai.com + 最小数据 + CF WAF 建议
- 复用现有 NOCODB_* env, 零新增 env
- 2 节点: webhook(GET, lastNode, CORS 头) + Code(w5-body.js)
- footer v2.6 动态行数据源; 待手动导入 n8n
- docs: N8N_WORKFLOWS + PROJECT_STATE 记录 W5 + 导入步骤
2026-08-28 18:24:42 +08:00

58 lines
1.8 KiB
JavaScript

// Builds n8n/W5-purchase-check.json — public footer purchase/expiry webhook.
// Trigger: GET /webhook/dk-purchase-check?u=<username>
// Response (JSON, CORS: https://drive.digikedai.com):
// { username, known, purchases: [{product, expires_at, display_state}] }
// No HMAC (key would ship client-side = theatre). Access control = CORS +
// Cloudflare WAF rate-limit/Origin rule (documented in delivery guide).
// Run: node n8n/gen_w5.js
const fs = require('fs');
const path = require('path');
const body = fs.readFileSync(path.join(__dirname, 'w5-body.js'), 'utf8');
const workflow = {
name: 'W5 - Footer Purchase Check (Public)',
nodes: [
{
parameters: {
httpMethod: 'GET',
path: 'dk-purchase-check',
responseMode: 'lastNode',
options: {
responseCode: 200,
responseHeaders: {
entries: [
{ name: 'Access-Control-Allow-Origin', value: 'https://drive.digikedai.com' },
{ name: 'Content-Type', value: 'application/json' }
]
}
}
},
id: 'trigger-webhook',
name: 'Footer Purchase Check (Webhook)',
type: 'n8n-nodes-base.webhook',
typeVersion: 2,
position: [0, 0],
webhookId: 'dk-purchase-check'
},
{
parameters: { jsCode: body },
id: 'lookup',
name: 'Lookup Purchases',
type: 'n8n-nodes-base.code',
typeVersion: 2,
position: [220, 0]
}
],
connections: {
'Footer Purchase Check (Webhook)': {
main: [[{ node: 'Lookup Purchases', type: 'main', index: 0 }]]
}
},
settings: { executionOrder: 'v1' },
pinData: {}
};
fs.writeFileSync(path.join(__dirname, 'W5-purchase-check.json'), JSON.stringify(workflow, null, 2) + '\n');
console.log('wrote W5-purchase-check.json (' + body.length + ' chars body)');