How to use the boom.badImplementation 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 elitan / hasura-backend-plus / src / auth / auth.js View on Github external
where: {
        email: { _eq: $email }
      }
    ) {
      id
    }
  }
  `;

  try {
    var hasura_data = await graphql_client.request(query, {
      email,
    });
  } catch (e) {
    console.log(e);
    return next(Boom.badImplementation('Unable to check for duplicates'));
  }

  if (hasura_data.users.length !== 0) {
    return next(Boom.unauthorized('The email is already in use'));
  }

  // generate password_hash
  try {
    var password_hash = await bcrypt.hash(password, 10);
  } catch(e) {
    return next(Boom.badImplementation('Unable to generate password hash'));
  }

  // insert user
  var query = `
  mutation insert_user($user: users_insert_input!) {
github ArkEcosystem / core / packages / core-api / src / versions / 1 / delegates / controller.ts View on Github external
public async index(request: Hapi.Request, h: Hapi.ResponseToolkit) {
        try {
            // @ts-ignore
            const data = await request.server.methods.v1.delegates.index(request);

            return super.respondWithCache(data, h);
        } catch (error) {
            return Boom.badImplementation(error);
        }
    }
github codius / codiusd / src / services / SelfTestCheck.ts View on Github external
server.ext('onPreAuth', (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
        const selfTest = this.selfTest
        const config = this.config

        if (selfTest.selfTestSuccess) {
          return h.continue
        }

        if (!selfTest) {
          log.error('self test stats missing from plugin context')
          throw Boom.badImplementation('self test stats missing from plugin context')
        }

        if (request.headers['authorization']) {
          const token = request.headers['authorization'].split(' ')[1]

          if (token === config.bearerToken) {
            log.debug('Route authenticated using bearer token')
            return h.continue
          }
        }

        const stats = selfTest.getTestStats()

        return h.response({
          message: stats.running ? 'Self Test Running' : 'Self Test Failed',
          stats: stats
github samtecspg / articulate / api / modules / agent / tools / parseText.agent.tool.js View on Github external
}, (err, wreckResponse, payload) => {

        if (err) {
            const error = Boom.badImplementation('Error calling duckling to parse text');
            return callback(error, null);
        }

        //The value in the result is not formatted as JSON. This formats that value
        payload = _.map(payload, (ducklingResult) => {

            //ducklingResult.value = JSON.parse(ducklingResult.value);
            return ducklingResult;
        });

        payload = DucklingOutputToIntervals(payload, timezone);
        return callback(null, payload);
    });
};
github samtecspg / articulate / api / modules / intent / controllers / updateById.intent.controller.js View on Github external
redis.hmset(`agent:${agentId}`, { status: Status.outOfDate }, (err) => {

                            if (err){
                                const error = Boom.badImplementation('An error occurred updating the agent status.');
                                return callback(error);
                            }
                            redis.hmset(`domain:${domainId}`, { status: Status.outOfDate }, (err) => {

                                if (err){
                                    const error = Boom.badImplementation('An error occurred updating the domain status.');
                                    return callback(error);
                                }
                                return callback(null, resultIntent);
                            });
                        });
                    });
github CoderDojo / cp-zen-platform / web / api / handlers.js View on Github external
request.seneca.act(msg, (err, resp) => {
        if (err) return reply(Boom.badImplementation());
        let isCDFAdmin = false;
        let code = 200;
        const roles = _.deepHas(user, 'user.roles')
          ? request.user.user.roles
          : [];
        if (_.includes(roles, 'cdf-admin')) {
          isCDFAdmin = true;
        }
        if (!resp.userIsDojoAdmin && !isCDFAdmin) {
          code = 401;
          return reply({
            ok: false,
            why:
              'You must be a dojo admin or ticketing admin to access this data',
          }).code(code);
        }
github yalla-coop / connect5 / v2 / server / controllers / behavioralInsight / getLocalLeadBehavioralInsight(legacy).js View on Github external
if (!id) {
    return next(boom.badRequest('no local lead id provided'));
  }
  try {
    const results = await getPINsRespondedToGroupSessions(id);
    const PINs = results[0] && results[0].PIN;
    return getTrainerBehavioral(PINs)
      .then(result => {
        const calculatedFormulae = trainerBehavioralFormulae(result);
        res.json({ ...calculatedFormulae });
      })
      .catch(err => {
        return next(boom.badImplementation('error in getting the data'));
      });
  } catch (error) {
    return next(boom.badImplementation());
  }
};
github samtecspg / articulate / api / modules / action / controllers / addPostFormat.action.controller.js View on Github external
redis.zscore('agents', postFormat.agent, (err, id) => {

                        if (err){
                            const error = Boom.badImplementation('An error occurred checking if the agent exists.');
                            return callback(error);
                        }
                        if (id){
                            agentId = id;
                            return callback(null);
                        }
                        const error = Boom.badRequest(`The agent ${postFormat.agent} doesn't exist`);
                        return callback(error, null);
                    });
                },
github samtecspg / articulate / api / modules / intent / controllers / updateScenario.intent.controller.js View on Github external
redis.zscore('agents', currentScenario.agent, (err, agentId) => {

                            if (err){
                                const error = Boom.badImplementation('An error occurred checking if the agent exists.');
                                return callback(error);
                            }
                            if (agentId){
                                return callback(null, agentId);
                            }
                            const error = Boom.badRequest(`The agent ${currentScenario.agent} doesn't exist`);
                            return callback(error, null);
                        });
                    },
github mozilla / thimble.mozilla.org / services / id.webmaker.org / web / server.js View on Github external
server.methods.account.requestMigrateEmail(request, function(err, json) {
          if ( err ) {
            return reply(Boom.badImplementation(err));
          }
          reply({ status: 'migration email sent' });
        });
      }