All files / utils platformAdmin.js

100% Statements 4/4
100% Branches 0/0
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 1511x             29x     29x     11x  
const { GetCommand } = require('@aws-sdk/lib-dynamodb')
 
/**
 * True when the caller is a platform administrator (`isPlatformAdmin` on their
 * UsersTable row), who may manage any entity's comments and any store pack.
 */
async function isPlatformAdminUser(docClient, userId) {
  const result = await docClient.send(
    new GetCommand({ TableName: process.env.USERS_TABLE_NAME, Key: { id: userId } })
  )
  return result.Item?.isPlatformAdmin === true
}
 
module.exports = { isPlatformAdminUser }