MCPcopy Index your code
hub / github.com/parse-community/parse-server / constructor

Method constructor

src/ParseServer.ts:68–144  ·  view source on GitHub ↗

* @constructor * @param {ParseServerOptions} options the parse server initialization options

(options: ParseServerOptions)

Source from the content-addressed store, hash-verified

66 * @param {ParseServerOptions} options the parse server initialization options
67 */
68 constructor(options: ParseServerOptions) {
69 // Scan for deprecated Parse Server options
70 Deprecator.scanParseServerOptions(options);
71
72 const interfaces = JSON.parse(JSON.stringify(OptionsDefinitions));
73
74 function getValidObject(root) {
75 const result = {};
76 for (const key in root) {
77 if (Object.prototype.hasOwnProperty.call(root[key], 'type')) {
78 if (root[key].type.endsWith('[]')) {
79 result[key] = [getValidObject(interfaces[root[key].type.slice(0, -2)])];
80 } else {
81 result[key] = getValidObject(interfaces[root[key].type]);
82 }
83 } else {
84 result[key] = '';
85 }
86 }
87 return result;
88 }
89
90 const optionsBlueprint = getValidObject(interfaces['ParseServerOptions']);
91
92 function validateKeyNames(original, ref, name = '') {
93 let result = [];
94 const prefix = name + (name !== '' ? '.' : '');
95 for (const key in original) {
96 if (!Object.prototype.hasOwnProperty.call(ref, key)) {
97 result.push(prefix + key);
98 } else {
99 if (ref[key] === '') { continue; }
100 let res = [];
101 if (Array.isArray(original[key]) && Array.isArray(ref[key])) {
102 const type = ref[key][0];
103 original[key].forEach((item, idx) => {
104 if (typeof item === 'object' && item !== null) {
105 res = res.concat(validateKeyNames(item, type, prefix + key + `[${idx}]`));
106 }
107 });
108 } else if (typeof original[key] === 'object' && typeof ref[key] === 'object') {
109 res = validateKeyNames(original[key], ref[key], prefix + key);
110 }
111 result = result.concat(res);
112 }
113 }
114 return result;
115 }
116
117 const diff = validateKeyNames(options, optionsBlueprint);
118 if (diff.length > 0) {
119 const logger = (logging as any).logger;
120 logger.error(`Invalid key(s) found in Parse Server configuration: ${diff.join(', ')}`);
121 }
122
123 // Set option defaults
124 injectDefaults(options);
125 const {

Callers

nothing calls this directly

Calls 6

setRegexTimeoutFunction · 0.90
injectDefaultsFunction · 0.85
errorMethod · 0.80
validateOptionsMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected