2021-07-07 05:38:56 -04:00
|
|
|
const Settings = require('@overleaf/settings')
|
2021-11-10 08:40:18 -05:00
|
|
|
const logger = require('@overleaf/logger')
|
2019-05-29 05:21:06 -04:00
|
|
|
|
2021-04-27 10:17:39 -04:00
|
|
|
function ensurePlansAreSetupCorrectly() {
|
|
|
|
Settings.plans.forEach(plan => {
|
2022-01-12 04:39:56 -05:00
|
|
|
if (
|
|
|
|
typeof plan.price_in_unit !== 'number' &&
|
|
|
|
typeof plan.price_in_cents !== 'number'
|
|
|
|
) {
|
2021-04-27 10:17:39 -04:00
|
|
|
logger.fatal({ plan }, 'missing price on plan')
|
|
|
|
process.exit(1)
|
|
|
|
}
|
2022-01-12 04:39:56 -05:00
|
|
|
if (plan.price) {
|
|
|
|
logger.fatal({ plan }, 'unclear price attribute on plan')
|
|
|
|
process.exit(1)
|
|
|
|
}
|
2021-04-27 10:17:39 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function findLocalPlanInSettings(planCode) {
|
2021-05-05 09:05:04 -04:00
|
|
|
for (const plan of Settings.plans) {
|
2021-04-27 10:17:39 -04:00
|
|
|
if (plan.planCode === planCode) {
|
|
|
|
return plan
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2021-04-27 10:17:39 -04:00
|
|
|
}
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
ensurePlansAreSetupCorrectly,
|
|
|
|
findLocalPlanInSettings,
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|