MCPcopy Index your code
hub / github.com/scality/cloudserver / routeIndexingAPIs

Function routeIndexingAPIs

lib/routes/routeBackbeat.js:1606–1640  ·  view source on GitHub ↗
(request, response, userInfo, log, callback)

Source from the content-addressed store, hash-verified

1604const indexingSchema = joi.array().items(indexEntrySchema).min(1);
1605
1606function routeIndexingAPIs(request, response, userInfo, log, callback) {
1607 const route = backbeatRoutes[request.method][request.resourceType];
1608
1609 if (!['GET', 'POST'].includes(request.method)) {
1610 return callback(errors.MethodNotAllowed);
1611 }
1612
1613 if (request.method === 'GET') {
1614 return route(request, response, userInfo, log, callback);
1615 }
1616
1617 const op = request.query.operation;
1618
1619 if (!op || typeof route[op] !== 'function') {
1620 log.error('Invalid operation parameter', { operation: op });
1621 return callback(errors.BadRequest);
1622 }
1623
1624 return _getRequestPayload(request, (err, payload) => {
1625 if (err) {
1626 return callback(err);
1627 }
1628
1629 let parsedIndex;
1630
1631 try {
1632 parsedIndex = joi.attempt(JSON.parse(payload), indexingSchema, 'invalid payload');
1633 } catch (err) {
1634 log.error('Unable to parse index request body', { error: err });
1635 return callback(errors.BadRequest);
1636 }
1637
1638 return route[op](parsedIndex, request, response, userInfo, log, callback);
1639 });
1640}
1641
1642function routeBackbeatAPIProxy(request, response, requestContexts, log) {
1643 const path = request.url.replace('/_/backbeat/api/', '/_/');

Callers 1

routeNonObjectRequestFunction · 0.85

Calls 2

_getRequestPayloadFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected