Merge pull request #1947 from overleaf/ta-cleanup-guard-1

Remove __guard__ Function Used to Access Settings

GitOrigin-RevId: 15e3749990a9fc68f8d344390b1bf0d09d839106
This commit is contained in:
Timothée Alby 2019-07-15 15:09:04 +02:00 committed by sharelatex
parent 238e2b2565
commit 109585d20c
29 changed files with 119 additions and 401 deletions

View file

@ -6,7 +6,6 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
@ -43,14 +42,7 @@ if (Settings.catchErrors) {
logger.error({ err: error }, 'uncaughtException')
)
}
const port =
Settings.port ||
__guard__(
Settings.internal != null ? Settings.internal.web : undefined,
x => x.port
) ||
3000
const port = Settings.port || Settings.internal.web.port || 3000
const host = Settings.internal.web.host || 'localhost'
if (!module.parent) {
// Called directly
@ -69,9 +61,3 @@ if (!module.parent) {
}
module.exports = Server.server
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}

View file

@ -9,7 +9,6 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__
* DS202: Simplify dynamic range loops
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
@ -25,13 +24,8 @@ const Errors = require('../Errors/Errors')
const UserGetter = require('../User/UserGetter')
const V1Handler = require('../V1/V1Handler')
const BCRYPT_ROUNDS =
__guard__(
Settings != null ? Settings.security : undefined,
x => x.bcryptRounds
) || 12
const BCRYPT_MINOR_VERSION =
(Settings != null ? Settings.security.bcryptMinorVersion : undefined) || 'a'
const BCRYPT_ROUNDS = Settings.security.bcryptRounds || 12
const BCRYPT_MINOR_VERSION = Settings.security.bcryptMinorVersion || 'a'
const _checkWriteResult = function(result, callback) {
// for MongoDB
@ -107,24 +101,17 @@ module.exports = AuthenticationManager = {
return { message: 'password not set' }
}
const allowAnyChars =
(Settings.passwordStrengthOptions != null
? Settings.passwordStrengthOptions.allowAnyChars
: undefined) === true
const min =
__guard__(
Settings.passwordStrengthOptions != null
? Settings.passwordStrengthOptions.length
: undefined,
x1 => x1.min
) || 6
let max =
__guard__(
Settings.passwordStrengthOptions != null
? Settings.passwordStrengthOptions.length
: undefined,
x2 => x2.max
) || 72
let allowAnyChars, min, max
if (Settings.passwordStrengthOptions) {
allowAnyChars = Settings.passwordStrengthOptions.allowAnyChars === true
if (Settings.passwordStrengthOptions.length) {
min = Settings.passwordStrengthOptions.length.min
max = Settings.passwordStrengthOptions.length.max
}
}
allowAnyChars = !!allowAnyChars
min = min || 6
max = max || 72
// we don't support passwords > 72 characters in length, because bcrypt truncates them
if (max > 72) {
@ -196,12 +183,7 @@ module.exports = AuthenticationManager = {
if (callback == null) {
callback = function(error) {}
}
if (
__guard__(
Settings != null ? Settings.security : undefined,
x1 => x1.disableBcryptRoundsUpgrades
)
) {
if (Settings.security.disableBcryptRoundsUpgrades) {
return callback()
}
// check current number of rounds and rehash if necessary
@ -274,34 +256,20 @@ module.exports = AuthenticationManager = {
},
_passwordCharactersAreValid(password) {
const digits =
__guard__(
Settings.passwordStrengthOptions != null
? Settings.passwordStrengthOptions.chars
: undefined,
x1 => x1.digits
) || '1234567890'
const letters =
__guard__(
Settings.passwordStrengthOptions != null
? Settings.passwordStrengthOptions.chars
: undefined,
x2 => x2.letters
) || 'abcdefghijklmnopqrstuvwxyz'
const letters_up =
__guard__(
Settings.passwordStrengthOptions != null
? Settings.passwordStrengthOptions.chars
: undefined,
x3 => x3.letters_up
) || 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
const symbols =
__guard__(
Settings.passwordStrengthOptions != null
? Settings.passwordStrengthOptions.chars
: undefined,
x4 => x4.symbols
) || '@#$%^&*()-_=+[]{};:<>/?!£€.,'
let digits, letters, letters_up, symbols
if (
Settings.passwordStrengthOptions &&
Settings.passwordStrengthOptions.chars
) {
digits = Settings.passwordStrengthOptions.chars.digits
letters = Settings.passwordStrengthOptions.chars.letters
letters_up = Settings.passwordStrengthOptions.chars.letters_up
symbols = Settings.passwordStrengthOptions.chars.symbols
}
digits = digits || '1234567890'
letters = letters || 'abcdefghijklmnopqrstuvwxyz'
letters_up = letters_up || 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
symbols = symbols || '@#$%^&*()-_=+[]{};:<>/?!£€.,'
for (
let charIndex = 0, end = password.length - 1, asc = end >= 0;
@ -320,9 +288,3 @@ module.exports = AuthenticationManager = {
return true
}
}
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}

View file

@ -56,22 +56,14 @@ module.exports = BlogController = {
data = data.trim()
try {
data = JSON.parse(data)
if (
__guard__(
settings.cdn != null ? settings.cdn.web : undefined,
x => x.host
) != null
) {
if (settings.cdn && settings.cdn.web && settings.cdn.web.host) {
if (data != null) {
data.content = __guard__(
data != null ? data.content : undefined,
x1 =>
x1.replace(
/src="(\/[^"]+)"/g,
`src='${__guard__(
settings.cdn != null ? settings.cdn.web : undefined,
x2 => x2.host
)}$1'`
`src='${settings.cdn.web.host}$1'`
)
)
}

View file

@ -9,7 +9,6 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
@ -84,15 +83,4 @@ var _setV1AsHostIfRelativeURL = urlString =>
// As it only applies if the second argument is not absolute, we can use it to transform relative URLs into
// absolute ones using v1 as the host. If the URL is absolute (e.g. a filepicker one), then the base
// argument is just ignored
url.resolve(
__guard__(
__guard__(settings != null ? settings.apis : undefined, x1 => x1.v1),
x => x.url
),
urlString
)
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}
url.resolve(settings.apis.v1.url, urlString)

View file

@ -245,14 +245,7 @@ module.exports = CompileManager = {
endpointName: 'auto_compile',
timeInterval: 20,
subjectName: compileGroup,
throttle:
__guard__(
__guard__(
Settings != null ? Settings.rateLimit : undefined,
x1 => x1.autoCompile
),
x => x[compileGroup]
) || 25
throttle: Settings.rateLimit.autoCompile[compileGroup] || 25
}
return rateLimiter.addCount(opts, function(err, canCompile) {
if (err != null) {

View file

@ -7,7 +7,6 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
@ -518,15 +517,11 @@ module.exports = {
opts.siteUrl = settings.siteUrl
opts.body = template.compiledTemplate(opts)
if (
__guard__(
settings.email != null ? settings.email.templates : undefined,
x => x.customFooter
) != null
settings.email &&
settings.email.template &&
settings.email.template.customFooter
) {
opts.body += __guard__(
settings.email != null ? settings.email.templates : undefined,
x1 => x1.customFooter
)
opts.body += settings.email.template.customFooter
}
return {
subject: template.subject(opts),
@ -538,11 +533,6 @@ module.exports = {
}
}
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}
function __guardMethod__(obj, methodName, transform) {
if (
typeof obj !== 'undefined' &&

View file

@ -10,7 +10,6 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
@ -41,86 +40,41 @@ let client = {
return callback()
}
}
if (
__guard__(
__guard__(
Settings != null ? Settings.email : undefined,
x1 => x1.parameters
),
x => x.AWSAccessKeyID
) != null ||
__guard__(Settings != null ? Settings.email : undefined, x2 => x2.driver) ===
'ses'
) {
logger.log('using aws ses for email')
nm_client = nodemailer.createTransport(
sesTransport(Settings.email.parameters)
)
} else if (
__guard__(
__guard__(
Settings != null ? Settings.email : undefined,
x4 => x4.parameters
),
x3 => x3.sendgridApiKey
) != null
) {
logger.log('using sendgrid for email')
nm_client = nodemailer.createTransport(
sgTransport({
auth: {
api_key: __guard__(
__guard__(
Settings != null ? Settings.email : undefined,
x6 => x6.parameters
),
x5 => x5.sendgridApiKey
)
}
})
)
} else if (
__guard__(
__guard__(
Settings != null ? Settings.email : undefined,
x8 => x8.parameters
),
x7 => x7.MandrillApiKey
) != null
) {
logger.log('using mandril for email')
nm_client = nodemailer.createTransport(
mandrillTransport({
auth: {
apiKey: __guard__(
__guard__(
Settings != null ? Settings.email : undefined,
x10 => x10.parameters
),
x9 => x9.MandrillApiKey
)
}
})
)
} else if (
__guard__(
Settings != null ? Settings.email : undefined,
x11 => x11.parameters
) != null
) {
logger.log('using smtp for email')
const smtp = _.pick(
__guard__(
Settings != null ? Settings.email : undefined,
x12 => x12.parameters
),
'host',
'port',
'secure',
'auth',
'ignoreTLS'
)
nm_client = nodemailer.createTransport(smtp)
if (Settings.email && Settings.email.parameters) {
let emailParameters = Settings.email.parameters
if (emailParameters.AWSAccessKeyID || Settings.email.driver === 'ses') {
logger.log('using aws ses for email')
nm_client = nodemailer.createTransport(sesTransport(emailParameters))
} else if (emailParameters.sendgridApiKey) {
logger.log('using sendgrid for email')
nm_client = nodemailer.createTransport(
sgTransport({
auth: {
api_key: emailParameters.sendgridApiKey
}
})
)
} else if (emailParameters.MandrillApiKey) {
logger.log('using mandril for email')
nm_client = nodemailer.createTransport(
mandrillTransport({
auth: {
apiKey: emailParameters.MandrillApiKey
}
})
)
} else {
logger.log('using smtp for email')
const smtp = _.pick(
emailParameters,
'host',
'port',
'secure',
'auth',
'ignoreTLS'
)
nm_client = nodemailer.createTransport(smtp)
}
} else {
logger.warn(
'Email transport and/or parameters not defined. No emails will be sent.'
@ -200,9 +154,3 @@ module.exports = {
})
}
}
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}

View file

@ -6,7 +6,6 @@
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS103: Rewrite code to no longer use __guard__
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
@ -16,12 +15,7 @@ const Settings = require('settings-sharelatex')
module.exports = UrlHelper = {
wrapUrlWithProxy(url) {
// TODO: Consider what to do for Community and Enterprise edition?
if (
__guard__(
Settings.apis != null ? Settings.apis.linkedUrlProxy : undefined,
x => x.url
) == null
) {
if (!Settings.apis.linkedUrlProxy.url) {
throw new Error('no linked url proxy configured')
}
return `${Settings.apis.linkedUrlProxy.url}?url=${encodeURIComponent(url)}`
@ -34,8 +28,3 @@ module.exports = UrlHelper = {
return url
}
}
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}

View file

@ -8,7 +8,6 @@
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
@ -150,12 +149,7 @@ var makeAffiliationRequest = function(requestOptions, callback) {
if (callback == null) {
callback = function(error) {}
}
if (
!__guard__(
__guard__(settings != null ? settings.apis : undefined, x1 => x1.v1),
x => x.url
)
) {
if (!settings.apis.v1.url) {
return callback(null)
} // service is not configured
if (!requestOptions.extraSuccessStatusCodes) {
@ -214,9 +208,3 @@ var makeAffiliationRequest = function(requestOptions, callback) {
logger
)
)
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}

View file

@ -7,7 +7,6 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
@ -119,15 +118,7 @@ module.exports = {
if (callback == null) {
callback = function() {}
}
if (
!__guard__(
__guard__(
settings != null ? settings.apis : undefined,
x1 => x1.v1
),
x => x.url
)
) {
if (!settings.apis.v1.url) {
return null
} // service is not configured
return request(
@ -179,9 +170,3 @@ module.exports = {
}
}
}
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}

View file

@ -427,14 +427,9 @@ module.exports = ProjectController = {
}
if (
__guard__(
Settings != null ? Settings.algolia : undefined,
x => x.app_id
) != null &&
__guard__(
Settings != null ? Settings.algolia : undefined,
x1 => x1.read_only_api_key
) != null
Settings.algolia &&
Settings.algolia.app_id &&
Settings.algolia.read_only_api_key
) {
viewModel.showUserDetailsArea = true
viewModel.algolia_api_key = Settings.algolia.read_only_api_key

View file

@ -9,7 +9,6 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
@ -104,12 +103,7 @@ const ProjectCreationHandler = {
Object.assign(project, attributes)
if (
__guard__(
Settings.apis != null ? Settings.apis.project_history : undefined,
x => x.displayHistoryForNewProjects
)
) {
if (Settings.apis.project_history.displayHistoryForNewProjects) {
project.overleaf.history.display = true
}
if (Settings.currentImageName != null) {
@ -338,12 +332,6 @@ metrics.timeAsyncMethod(
logger
)
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}
const promises = {
createBlankProject: promisify(ProjectCreationHandler.createBlankProject)
}

View file

@ -25,12 +25,7 @@ const Async = require('async')
const oneMinInMs = 60 * 1000
const fiveMinsInMs = oneMinInMs * 5
if (
__guard__(
settings.apis != null ? settings.apis.references : undefined,
x => x.url
) == null
) {
if (!settings.apis.references.url) {
logger.log('references search not enabled')
}
@ -149,12 +144,7 @@ module.exports = ReferencesHandler = {
},
_doIndexOperation(projectId, project, docIds, fileIds, callback) {
if (
__guard__(
settings.apis != null ? settings.apis.references : undefined,
x1 => x1.url
) == null
) {
if (!settings.apis.references.url) {
return callback()
}
return ReferencesHandler._isFullIndex(project, function(err, isFullIndex) {

View file

@ -26,11 +26,7 @@ const logger = require('logger-sharelatex')
const Async = require('async')
module.exports = RecurlyWrapper = {
apiUrl:
__guard__(
Settings.apis != null ? Settings.apis.recurly : undefined,
x => x.url
) || 'https://api.recurly.com/v2',
apiUrl: Settings.apis.recurly.url || 'https://api.recurly.com/v2',
_paypal: {
checkAccountExists(cache, next) {

View file

@ -33,10 +33,7 @@ const buildBillingDetails = function(recurlySubscription) {
recurlySubscription != null ? recurlySubscription.account : undefined,
x => x.hosted_login_token
)
const recurlySubdomain = __guard__(
__guard__(Settings != null ? Settings.apis : undefined, x2 => x2.recurly),
x1 => x1.subdomain
)
const recurlySubdomain = Settings.apis.recurly.subdomain
if (hostedLoginToken != null && recurlySubdomain != null) {
return [
'https://',

View file

@ -154,7 +154,7 @@ module.exports = V1SubscriptionManager = {
if (callback == null) {
callback = function(err, body, v1Id) {}
}
if (!__guard__(settings != null ? settings.apis : undefined, x => x.v1)) {
if (!settings.apis.v1.url) {
return callback(null, null)
}

View file

@ -126,15 +126,13 @@ module.exports = UserPagesController = {
delete req.session.ssoError
}
logger.log({ user: user_id }, 'loading settings page')
const shouldAllowEditingDetails =
!__guard__(
Settings != null ? Settings.ldap : undefined,
x => x.updateUserDetailsOnLogin
) &&
!__guard__(
Settings != null ? Settings.saml : undefined,
x1 => x1.updateUserDetailsOnLogin
)
let shouldAllowEditingDetails = true
if (Settings.ldap && Settings.ldap.updateUserDetailsOnLogin) {
shouldAllowEditingDetails = false
}
if (Settings.saml && Settings.saml.updateUserDetailsOnLogin) {
shouldAllowEditingDetails = false
}
const oauthProviders = Settings.oauthProviders || {}
return UserGetter.getUser(user_id, function(err, user) {

View file

@ -10,7 +10,6 @@
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
@ -193,12 +192,7 @@ module.exports = UserUpdater = {
},
updateEmailAddressInV1(userId, newEmail, callback) {
if (
__guard__(
Settings.apis != null ? Settings.apis.v1 : undefined,
x => x.url
) == null
) {
if (!Settings.apis.v1.url) {
return callback()
}
return UserGetter.getUser(userId, { 'overleaf.id': 1, emails: 1 }, function(
@ -331,9 +325,3 @@ module.exports = UserUpdater = {
].map(method =>
metrics.timeAsyncMethod(UserUpdater, method, 'mongo.UserUpdater', logger)
)
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}

View file

@ -7,7 +7,6 @@
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
@ -18,19 +17,10 @@ const Errors = require('../Errors/Errors')
// TODO: check what happens when these settings aren't defined
const DEFAULT_V1_PARAMS = {
baseUrl: __guard__(
__guard__(settings != null ? settings.apis : undefined, x1 => x1.v1),
x => x.url
),
baseUrl: settings.apis.v1.url,
auth: {
user: __guard__(
__guard__(settings != null ? settings.apis : undefined, x3 => x3.v1),
x2 => x2.user
),
pass: __guard__(
__guard__(settings != null ? settings.apis : undefined, x5 => x5.v1),
x4 => x4.pass
)
user: settings.apis.v1.user,
pass: settings.apis.v1.pass
},
json: true,
timeout: 30 * 1000
@ -39,10 +29,7 @@ const DEFAULT_V1_PARAMS = {
const v1Request = request.defaults(DEFAULT_V1_PARAMS)
const DEFAULT_V1_OAUTH_PARAMS = {
baseUrl: __guard__(
__guard__(settings != null ? settings.apis : undefined, x7 => x7.v1),
x6 => x6.url
),
baseUrl: settings.apis.v1.url,
json: true,
timeout: 30 * 1000
}
@ -98,9 +85,3 @@ module.exports = V1Api = {
}
}
}
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}

View file

@ -94,14 +94,10 @@ if (!Settings.useMinifiedJs) {
}
}
const cdnAvailable =
__guard__(Settings.cdn != null ? Settings.cdn.web : undefined, x => x.host) !=
null
const cdnAvailable = Settings.cdn && Settings.cdn.web && !!Settings.cdn.web.host
const darkCdnAvailable =
__guard__(
Settings.cdn != null ? Settings.cdn.web : undefined,
x1 => x1.darkHost
) != null
Settings.cdn && Settings.cdn.web && !!Settings.cdn.web.darkHost
module.exports = function(app, webRouter, privateApiRouter, publicApiRouter) {
webRouter.use(function(req, res, next) {
@ -167,15 +163,9 @@ module.exports = function(app, webRouter, privateApiRouter, publicApiRouter) {
const isLive = !isDark && !isSmoke
if (cdnAvailable && isLive && !cdnBlocked) {
staticFilesBase = __guard__(
Settings.cdn != null ? Settings.cdn.web : undefined,
x6 => x6.host
)
staticFilesBase = Settings.cdn.web.host
} else if (darkCdnAvailable && isDark) {
staticFilesBase = __guard__(
Settings.cdn != null ? Settings.cdn.web : undefined,
x7 => x7.darkHost
)
staticFilesBase = Settings.cdn.web.darkHost
} else {
staticFilesBase = ''
}
@ -428,10 +418,7 @@ module.exports = function(app, webRouter, privateApiRouter, publicApiRouter) {
delete req.session.justLoggedIn
}
}
res.locals.gaToken = __guard__(
Settings.analytics != null ? Settings.analytics.ga : undefined,
x2 => x2.token
)
res.locals.gaToken = Settings.analytics && Settings.analytics.ga.token
res.locals.tenderUrl = Settings.tenderUrl
res.locals.sentrySrc =
Settings.sentry != null ? Settings.sentry.src : undefined

View file

@ -6,7 +6,6 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
@ -44,15 +43,7 @@ module.exports = Features = {
case 'view-templates':
return Settings.overleaf == null
case 'affiliations':
return (
__guard__(
__guard__(
Settings != null ? Settings.apis : undefined,
x1 => x1.v1
),
x => x.url
) != null
)
return !!Settings.apis.v1.url
case 'redirect-sl':
return Settings.redirectToV2 != null
default:
@ -60,9 +51,3 @@ module.exports = Features = {
}
}
}
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}

View file

@ -499,7 +499,7 @@ module.exports = settings =
# url: "/templates/all"
#}]
rateLimits:
rateLimit:
autoCompile:
everyone: process.env['RATE_LIMIT_AUTO_COMPILE_EVERYONE'] or 100
standard: process.env['RATE_LIMIT_AUTO_COMPILE_STANDARD'] or 25

View file

@ -8,7 +8,6 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS103: Rewrite code to no longer use __guard__
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
@ -21,15 +20,8 @@ if (Object.prototype.should == null) {
}
const { expect } = chai
const Settings = require('settings-sharelatex')
const ownPort =
__guard__(
Settings.internal != null ? Settings.internal.web : undefined,
x => x.port
) ||
Settings.port ||
3000
const port =
(Settings.web != null ? Settings.web.web_router_port : undefined) || ownPort // send requests to web router if this is the api process
let ownPort = Settings.internal.web.port || Settings.port || 3000
const port = Settings.web.web_router_port || ownPort // send requests to web router if this is the api process
const cookeFilePath = `/tmp/smoke-test-cookie-${ownPort}-to-${port}.txt`
const buildUrl = path =>
` -b ${cookeFilePath} --resolve 'smoke${
@ -227,9 +219,3 @@ curl -H "X-Forwarded-Proto: https" -v ${buildUrl('project')}\
})
})
})
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null
? transform(value)
: undefined
}

View file

@ -35,7 +35,8 @@ describe('AuthorizationManager', function() {
'../Errors/Errors': Errors,
'../TokenAccess/TokenAccessHandler': (this.TokenAccessHandler = {
isValidToken: sinon.stub().callsArgWith(2, null, false, false)
})
}),
'settings-sharelatex': { passwordStrengthOptions: {} }
}
})
this.user_id = 'user-id-1'

View file

@ -28,7 +28,8 @@ describe('BlogController', function() {
blog: {
url: 'http://blog.sharelatex.env'
}
}
},
cdn: { web: { host: null } }
}
this.request = { get: sinon.stub() }
this.ErrorController = {}

View file

@ -32,7 +32,8 @@ describe('CompileManager', function() {
},
requires: {
'settings-sharelatex': (this.settings = {
redis: { web: { host: 'localhost', port: 42 } }
redis: { web: { host: 'localhost', port: 42 } },
rateLimit: { autoCompile: {} }
}),
'../../infrastructure/RedisWrapper': {
client: () => {

View file

@ -79,7 +79,8 @@ describe('InstitutionsAPI', function() {
})
it('handle empty response', function(done) {
this.settings.apis = null
this.settings.apis.v1.url = ''
return this.InstitutionsAPI.getInstitutionAffiliations(
this.institutionId,
(err, body) => {
@ -162,7 +163,7 @@ describe('InstitutionsAPI', function() {
})
it('handle empty response', function(done) {
this.settings.apis = null
this.settings.apis.v1.url = ''
return this.InstitutionsAPI.getUserAffiliations(
this.stubbedUser._id,
(err, body) => {

View file

@ -37,7 +37,8 @@ describe('ProjectController', function() {
url: 'chat.com'
}
},
siteUrl: 'mysite.com'
siteUrl: 'mysite.com',
algolia: {}
}
this.brandVariationDetails = {
id: '12',

View file

@ -39,7 +39,8 @@ describe('V1SubscriptionManager', function() {
'settings-sharelatex': (this.Settings = {
apis: {
v1: {
host: (this.host = 'http://overleaf.example.com')
host: (this.host = 'http://overleaf.example.com'),
url: 'v1.url'
}
},
v1GrandfatheredFeaturesUidCutoff: 10,