async function del(req, res) {
  const name = (req.params.name || '').replace(/%20/g, ' ');
  const model = new models.Rule();
  const dbClient = await getKnexClient();

  let apiRule;
  try {
    apiRule = await model.get({ name });
  } catch (error) {
    if (error instanceof RecordDoesNotExist) {
      return res.boom.notFound('No record found');
    }
    throw error;
  }

  await dbClient.transaction(async (trx) => {
    await trx(TableNames.rules).where({ name }).del();
    await model.delete(apiRule);
  });

  if (inTestMode()) {
    const esClient = await Search.es(process.env.ES_HOST);
    await esClient.delete({
      id: name,
      index: process.env.ES_INDEX,
      type: 'rule',
    }, { ignore: [404] });
  }
  return res.send({ message: 'Record deleted' });
}
/**
 * deletes a rule
 *
 * @param {Object} req - express request object
 * @param {Object} res - express response object
 * @returns {Promise<Object>} the promise of express response object
 */
deletes a rule
@param {Object} req - express request object
@param {Object} res - express response object
@returns {Promise} the promise of express response object
deletes a rule @param { Object } req - express request object @param { Object } res - express response object @returns { Promise } the promise of express response object
async function del(req, res) {
  const name = (req.params.name || '').replace(/%20/g, ' ');
  const model = new models.Rule();
  const dbClient = await getKnexClient();
  let apiRule;
  try {
    apiRule = await model.get({ name });
  } catch (error) {
    if (error instanceof RecordDoesNotExist) {
      return res.boom.notFound('No record found');
    }
    throw error;
  }
  await dbClient.transaction(async (trx) => {
    await trx(TableNames.rules).where({ name }).del();
    await model.delete(apiRule);
  });
  if (inTestMode()) {
    const esClient = await Search.es(process.env.ES_HOST);
    await esClient.delete({
      id: name,
      index: process.env.ES_INDEX,
      type: 'rule',
    }, { ignore: [404] });
  }
  return res.send({ message: 'Record deleted' });
}
async function del ( req , res ) { const name = ( req . params . name || '' ) . replace ( / %20 / g , ' ' ) ; const model = new models . Rule ( ) ; const dbClient = await getKnexClient ( ) ; let apiRule ; try { apiRule = await model . get ( { name } ) ; } catch ( error ) { if ( error instanceof RecordDoesNotExist ) { return res . boom . notFound ( 'No record found' ) ; } throw error ; } await dbClient . transaction ( async ( trx ) => { await trx ( TableNames . rules ) . where ( { name } ) . del ( ) ; await model . delete ( apiRule ) ; } ) ; if ( inTestMode ( ) ) { const esClient = await Search . es ( process . env . ES_HOST ) ; await esClient . delete ( { id : name , index : process . env . ES_INDEX , type : 'rule' , } , { ignore : [ 404 ] } ) ; } return res . send ( { message : 'Record deleted' } ) ; }
deletes a rule
 @param {Object} req - express request object
 @param {Object} res - express response object
 @returns {Promise<Object>} the promise of express response object
deletes a rule @param { Object } req - express request object @param { Object } res - express response object @returns { Promise<Object > } the promise of express response object