测试文件

This commit is contained in:
not-like-juvenile
2026-02-26 09:54:21 +08:00
parent 0762857434
commit 08a0408b0e
6 changed files with 475 additions and 8 deletions

37
server/insert_supa.js Normal file
View File

@@ -0,0 +1,37 @@
const fetch = require('node-fetch')
const SUPA = process.env.SUPA_URL || 'http://192.168.1.62:18000'
const KEY = process.env.SUPA_KEY || process.env.SERVICE_ROLE_KEY || ''
const payload = [
{
cid: 'CID_TEST_001',
user_id: 'a8e3a568-fc1f-4237-bcc5-5722e2fca0a3',
platform: 'android',
active: true
}
]
(async () => {
try {
const url = `${SUPA.replace(/\/$/, '')}/rest/v1/push_devices`
console.log('POST', url)
const resp = await fetch(url, {
method: 'POST',
headers: {
apikey: KEY,
Authorization: `Bearer ${KEY}`,
'Content-Type': 'application/json',
Prefer: 'return=representation'
},
body: JSON.stringify(payload),
timeout: 15000
})
console.log('status', resp.status)
const txt = await resp.text()
console.log('body:', txt)
} catch (e) {
console.error('insert error', e && e.message ? e.message : e)
process.exit(1)
}
})()