Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}, null);
if (response.statusCode !== 503)
break;
debug('Rate limiter kicked in, slowing down...');
await RateLimiter.sleep(500);
} while (true);
switch (response.statusCode) {
case HttpStatus.OK:
return response.body;
case HttpStatus.BAD_REQUEST:
case HttpStatus.NOT_FOUND:
throw new Error(`Got response status ${response.statusCode}: ${HttpStatus.getStatusText(response.statusCode)}`);
case HttpStatus.SERVICE_UNAVAILABLE: // 503
default:
const msg = `Got response status ${response.statusCode} on attempt #${attempt} (${HttpStatus.getStatusText(response.statusCode)})`;
debug(msg);
if (attempt < retries) {
return this.restGet(relUrl, query, attempt + 1);
} else
throw new Error(msg);
}
}
export function serviceUnavailable(arg1: T | string | Wrapper, arg2?: string): T {
return answer(HTTP.SERVICE_UNAVAILABLE, arg1, arg2);
}
router.get('/getChannelsByTopic', (clientRequest: any, serverResponse: any) => {
if (this.initialized) {
return getChannelsByTopic(clientRequest, serverResponse, this.dataAccess, this.logger);
} else {
return serverResponse.status(httpStatus.SERVICE_UNAVAILABLE).send(NOT_INITIALIZED_MESSAGE);
}
});
let isAuth = await compare(res.value.password.trim(), dbuser.password);
if (isAuth) {
let obj = await generateTokenObject(res.value);
try {
await updateUser(dbuser._id || dbuser.email);
ctx.body = {
status: HttpStatus.OK,
message: {
expires_in: obj.expires_in,
token: obj.token
}
};
} catch (err) {
throw new ApiAccessBoundleError(
HttpStatus.SERVICE_UNAVAILABLE, err.message
);
}
} else {
throw new ApiAccessBoundleError(
HttpStatus.FORBIDDEN, 'Invalid credentials'
);
}
} else {
throw new ApiAccessBoundleError(
HttpStatus.NOT_FOUND, 'User not found'
);
}
} else {
throw new ApiAccessBoundleError(
HttpStatus.BAD_REQUEST, res.error.message
);
return function(req,res,next){
var options = _.extend({}, configuration, overrides);
var pgtPathname = pgtPath(options);
if (!options.host && !options.hostname) throw new Error('no CAS host specified');
if (options.pgtFn && !options.pgtUrl) throw new Error('pgtUrl must be specified for obtaining proxy tickets');
if (!req.session){
res.send(HttpStatus.SERVICE_UNAVAILABLE);
return;
}
var url = parseUrl(req.url, true);
var ticket = (url.query && url.query.ticket) ? url.query.ticket : null;
options.query = options.query || {};
options.query.service = origin(req);
options.query.ticket = ticket;
options.pathname = options.paths.serviceValidate;
if (options.pgtUrl || options.query.pgtUrl)
options.query.pgtUrl = pgtPathname ? req.protocol + '://' + req.get('host') + pgtPathname : options.pgtUrl;
if (pgtPathname && req.path === pgtPathname && req.method === 'GET') {
if (!req.query.pgtIou || !req.query.pgtId) return res.send(HttpStatus.OK);
router.post('/connect', withAuthenticated, withConnection, async ctx => {
const state = store.getState()
const { connection } = ctx
if (state.isIrcClientConnected[connection.id]) {
ctx.body = { error: 'Already connected to IRC!' }
ctx.status = HttpStatus.SERVICE_UNAVAILABLE
return
}
const nextConnection = await updateConnection(
{ id: connection.id },
{ autoConnect: true },
)
store.dispatch({
type: 'SYNC_POSTGRES',
payload: {
table: 'connections',
change: { next: nextConnection },
},
})
connect(nextConnection)