Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try {
cards = await creditCards.ls();
} catch (err) {
console.error(error(err.message));
return 1;
}
if (cards.sources.length === 0) {
console.error(error('You have no credit cards to choose from'));
return 0;
}
let cardId = args[0];
if (cardId === undefined) {
const elapsed = ms(new Date() - start);
const message = `Selecting a new default payment card for ${chalk.bold(
contextName
)} ${chalk.gray(`[${elapsed}]`)}`;
const choices = buildInquirerChoices(cards);
cardId = await listInput({
message,
choices,
separator: true,
abort: 'end'
});
}
// Check if the provided cardId (in case the user
// typed `now billing set-default `) is valid
if (cardId) {
async onStart() {
this.locker = new RedLock([this.uw.redis]);
const current = await this.getCurrentEntry();
if (current && this.timeout === null) {
// Restart the advance timer after a server restart, if a track was
// playing before the server restarted.
const duration = (current.media.end - current.media.start) * ms('1 second');
const endTime = Number(current.playedAt) + duration;
if (endTime > Date.now()) {
this.timeout = setTimeout(
() => this.advance(),
endTime - Date.now(),
);
} else {
this.advance();
}
}
}
hasuraUrl: process.env.HASURA_URL as string,
mailApiKey: process.env.SENDGRID_API_KEY as string,
mailAddress: 'noreply@nusmods.com',
// Passcode for verifying accounts
passcode: {
verifyTimeout: ms('15m'),
verifyLimit: 20,
requestLimitResetTimeout: ms('5m'),
requestLimit: 20,
},
// Access Token for obtaining information (aka Hasura Token)
accessToken: {
nameSpace: hasuraConfig.claims_namespace,
secretKey: hasuraConfig.key,
secretAlgorithm: hasuraConfig.type,
lifeTime: ms('1d'),
},
// Refresh Token for obtaining Access Token (aka Long Lived Token)
refreshToken: {
secretKey: hasuraConfig.key,
secretAlgorithm: hasuraConfig.type,
lifeTime: ms('90d'),
},
};
export default config;
async function stopService(service: Service) {
const { name } = services[service];
const info = await getContainerInfo(name);
if (!info) return;
const startTime = Date.now();
signale.pending(`stopping service ${service}`);
await dockerStop(name);
signale.success(`stopped service ${service}, took ${ms(Date.now() - startTime)}`);
}
Object.keys(deployment.scale).map(dc => chalk.bold(dc))
)}`
);
const verifyStamp = stamp();
const verifyDCsGenerator = getVerifyDCsGenerator(
output,
now,
deployment,
eventsStream
);
for await (const _dcOrEvent of verifyDCsGenerator) {
const dcOrEvent = _dcOrEvent as any;
if (dcOrEvent instanceof VerifyScaleTimeout) {
output.error(
`Instance verification timed out (${ms(
dcOrEvent.meta.timeout
)})`
);
output.log(
'Read more: https://err.sh/now/verification-timeout'
);
await exit(1);
} else if (Array.isArray(dcOrEvent)) {
const [dc, instances] = dcOrEvent;
output.log(
`${chalk.cyan(chars.tick)} Scaled ${plural(
'instance',
instances,
true
)} in ${chalk.bold(dc)} ${verifyStamp()}`
);
function formatExpirationDate(date: Date) {
const diff = date.getTime() - Date.now();
return diff < 0
? chalk.gray(`${ms(-diff)} ago`)
: chalk.gray(`in ${ms(diff)}`);
}
return (val) => {
const endTime = new Date();
const duration = ms(endTime - startTime);
logTime(endTime, `Finished '${cyan(name)}' (${magenta(duration)})`);
return val;
};
}
`);
}
export default class SocketServer {
connections = [];
options = {
onError: (socket, err) => {
throw err;
},
timeout: 30,
};
pinger = setInterval(() => {
this.ping();
}, ms('10 seconds'));
/**
* Create a socket server.
*
* @param {Uwave} uw üWave Core instance.
* @param {object} options Socket server options.
* @param {number} options.timeout Time in seconds to wait for disconnected
* users to reconnect before removing them.
*/
constructor(uw, options = {}) {
if (!uw || !('mongo' in uw)) {
throw new TypeError('Expected a u-wave-core instance in the first parameter. If you are '
+ 'developing, you may have to upgrade your u-wave-* modules.');
}
if (!options.server && !options.port) {
function formatExpirationDate(date) {
const diff = date - Date.now()
return diff < 0
? chalk.gray(ms(-diff) + ' ago')
: chalk.gray('in ' + ms(diff))
}