async function pinsGet (request, env, ctx) {
  const url = new URL(request.url)
  const urlParams = new URLSearchParams(url.search)
  const params = Object.fromEntries(urlParams)

  const result = parseSearchParams(params)
  if (result.error) {
    return new JSONResponse(result.error, { status: 400 })
  }

  let pinRequests
  const opts = result.data

  try {
    pinRequests = await env.db.listPsaPinRequests(request.auth.authToken._id, opts)
  } catch (e) {
    console.error(e)
    return notFound()
  }

  const pins = pinRequests.results.map((pinRequest) => getPinStatus(pinRequest))

  return new JSONResponse({
    count: pinRequests.count,
    results: pins
  })
}
/**
 * List all the pins matching optional filters.
 * When no filter is specified, only successful pins are returned.
 *
 * @param {import('./user').AuthenticatedRequest} request
 * @param {import('./env').Env} env
 * @param {import('./index').Ctx} ctx
 */
List all the pins matching optional filters.
When no filter is specified, only successful pins are returned.


List all the pins matching optional filters . When no filter is specified only successful pins are returned .
async function pinsGet (request, env, ctx) {
  const url = new URL(request.url)
  const urlParams = new URLSearchParams(url.search)
  const params = Object.fromEntries(urlParams)
  const result = parseSearchParams(params)
  if (result.error) {
    return new JSONResponse(result.error, { status: 400 })
  }
  let pinRequests
  const opts = result.data
  try {
    pinRequests = await env.db.listPsaPinRequests(request.auth.authToken._id, opts)
  } catch (e) {
    console.error(e)
    return notFound()
  }
  const pins = pinRequests.results.map((pinRequest) => getPinStatus(pinRequest))
  return new JSONResponse({
    count: pinRequests.count,
    results: pins
  })
}
async function pinsGet ( request , env , ctx ) { const url = new URL ( request . url ) const urlParams = new URLSearchParams ( url . search ) const params = Object . fromEntries ( urlParams ) const result = parseSearchParams ( params ) if ( result . error ) { return new JSONResponse ( result . error , { status : 400 } ) } let pinRequests const opts = result . data try { pinRequests = await env . db . listPsaPinRequests ( request . auth . authToken . _id , opts ) } catch ( e ) { console . error ( e ) return notFound ( ) } const pins = pinRequests . results . map ( ( pinRequest ) => getPinStatus ( pinRequest ) ) return new JSONResponse ( { count : pinRequests . count , results : pins } ) }
List all the pins matching optional filters.
List all the pins matching optional filters .