feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes
This commit is contained in:
parent
01ef3293cf
commit
66b6b45ba9
399 changed files with 17828 additions and 11330 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { corsHeaders, handleCorsPreflightRequest } from '../_shared/cors.ts'
|
||||
import { requireUser, authErrorResponse, type AuthError } from '../_shared/auth.ts'
|
||||
import { createJsonResponder, JsonBodyError, readJsonBody } from '../_shared/json-response.ts'
|
||||
import { createServiceRoleClient } from '../_shared/quota.ts'
|
||||
import {
|
||||
calcSubscriptionPeriod,
|
||||
|
|
@ -31,12 +32,8 @@ interface ApplyResult {
|
|||
reason?: string
|
||||
}
|
||||
|
||||
function jsonResponse(body: Record<string, unknown>, status = 200): Response {
|
||||
return new Response(JSON.stringify(body), {
|
||||
status,
|
||||
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
|
||||
})
|
||||
}
|
||||
const MAX_REQUEST_BYTES = 16 * 1024
|
||||
const jsonResponse = createJsonResponder()
|
||||
|
||||
Deno.serve(async (req: Request) => {
|
||||
const preflight = handleCorsPreflightRequest(req)
|
||||
|
|
@ -50,7 +47,8 @@ Deno.serve(async (req: Request) => {
|
|||
|
||||
try {
|
||||
const user = await requireUser(req)
|
||||
const input = parseCheckoutRequest(await req.json())
|
||||
const rawBody = await readJsonBody(req, { maxBytes: MAX_REQUEST_BYTES })
|
||||
const input = parseCheckoutRequest(rawBody)
|
||||
if (!input) return jsonResponse({ error: 'invalid_request' }, 400)
|
||||
|
||||
// Configuration is validated before reserving state or contacting Payple.
|
||||
|
|
@ -164,6 +162,9 @@ Deno.serve(async (req: Request) => {
|
|||
amount: price,
|
||||
})
|
||||
} catch (error) {
|
||||
if (error instanceof JsonBodyError) {
|
||||
return jsonResponse({ error: error.status === 413 ? 'request_too_large' : 'invalid_request' }, error.status)
|
||||
}
|
||||
const plan = planCheckoutFailure(
|
||||
{
|
||||
hasOperation: operationId !== null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue