(context, paramName)
| 3 | import { createSanitizedError } from '../../Error'; |
| 4 | |
| 5 | const cloudConfig = async (context, paramName) => { |
| 6 | const { config, auth } = context; |
| 7 | |
| 8 | if (!auth.isMaster) { |
| 9 | throw createSanitizedError( |
| 10 | Parse.Error.OPERATION_FORBIDDEN, |
| 11 | 'Master Key is required to access GlobalConfig.' |
| 12 | ); |
| 13 | } |
| 14 | |
| 15 | const results = await config.database.find('_GlobalConfig', { objectId: '1' }, { limit: 1 }); |
| 16 | |
| 17 | if (results.length !== 1) { |
| 18 | return { value: null, isMasterKeyOnly: null }; |
| 19 | } |
| 20 | |
| 21 | const globalConfig = results[0]; |
| 22 | const params = globalConfig.params || {}; |
| 23 | const masterKeyOnly = globalConfig.masterKeyOnly || {}; |
| 24 | |
| 25 | if (params[paramName] !== undefined) { |
| 26 | return { value: params[paramName], isMasterKeyOnly: masterKeyOnly[paramName] ?? null }; |
| 27 | } |
| 28 | |
| 29 | return { value: null, isMasterKeyOnly: null }; |
| 30 | }; |
| 31 | |
| 32 | const load = (parseGraphQLSchema) => { |
| 33 | if (!parseGraphQLSchema.cloudConfigType) { |
no test coverage detected