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 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 1x 1x 1x 1x 1x 1x 2x 1x 1x 1x | /**
* List Ribbons Lambda
* GET /v1/platform-admin/ribbons
*
* Returns every ribbon (active and inactive) for the platform-admin
* management UI. Requires `isPlatformAdmin: true`.
*/
const { DynamoDBClient } = require('@aws-sdk/client-dynamodb')
const { DynamoDBDocumentClient, ScanCommand } = require('@aws-sdk/lib-dynamodb')
const { requirePlatformAdmin } = require('../utils/requirePlatformAdmin')
const client = new DynamoDBClient({})
const docClient = DynamoDBDocumentClient.from(client)
const corsHeaders = {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
}
async function listRibbonsHandler() {
const result = await docClient.send(
new ScanCommand({ TableName: process.env.RIBBONS_TABLE_NAME })
)
const ribbons = (result.Items || []).sort((a, b) => a.createdAt.localeCompare(b.createdAt))
return {
statusCode: 200,
headers: corsHeaders,
body: JSON.stringify(ribbons)
}
}
exports.handler = requirePlatformAdmin(listRibbonsHandler)
|