How to use the http-status-codes.BAD_GATEWAY function in http-status-codes

To help you get started, we’ve selected a few http-status-codes 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 Ionaru / EVIE / server / src / routers / sso.router.ts View on Github external
process.emitWarning(
                `Invalid state from /auth-callback request! Expected '${request.session!.state}' and got '${request.query.state}'.`,
            );
            return SSORouter.sendResponse(response, httpStatus.BAD_REQUEST, 'InvalidState');
        }
        delete request.session!.state;

        const authResponse = await SSORouter.doAuthRequest(SSORouter.getSSOAuthString(), request.query.code);

        if (!authResponse || authResponse.status !== httpStatus.OK) {
            return SSORouter.sendResponse(response, httpStatus.BAD_GATEWAY, 'SSOTokenResponseError');
        }

        const token = jwt.decode(authResponse.data.access_token) as IJWTToken;
        if (!SSORouter.isJWTValid(token)) {
            return SSORouter.sendResponse(response, httpStatus.BAD_GATEWAY, 'InvalidJWTToken');
        }

        const {characterID, characterName, characterOwnerHash, characterScopes} = SSORouter.extractJWTValues(token);

        let user = await User.getFromId(request.session!.user.id);

        if (!user) {
            return SSORouter.sendResponse(response, httpStatus.NOT_FOUND, 'UserNotFound');
        }

        let character = await Character.getFromId(characterID);

        // Only revoke the token if the new one is different.
        if (character && character.refreshToken && character.refreshToken !== authResponse.data.refresh_token) {
            // Revoke old token
            SSORouter.revokeKey(character.refreshToken, 'refresh_token').then();
github Azure / meta-azure-service-broker / test / unit / services / azuresqldb / poll-spec.js View on Github external
it('fail if an unexpected error code is received without an error', function (done) {
            var cp = new cmdPoll(afterProvisionValidParamsWithTDE);
            var tdeResult = {
                statusCode:HttpStatus.BAD_GATEWAY,
                body:{
                    message:'Bad Gateway'
                }
            };
            msRestRequest.PUT.withArgs('https://management.azure.com//subscriptions/55555555-4444-3333-2222-111111111111/resourceGroups/sqldbResourceGroup/providers/Microsoft.Sql/servers/golive4/databases/sqldb/transparentDataEncryption/current')
              .yields(null, tdeResult, tdeResult.body);

            cp.poll(sqldbOps, function (err, result) {
                should.exist(err);
                err.message.should.equal('Bad Gateway');
                done();
            });
        });
github Sunbird-Ed / SunbirdEd-portal / src / app / helpers / announcement / controller.js View on Github external
if (_.get(error, 'body.params.err') === 'USER_NOT_FOUND') {
                            reject(this.customError({
                                message: 'User not found!',
                                status: HttpStatus.NOT_FOUND,
                                isCustom:true
                            }))
                        } else if (_.get(error, 'body.params.err') === 'UNAUTHORIZE_USER') {
                            reject(this.customError({
                                message: 'Unauthorized User!',
                                status: HttpStatus.UNAUTHORIZED,
                                isCustom:true
                            }))
                        } else {
                            reject(this.customError({
                                message: 'Unknown Error!',
                                status: HttpStatus.BAD_GATEWAY,
                                isCustom:true
                            }))
                        }
                    })
            } catch (error) {
github AceMetrix / connect-cas / lib / service-validate.js View on Github external
options.pgtFn.call(null, pgtIou, function(err, pgt){
                if (err) return res.send(HttpStatus.BAD_GATEWAY);
                req.session.pgt = pgt;
                next();
            });
            return;
github springernature / thundermole / lib / thundermole.js View on Github external
proxy.on('error', function (error) {
		arguments[0].status = httpStatus.BAD_GATEWAY;
		mole.logger.error('Error in HTTP proxy: %s', error.stack);
		mole.statsd.increment('proxy_response_' + arguments[0].status);
		mole.statsd.increment('proxy_error');
		handleError.apply(null, arguments);
	});
	return proxy;
github Prior99 / hyrest / packages / hyrest / src / answers.ts View on Github external
export function badGateway(arg1: T | string | Wrapper, arg2?: string): T {
    return answer(HTTP.BAD_GATEWAY, arg1, arg2);
}