How to use the boom.create 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 mozilla / chronicle / server / controllers / auth.js View on Github external
complete: function (request, reply) {
    // Bell has obtained the oauth token, used it to get the profile, and
    // that profile is available as request.auth.credentials.profile.
    // Now, use it to set a cookie.
    log.verbose('inside auth/complete');
    log.verbose('request.auth.credentials is ' + JSON.stringify(request.auth.credentials));

    // XXX temporary while we're in alpha: only allow whitelisted users, show
    // a friendly error message if they're not on the list.
    // TODO: on the front-end, auto-populate their email in a "want us to email you when
    // we are adding new users?" form
    if (!request.auth.credentials.profile.isAllowed) {
      return reply(Boom.create(401, 'Sorry, only whitelisted users are allowed at this time.'));
    }

    var session = {
      userId: request.auth.credentials.profile.userId
    };
    var duration = config.get('server_session_duration');
    if (duration > 0) {
      session.expiresAt = new Date(new Date().getTime() + duration);
    }
    request.auth.session.set(session);
    if (request.auth.credentials.profile.isNewUser) {
      reply.redirect('/#welcome');
    } else {
      reply.redirect('/');
    }
github node-tastypie / tastypie / lib / resource / index.js View on Github external
bundle.action  = action;

        [err] = this.check('dispatch', bundle );
        results = this.check('access', bundle );

        err = err ? err : results[0];

        if( err ){
            return this.exception( annotate( err, bundle ) );
        }

        method = results[1];

        if(this.throttle( bundle )){
            return this.exception( annotate( Boom.create(429), bundle ) );
        }

        this.domain.run(() => {
            let [err, result] = attempt(method, [bundle], this );
            if( err ){
                this.exception( annotate( err, bundle ) );
            }
        });
    }
github HenrikJoreteg / github-secret-keeper / server.js View on Github external
got.post('https://' + domain + '/login/oauth/access_token', options, function (err, body, response) {
      if (err) {
        if (err.statusCode === 404) {
          return reply(Boom.create(err.statusCode, 'GitHub could not find client ID: \'' + client + '\''))
        } else {
          return reply(Boom.create(500, err))
        }
      } else {
        if (body.error) {
          return reply(Boom.create(400, body.error_description))
        }
        return reply(body)
      }
    })
  }
github samtecspg / articulate / api / modules / agent / controllers / findIntentPostFormatInDomainByIdByAgentId.agent.controller.js View on Github external
server.inject(`/agent/${agentId}/domain/${domainId}`, (res) => {

                if (res.statusCode !== 200){
                    if (res.statusCode === 404){
                        const errorNotFound = Boom.notFound('The specified domain doesn\'t exists in this agent');
                        return cb(errorNotFound);
                    }
                    const error = Boom.create(res.statusCode, 'An error occurred getting the data of the domain');
                    return cb(error, null);
                }
                domainName = res.result.domainName;
                return cb(null);
            });
        },
github samtecspg / articulate / api / modules / agent / tools / respond.agent.tool.js View on Github external
server.inject(options, (res) => {

                    if (res.statusCode !== 200) {
                        const error = Boom.create(res.statusCode, `An error occurred updating the context ${elementInContext.id} of the session ${conversationStateObject.sessionId}`);
                        return callbackInsertInContext(error, null);
                    }
                    return callbackInsertInContext(null);
                });
            }
github samtecspg / articulate / api / modules / agent / controllers / findWebhook.agent.controller.js View on Github external
server.inject(`/agent/${agentId}`, (res) => {

                if (res.statusCode !== 200){
                    if (res.statusCode === 404){
                        const errorNotFound = Boom.notFound('The specified agent doesn\'t exists');
                        return cb(errorNotFound);
                    }
                    const error = Boom.create(res.statusCode, 'An error occurred getting the data of the agent');
                    return cb(error, null);
                }
                return cb(null, res.result);
            });
        },
github samtecspg / articulate / api / modules / domain / controllers / findEntitiesByDomainId.domain.controller.js View on Github external
server.inject(`/domain/${domainId}`, (res) => {

                if (res.statusCode !== 200){
                    if (res.statusCode === 404){
                        const error = Boom.notFound('The specified domain doesn\'t exists');
                        return cb(error, null);
                    }
                    const error = Boom.create(res.statusCode, 'An error occurred getting the domain');
                    return cb(error, null);
                }
                return cb(null);
            });
        },
github glennjones / be-more-hapi / lib / utilities.js View on Github external
buildError: function( code, error ){
    		return Boom.create( parseInt(code, 10), error);
		},
github samtecspg / articulate / api / modules / domain / controllers / deleteById.domain.controller.js View on Github external
server.inject(`/domain/${domainId}`, (res) => {

                if (res.statusCode !== 200){
                    if (res.statusCode === 404){
                        const error = Boom.notFound('The specified domain doesn\'t exists');
                        return cb(error, null);
                    }
                    const error = Boom.create(res.statusCode, `An error occurred getting the data of the domain ${domainId}`);
                    return cb(error, null);
                }
                domain = res.result;
                return cb(null);
            });
        },
github samtecspg / articulate / api / modules / agent / controllers / findIntentsInDomainByIdByAgentId.agent.controller.js View on Github external
server.inject('/agent/' + agentId, (res) => {

                if (res.statusCode !== 200){
                    if (res.statusCode === 404){
                        const errorNotFound = Boom.notFound('The specified agent doesn\'t exists');
                        return cb(errorNotFound);
                    }
                    const error = Boom.create(res.statusCode, 'An error occurred getting the data of the agent');
                    return cb(error, null);
                }
                return cb(null);
            });
        },