How to use the boom.notFound function in boom

To help you get started, we’ve selected a few boom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JKHeadley / appy-backend / server / api / login.js View on Github external
.then(function (user) {
            // NOTE: For more secure applications, the server should respond with a success even if the user isn't found
            // since this reveals the existence of an account. For more information, refer to the links below:
            // https://postmarkapp.com/guides/password-reset-email-best-practices
            // https://security.stackexchange.com/questions/40694/disclose-to-user-if-account-exists
            if (!user) {
              return reply(Boom.notFound('User not found.'));
            }
            return reply(user);
          })
          .catch(function (error) {
github elastic / kibana / x-pack / legacy / plugins / ml / server / models / data_recognizer / data_recognizer.js View on Github external
async getModule(id, prefix = '') {
    let manifestJSON = null;
    let dirName = null;

    const manifestFile = await this.getManifestFile(id);
    if (manifestFile !== undefined) {
      manifestJSON = manifestFile.json;
      dirName = manifestFile.dirName;
    }
    else {
      throw Boom.notFound(`Module with the id "${id}" not found`);
    }

    const jobs = [];
    const datafeeds = [];
    const kibana = {};
    // load all of the job configs
    await Promise.all(manifestJSON.jobs.map(async (job) => {
      try {
        const jobConfig = await this.readFile(`${this.modulesDir}/${dirName}/${ML_DIR}/${job.file}`);
        // use the file name for the id
        jobs.push({
          id: `${prefix}${job.id}`,
          config: JSON.parse(jobConfig)
        });
      } catch (error) {
        mlLog.warn(`Data recognizer error loading config for job ${job.id} for module ${id}. ${error}`);
github screwdriver-cd / screwdriver / plugins / pipelines / tokens / update.js View on Github external
.then(([token, pipeline, user]) => {
                    if (!token) {
                        throw boom.notFound('Token does not exist');
                    }

                    if (!pipeline) {
                        throw boom.notFound('Pipeline does not exist');
                    }

                    if (!user) {
                        throw boom.notFound('User does not exist');
                    }

                    return user.getPermissions(pipeline.scmUri).then((permissions) => {
                        if (!permissions.admin) {
                            throw boom.forbidden(`User ${username} `
                                + 'is not an admin of this repo');
                        }

                        return Promise.resolve();
                    }).then(() => {
                        if (token.pipelineId !== pipeline.id) {
                            throw boom.forbidden('Pipeline does not own token');
github elastic / kibana / x-pack / plugins / code / server / git_operations.ts View on Github external
async function checkExists(func: () => Promise, message: string): Promise {
  let result: R;
  try {
    result = await func();
  } catch (e) {
    if (e.errno === NodeGitError.CODE.ENOTFOUND) {
      throw Boom.notFound(message);
    } else {
      throw e;
    }
  }
  if (result == null) {
    throw Boom.notFound(message);
  }
  return result;
}
github screwdriver-cd / screwdriver / plugins / builds / token.js View on Github external
return buildFactory.get(request.params.id).then((build) => {
                if (!build) {
                    throw boom.notFound('Build does not exist');
                }

                if (parseInt(request.params.id, 10) !== parseInt(profile.username, 10)) {
                    throw boom.notFound('Build Id parameter and token does not match');
                }

                if (isFinite(buildTimeout) === false && buildTimeout !== null) {
                    throw boom.badRequest(`Invalid buildTimeout value: ${buildTimeout}`);
                }

                if (build.status !== 'QUEUED' && build.status !== 'BLOCKED') {
                    throw boom.forbidden('Build is already running or finished.');
                }
                const jwtInfo = {
                    isPR: profile.isPR,
                    jobId: profile.jobId,
                    eventId: profile.eventId,
                    pipelineId: profile.pipelineId,
                    configPipelineId: profile.configPipelineId
                };
github ryanmurakami / hbfl / handlers / races.js View on Github external
.catch((err) => {
      reply(Boom.notFound(err))
    })
}
github nus-mtp / worldscope / app_server / app / controllers / StreamController.js View on Github external
Service.getStreamById(request.params.id).then(function(result) {
    if (result instanceof Error) {
      logger.error(result.message);
      return reply(Boom.notFound(result.message));
    }

    return reply(result);
  });
};
github samtecspg / articulate / api / modules / intent / controllers / findScenario.intent.controller.js View on Github external
redis.hgetall(`scenario:${intentId}`, (err, data) => {

        if (err){
            const error = Boom.badImplementation('An error occurred retrieving the scenario.');
            return reply(error);
        }
        if (data){
            return reply(null, Cast(Flat.unflatten(data), 'scenario'));
        }
        const error = Boom.notFound('The specified scenario doesn\'t exists');
        return reply(error);
    });
github uvsankar / dairy / backend / dataAccess / journal-accessor-file.js View on Github external
async getJournalEntry(journal, id) {
        const me = this;
        try {
            let entryPath = path.join(me.parentFolder, journal, id);
            if(!fs.existsSync(entryPath))
                throw Boom.notFound(`Entry ${id} not found.`);
            return JSON.parse(fs.readFileSync(entryPath, 'utf8'))
        } catch (err) {
            me.error(scope, 'getJournalEntry', err);
            throw err;
        }
    }
github mozilla / api.webmaker.org / services / api / handlers / elements.js View on Github external
function(err, result) {
        if ( err ) {
          return reply(err);
        }

        if ( !result.rows.length ) {
          return reply(boom.notFound('Element not found'));
        }

        reply({
          status: 'success',
          element: request.server.methods.utils.formatElement(result.rows[0])
        });
      }
    );