export async function stacks()

in api/index.js [49:97]


export async function stacks(req, res) {
  const superhubs = await superhubBuckets();
  const id = stackID(req.path);
  switch (req.method) {
    case 'GET':
      if (id) {
        let stack;
        if (req.query.raw || req.query.raw === '') {
          stack = await stackByID(id, superhubs, true);
        } else {
          stack = await stackByID(id, superhubs, false);
        }
        if (stack) {
          res
              .status(200)
              .set('content-type', 'application/json')
              .send(JSON.stringify(stack));
        } else {
          res
              .status(404)
              .send('Sorry, cant find that');
        }
      } else {
        const stacks = await allStacks(superhubs);
        res
            .status(200)
            .set('content-type', 'application/json')
            .send(JSON.stringify(filter(stacks, req.query)));
      }
      break;
    case 'DELETE':
      stack = await stackByID(id, superhubs, false);
      if (stack) {
        await deleteByID(id, superhubs);
        res
            .status(202)
            .send('');
      } else {
        res
            .status(404)
            .send('');
      }
      break;
    default:
      res
          .status(400)
          .send('Sorry, not supported');
  }
}