Appwrite: Bulk-Create, Bereichsabfragen, seitenweises Laden, genauerer Nachbau
appwriteAdmin: adminFetch kennt die Option raw (Body unverpackt), createDocuments (Bulk-Create, alles oder nichts, 409 bei vorhandener ID), listAllDocuments (seitenweise per cursorAfter, sortiert nach $id, Fehler ueber max) und Query.between/greaterThanEqual/ lessThanEqual/cursorAfter. Nachbau: Bulk-Create mit Alles-oder-nichts (409/400, hoechstens 100), die neuen Abfragen samt cursorAfter, Zeitpunktvergleich fuer ISO-Datumswerte, Optionen datetimes (Normalisierung auf +00:00, leeres Datum => 400) und defaultLimit (Standard-Limit wie Appwrite). Ohne die Optionen unveraendert. testApp exportiert send(method, path, opts). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
334dc1e669
commit
a5e12d7f34
4 files changed
+407
-23
No files matched your search
@@ -69,7 +69,8 @@ export async function startTestApp(routers = {}) {
|
||||
return { url: baseUrl, close: () => new Promise((resolve) => server.close(resolve)) }
|
||||
}
|
||||
|
||||
async function request(method, path, { body, cookie, headers = {} } = {}) {
|
||||
/** Anfrage an die zuletzt gestartete App (beliebige Methode) -> { status, body, headers }; body ist geparstes JSON, sonst Text. */
|
||||
export async function send(method, path, { body, cookie, headers = {} } = {}) {
|
||||
if (!baseUrl) throw new Error('testApp: startTestApp() zuerst aufrufen')
|
||||
const res = await fetch(baseUrl + path, {
|
||||
method,
|
||||
@@ -92,7 +93,7 @@ async function request(method, path, { body, cookie, headers = {} } = {}) {
|
||||
}
|
||||
|
||||
/** GET -> { status, body } */
|
||||
export const rawGet = (path, opts = {}) => request('GET', path, opts)
|
||||
export const rawGet = (path, opts = {}) => send('GET', path, opts)
|
||||
|
||||
/** GET -> JSON-Body; ab Status 400 fliegt ein Fehler mit err.status und err.body. */
|
||||
export async function get(path, opts = {}) {
|
||||
@@ -107,7 +108,7 @@ export async function get(path, opts = {}) {
|
||||
}
|
||||
|
||||
/** POST mit JSON-Body -> { status, body } */
|
||||
export const post = (path, body, opts = {}) => request('POST', path, { ...opts, body })
|
||||
export const post = (path, body, opts = {}) => send('POST', path, { ...opts, body })
|
||||
|
||||
// Signiert wie Stripe (whsec_test aus useTestEnv); der Schluessel wird nie fuer Netzaufrufe benutzt
|
||||
const webhookSigner = new Stripe('sk_test_fake')
|
||||
@@ -116,5 +117,5 @@ const webhookSigner = new Stripe('sk_test_fake')
|
||||
export function postWebhook(event, { path = '/api/abo/webhook', secret = config.stripe.webhookSecret || 'whsec_test' } = {}) {
|
||||
const payload = JSON.stringify(event)
|
||||
const stripeSignature = webhookSigner.webhooks.generateTestHeaderString({ payload, secret })
|
||||
return request('POST', path, { body: payload, headers: { 'stripe-signature': stripeSignature } })
|
||||
return send('POST', path, { body: payload, headers: { 'stripe-signature': stripeSignature } })
|
||||
}
|
||||
Reference in new issue
Block a user