packages/api/src/routes/metaplex-upload.js
/**
 * Validates that the account associated with the METAPLEX_AUTH_TOKEN secret exists,
 * and returns the user id and auth key id.
 * @param {import('../utils/db-client').DBClient} db
 */
Validates that the account associated with the METAPLEX_AUTH_TOKEN secret exists,
and returns the user id and auth key id.
Validates that the account associated with the METAPLEX_AUTH_TOKEN secret exists and returns the user id and auth key id .
async function validate(db) {
  if (!secrets.metaplexAuth) {
    throw new Error('missing metaplex auth key')
  }
  const { error, data } = await db.client
    .from('auth_key')
    .select('id,user:auth_key_user_id_fkey(id)')
    .eq('secret', secrets.metaplexAuth)
    .single()
  if (error) {
    throw new DBError(error)
  }
  if (!data) {
    throw new HTTPError('metaplex user not found', 404)
  }
  return { user: { id: data.user.id }, key: { id: data.id } }
}
async function validate ( db ) { if ( ! secrets . metaplexAuth ) { throw new Error ( 'missing metaplex auth key' ) } const { error , data } = await db . client . from ( 'auth_key' ) . select ( 'id,user:auth_key_user_id_fkey(id)' ) . eq ( 'secret' , secrets . metaplexAuth ) . single ( ) if ( error ) { throw new DBError ( error ) } if ( ! data ) { throw new HTTPError ( 'metaplex user not found' , 404 ) } return { user : { id : data . user . id } , key : { id : data . id } } }
Validates that the account associated with the METAPLEX_AUTH_TOKEN secret exists,
 and returns the user id and auth key id.
Validates that the account associated with the METAPLEX_AUTH_TOKEN secret exists and returns the user id and auth key id .
// note: we need to specify the foreign key to use in the select statement below // because there's also a potential join between `auth_key` and `user` // via the `uploads` table.