INNER CODE UNIT · TypeScript

createLink

Hash-Studios/Prism · infra/cloudflare/worker/src/index.ts:126

async function createLink(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
  const ip = getClientIp(request);
  const withinRateLimit = await enforceCreateRateLimits(ip, env);
  if (!withinRateLimit) {
    return json({ error: 'rate_limited' }, 429);
  }

  let body: CreateLinkRequest;
  try {
    body = (await request.json()) as CreateLinkRequest;
  } catch {
    return json({ error: 'invalid_json' }, 400);
  }

  if (!isValidType(body.type)) {
    return json({ error: 'invalid_type' }, 400);
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…