Run Prettier JS (#6795)

This commit is contained in:
Diamond Lewis
2020-07-13 13:06:52 -05:00
committed by GitHub
parent ebb0727793
commit e6a6354b29
47 changed files with 313 additions and 329 deletions

82
package-lock.json generated
View File

@@ -47,11 +47,6 @@
"xss": "^1.0.6" "xss": "^1.0.6"
} }
}, },
"@ardatan/aggregate-error": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/@ardatan/aggregate-error/-/aggregate-error-0.0.1.tgz",
"integrity": "sha512-UQ9BequOTIavs0pTHLMwQwKQF8tTV1oezY/H2O9chA+JNPFZSua55xpU5dPSjAU9/jLJ1VwU+HJuTVN8u7S6Fg=="
},
"@babel/cli": { "@babel/cli": {
"version": "7.10.0", "version": "7.10.0",
"resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.10.0.tgz", "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.10.0.tgz",
@@ -1137,66 +1132,52 @@
} }
}, },
"@graphql-tools/delegate": { "@graphql-tools/delegate": {
"version": "6.0.12", "version": "6.0.1",
"resolved": "https://registry.npmjs.org/@graphql-tools/delegate/-/delegate-6.0.12.tgz", "resolved": "https://registry.npmjs.org/@graphql-tools/delegate/-/delegate-6.0.1.tgz",
"integrity": "sha512-52bac1Ct1s0c8aSTVCbnc5FI2LC+NqUFSs+5/mP1k5hIEW2GROGBeZdbRs2GQaHir1vKUYIyHzlZIIBMzOZ/gA==", "integrity": "sha512-eb6KyskEOTOe3cJtqQGwoyjSxWZKvARPoS7bUB1ZY7SzSAFvDUomee3ercLVk9PTNwv+BE2ePpsFyAZkBhF4Xg==",
"requires": { "requires": {
"@ardatan/aggregate-error": "0.0.1", "@graphql-tools/schema": "6.0.1",
"@graphql-tools/schema": "6.0.12", "@graphql-tools/utils": "6.0.1",
"@graphql-tools/utils": "6.0.12",
"tslib": "~2.0.0"
}
},
"@graphql-tools/merge": {
"version": "6.0.12",
"resolved": "https://registry.npmjs.org/@graphql-tools/merge/-/merge-6.0.12.tgz",
"integrity": "sha512-GGvdIoTad6PJk/d1omPlGQ25pCFWmjuGkARYZ71qWI/c4FEA8EdGoOoPz3shhaKXyLdRiu84S758z4ZtDQiYVw==",
"requires": {
"@graphql-tools/schema": "6.0.12",
"@graphql-tools/utils": "6.0.12",
"tslib": "~2.0.0" "tslib": "~2.0.0"
} }
}, },
"@graphql-tools/schema": { "@graphql-tools/schema": {
"version": "6.0.12", "version": "6.0.1",
"resolved": "https://registry.npmjs.org/@graphql-tools/schema/-/schema-6.0.12.tgz", "resolved": "https://registry.npmjs.org/@graphql-tools/schema/-/schema-6.0.1.tgz",
"integrity": "sha512-XUmKJ+ipENaxuXIX4GapsLAUl1dFQBUg+S4ZbgtKVlwrPhZJ9bkjIqnUHk3wg4S4VXqzLX97ol1e4g9N6XLkYg==", "integrity": "sha512-/X9Uji9BCulP5vx69pLD6TcmETRKl71qVAZbNUEURklpU3kty8zrCqs6gqO2nz4nEJzYRrXFTMf+zZ6L7Ae3ew==",
"requires": { "requires": {
"@graphql-tools/utils": "6.0.12", "@graphql-tools/utils": "6.0.1",
"tslib": "~2.0.0" "tslib": "~2.0.0"
} }
}, },
"@graphql-tools/stitch": { "@graphql-tools/stitch": {
"version": "6.0.12", "version": "6.0.1",
"resolved": "https://registry.npmjs.org/@graphql-tools/stitch/-/stitch-6.0.12.tgz", "resolved": "https://registry.npmjs.org/@graphql-tools/stitch/-/stitch-6.0.1.tgz",
"integrity": "sha512-I+9l5Ws30Fn3nx0CIDUDMGP0nhexMEJyzfQn1t9DuOTy2QHPQ5YpaZ8hxv6y5+X23EJBU9AebqvNSvWNEO6XJQ==", "integrity": "sha512-2zQEYHpzQ67A59W3bD+YB+jjpAT24UT5a7Gpu5V4+sBsLEQdT0rnkUUQR4YYj4TshRDEPDbv2LcjuPAX3+QMPg==",
"requires": { "requires": {
"@graphql-tools/delegate": "6.0.12", "@graphql-tools/delegate": "6.0.1",
"@graphql-tools/merge": "6.0.12", "@graphql-tools/schema": "6.0.1",
"@graphql-tools/schema": "6.0.12", "@graphql-tools/utils": "6.0.1",
"@graphql-tools/utils": "6.0.12", "@graphql-tools/wrap": "6.0.1",
"@graphql-tools/wrap": "6.0.12",
"tslib": "~2.0.0" "tslib": "~2.0.0"
} }
}, },
"@graphql-tools/utils": { "@graphql-tools/utils": {
"version": "6.0.12", "version": "6.0.1",
"resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-6.0.12.tgz", "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-6.0.1.tgz",
"integrity": "sha512-MuFSkxXCe2QoD5QJPJ/1WIm0YnBzzXpkq9d/XznVAWptHFRwtwIbZ1xcREjYquFvoZ7ddsjZfyvUN/5ulmHhhg==", "integrity": "sha512-HqqJFYFG464ydL6XgUkwmYJLO/VzCsD86Bl25AX7aCLabPpn4O/pwCKSKRFsGQZvZbrth+urkHpyRU82Iqw2RQ==",
"requires": { "requires": {
"@ardatan/aggregate-error": "0.0.1",
"camel-case": "4.1.1" "camel-case": "4.1.1"
} }
}, },
"@graphql-tools/wrap": { "@graphql-tools/wrap": {
"version": "6.0.12", "version": "6.0.1",
"resolved": "https://registry.npmjs.org/@graphql-tools/wrap/-/wrap-6.0.12.tgz", "resolved": "https://registry.npmjs.org/@graphql-tools/wrap/-/wrap-6.0.1.tgz",
"integrity": "sha512-x/t6004aNLzTbOFzZiau15fY2+TBy0wbFqP2du+I+yh8j6KmAU1YkPolBJ4bAI04WD3qcLNh7Rai+VhOxidOkw==", "integrity": "sha512-8D5TZalct+7yqXbkv6fdpLs81/60T3EjL1SP/xAjvRlKCy3nrGL31xLeJmch6sqH3yQvzhD9sISmkjs6xTNAqQ==",
"requires": { "requires": {
"@graphql-tools/delegate": "6.0.12", "@graphql-tools/delegate": "6.0.1",
"@graphql-tools/schema": "6.0.12", "@graphql-tools/schema": "6.0.1",
"@graphql-tools/utils": "6.0.12", "@graphql-tools/utils": "6.0.1",
"aggregate-error": "3.0.1",
"tslib": "~2.0.0" "tslib": "~2.0.0"
} }
}, },
@@ -1786,6 +1767,7 @@
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.0.1.tgz", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.0.1.tgz",
"integrity": "sha512-quoaXsZ9/BLNae5yiNoUz+Nhkwz83GhWwtYFglcjEQB2NDHCIpApbqXxIFnm4Pq/Nvhrsq5sYJFyohrrxnTGAA==", "integrity": "sha512-quoaXsZ9/BLNae5yiNoUz+Nhkwz83GhWwtYFglcjEQB2NDHCIpApbqXxIFnm4Pq/Nvhrsq5sYJFyohrrxnTGAA==",
"dev": true,
"requires": { "requires": {
"clean-stack": "^2.0.0", "clean-stack": "^2.0.0",
"indent-string": "^4.0.0" "indent-string": "^4.0.0"
@@ -3065,7 +3047,8 @@
"clean-stack": { "clean-stack": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz",
"integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==" "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==",
"dev": true
}, },
"cli-color": { "cli-color": {
"version": "0.3.2", "version": "0.3.2",
@@ -5491,9 +5474,9 @@
} }
}, },
"graphql-tag": { "graphql-tag": {
"version": "2.10.3", "version": "2.10.1",
"resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.10.3.tgz", "resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.10.1.tgz",
"integrity": "sha512-4FOv3ZKfA4WdOKJeHdz6B3F/vxBLSgmBcGeAFPf4n1F64ltJUvOOerNj0rsJxONQGdhUMynQIvd6LzB+1J5oKA==" "integrity": "sha512-jApXqWBzNXQ8jYa/HLkZJaVw9jgwNqZkywa2zfFn16Iv1Zb7ELNHkJaXHR7Quvd5SIGsy6Ny7SUKATgnu05uEg=="
}, },
"graphql-tools": { "graphql-tools": {
"version": "4.0.8", "version": "4.0.8",
@@ -5864,7 +5847,8 @@
"indent-string": { "indent-string": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz",
"integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==" "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==",
"dev": true
}, },
"inflection": { "inflection": {
"version": "1.12.0", "version": "1.12.0",

View File

@@ -20,8 +20,8 @@
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"dependencies": { "dependencies": {
"@apollographql/graphql-playground-html": "1.6.26", "@apollographql/graphql-playground-html": "1.6.26",
"@graphql-tools/stitch": "^6.0.1", "@graphql-tools/stitch": "6.0.1",
"@graphql-tools/utils": "^6.0.1", "@graphql-tools/utils": "6.0.1",
"@parse/fs-files-adapter": "1.0.1", "@parse/fs-files-adapter": "1.0.1",
"@parse/push-adapter": "3.2.0", "@parse/push-adapter": "3.2.0",
"@parse/s3-files-adapter": "1.4.0", "@parse/s3-files-adapter": "1.4.0",
@@ -36,7 +36,7 @@
"follow-redirects": "1.12.1", "follow-redirects": "1.12.1",
"graphql": "15.1.0", "graphql": "15.1.0",
"graphql-list-fields": "2.0.2", "graphql-list-fields": "2.0.2",
"graphql-relay": "^0.6.0", "graphql-relay": "0.6.0",
"graphql-upload": "11.0.0", "graphql-upload": "11.0.0",
"intersect": "1.0.1", "intersect": "1.0.1",
"jsonwebtoken": "8.5.1", "jsonwebtoken": "8.5.1",
@@ -48,7 +48,7 @@
"mongodb": "3.5.9", "mongodb": "3.5.9",
"parse": "2.14.0", "parse": "2.14.0",
"pg-promise": "10.5.7", "pg-promise": "10.5.7",
"pluralize": "^8.0.0", "pluralize": "8.0.0",
"redis": "3.0.2", "redis": "3.0.2",
"semver": "7.3.2", "semver": "7.3.2",
"subscriptions-transport-ws": "0.9.16", "subscriptions-transport-ws": "0.9.16",
@@ -80,7 +80,7 @@
"eslint-plugin-flowtype": "5.1.3", "eslint-plugin-flowtype": "5.1.3",
"flow-bin": "0.119.1", "flow-bin": "0.119.1",
"form-data": "3.0.0", "form-data": "3.0.0",
"graphql-tag": "^2.10.1", "graphql-tag": "2.10.1",
"husky": "4.2.5", "husky": "4.2.5",
"jasmine": "3.5.0", "jasmine": "3.5.0",
"jsdoc": "3.6.3", "jsdoc": "3.6.3",

View File

@@ -1,8 +1,8 @@
module.exports = { module.exports = {
validateAppId: function() { validateAppId: function () {
return Promise.resolve(); return Promise.resolve();
}, },
validateAuthData: function(authData) { validateAuthData: function (authData) {
if (authData.token == 'my-token') { if (authData.token == 'my-token') {
return Promise.resolve(); return Promise.resolve();
} }

View File

@@ -1,9 +1,9 @@
module.exports = function(validAuthData) { module.exports = function (validAuthData) {
return { return {
validateAppId: function() { validateAppId: function () {
return Promise.resolve(); return Promise.resolve();
}, },
validateAuthData: function(authData) { validateAuthData: function (authData) {
if (authData.token == validAuthData.token) { if (authData.token == validAuthData.token) {
return Promise.resolve(); return Promise.resolve();
} }

View File

@@ -1,4 +1,4 @@
module.exports = function(req, res, next) { module.exports = function (req, res, next) {
res.set('X-Yolo', '1'); res.set('X-Yolo', '1');
next(); next();
}; };

View File

@@ -7,7 +7,7 @@ export class AnalyticsController extends AdaptableController {
.then(() => { .then(() => {
return this.adapter.appOpened(req.body, req); return this.adapter.appOpened(req.body, req);
}) })
.then(response => { .then((response) => {
return { response: response || {} }; return { response: response || {} };
}) })
.catch(() => { .catch(() => {
@@ -20,7 +20,7 @@ export class AnalyticsController extends AdaptableController {
.then(() => { .then(() => {
return this.adapter.trackEvent(req.params.eventName, req.body, req); return this.adapter.trackEvent(req.params.eventName, req.body, req);
}) })
.then(response => { .then((response) => {
return { response: response || {} }; return { response: response || {} };
}) })
.catch(() => { .catch(() => {

View File

@@ -27,9 +27,9 @@ export class HooksController {
} }
load() { load() {
return this._getHooks().then(hooks => { return this._getHooks().then((hooks) => {
hooks = hooks || []; hooks = hooks || [];
hooks.forEach(hook => { hooks.forEach((hook) => {
this.addHookToTriggers(hook); this.addHookToTriggers(hook);
}); });
}); });
@@ -37,7 +37,7 @@ export class HooksController {
getFunction(functionName) { getFunction(functionName) {
return this._getHooks({ functionName: functionName }).then( return this._getHooks({ functionName: functionName }).then(
results => results[0] (results) => results[0]
); );
} }
@@ -49,7 +49,7 @@ export class HooksController {
return this._getHooks({ return this._getHooks({
className: className, className: className,
triggerName: triggerName, triggerName: triggerName,
}).then(results => results[0]); }).then((results) => results[0]);
} }
getTriggers() { getTriggers() {
@@ -75,8 +75,8 @@ export class HooksController {
_getHooks(query = {}) { _getHooks(query = {}) {
return this.database return this.database
.find(DefaultHooksCollectionName, query) .find(DefaultHooksCollectionName, query)
.then(results => { .then((results) => {
return results.map(result => { return results.map((result) => {
delete result.objectId; delete result.objectId;
return result; return result;
}); });
@@ -156,7 +156,7 @@ export class HooksController {
createHook(aHook) { createHook(aHook) {
if (aHook.functionName) { if (aHook.functionName) {
return this.getFunction(aHook.functionName).then(result => { return this.getFunction(aHook.functionName).then((result) => {
if (result) { if (result) {
throw new Parse.Error( throw new Parse.Error(
143, 143,
@@ -168,13 +168,11 @@ export class HooksController {
}); });
} else if (aHook.className && aHook.triggerName) { } else if (aHook.className && aHook.triggerName) {
return this.getTrigger(aHook.className, aHook.triggerName).then( return this.getTrigger(aHook.className, aHook.triggerName).then(
result => { (result) => {
if (result) { if (result) {
throw new Parse.Error( throw new Parse.Error(
143, 143,
`class ${aHook.className} already has trigger ${ `class ${aHook.className} already has trigger ${aHook.triggerName}`
aHook.triggerName
}`
); );
} }
return this.createOrUpdateHook(aHook); return this.createOrUpdateHook(aHook);
@@ -187,7 +185,7 @@ export class HooksController {
updateHook(aHook) { updateHook(aHook) {
if (aHook.functionName) { if (aHook.functionName) {
return this.getFunction(aHook.functionName).then(result => { return this.getFunction(aHook.functionName).then((result) => {
if (result) { if (result) {
return this.createOrUpdateHook(aHook); return this.createOrUpdateHook(aHook);
} }
@@ -198,7 +196,7 @@ export class HooksController {
}); });
} else if (aHook.className && aHook.triggerName) { } else if (aHook.className && aHook.triggerName) {
return this.getTrigger(aHook.className, aHook.triggerName).then( return this.getTrigger(aHook.className, aHook.triggerName).then(
result => { (result) => {
if (result) { if (result) {
return this.createOrUpdateHook(aHook); return this.createOrUpdateHook(aHook);
} }
@@ -211,7 +209,7 @@ export class HooksController {
} }
function wrapToHTTPRequest(hook, key) { function wrapToHTTPRequest(hook, key) {
return req => { return (req) => {
const jsonBody = {}; const jsonBody = {};
for (var i in req) { for (var i in req) {
jsonBody[i] = req[i]; jsonBody[i] = req[i];
@@ -245,7 +243,7 @@ function wrapToHTTPRequest(hook, key) {
'Making outgoing webhook request without webhookKey being set!' 'Making outgoing webhook request without webhookKey being set!'
); );
} }
return request(jsonRequest).then(response => { return request(jsonRequest).then((response) => {
let err; let err;
let result; let result;
let body = response.data; let body = response.data;

View File

@@ -61,7 +61,7 @@ export class LoggerController extends AdaptableController {
} }
maskSensitive(argArray) { maskSensitive(argArray) {
return argArray.map(e => { return argArray.map((e) => {
if (!e) { if (!e) {
return e; return e;
} }
@@ -78,7 +78,7 @@ export class LoggerController extends AdaptableController {
e.url = this.maskSensitiveUrl(e.url); e.url = this.maskSensitiveUrl(e.url);
} else if (Array.isArray(e.url)) { } else if (Array.isArray(e.url)) {
// for strings in array // for strings in array
e.url = e.url.map(item => { e.url = e.url.map((item) => {
if (typeof item === 'string') { if (typeof item === 'string') {
return this.maskSensitiveUrl(item); return this.maskSensitiveUrl(item);
} }
@@ -115,7 +115,7 @@ export class LoggerController extends AdaptableController {
args = this.maskSensitive([...args]); args = this.maskSensitive([...args]);
args = [].concat( args = [].concat(
level, level,
args.map(arg => { args.map((arg) => {
if (typeof arg === 'function') { if (typeof arg === 'function') {
return arg(); return arg();
} }

View File

@@ -137,7 +137,7 @@ class ParseGraphQLController {
} }
if (classConfigs !== null) { if (classConfigs !== null) {
if (Array.isArray(classConfigs)) { if (Array.isArray(classConfigs)) {
classConfigs.forEach(classConfig => { classConfigs.forEach((classConfig) => {
const errorMessage = this._validateClassConfig(classConfig); const errorMessage = this._validateClassConfig(classConfig);
if (errorMessage) { if (errorMessage) {
errorMessages.push( errorMessages.push(
@@ -332,9 +332,9 @@ class ParseGraphQLController {
} }
} }
const isValidStringArray = function(array): boolean { const isValidStringArray = function (array): boolean {
return Array.isArray(array) return Array.isArray(array)
? !array.some(s => typeof s !== 'string' || s.trim().length < 1) ? !array.some((s) => typeof s !== 'string' || s.trim().length < 1)
: false; : false;
}; };
/** /**
@@ -342,7 +342,7 @@ const isValidStringArray = function(array): boolean {
* object, i.e. not an array, null, date * object, i.e. not an array, null, date
* etc. * etc.
*/ */
const isValidSimpleObject = function(obj): boolean { const isValidSimpleObject = function (obj): boolean {
return ( return (
typeof obj === 'object' && typeof obj === 'object' &&
!Array.isArray(obj) && !Array.isArray(obj) &&

View File

@@ -137,7 +137,7 @@ export class PushController {
pushStatus pushStatus
); );
}) })
.catch(err => { .catch((err) => {
return pushStatus.fail(err).then(() => { return pushStatus.fail(err).then(() => {
throw err; throw err;
}); });

View File

@@ -41,9 +41,9 @@ export default class SchemaCache {
if (!this.ttl) { if (!this.ttl) {
return Promise.resolve(null); return Promise.resolve(null);
} }
return this.cache.get(this.prefix + MAIN_SCHEMA).then(cachedSchemas => { return this.cache.get(this.prefix + MAIN_SCHEMA).then((cachedSchemas) => {
cachedSchemas = cachedSchemas || []; cachedSchemas = cachedSchemas || [];
const schema = cachedSchemas.find(cachedSchema => { const schema = cachedSchemas.find((cachedSchema) => {
return cachedSchema.className === className; return cachedSchema.className === className;
}); });
if (schema) { if (schema) {

View File

@@ -545,7 +545,7 @@ class SchemaData {
constructor(allSchemas = [], protectedFields = {}) { constructor(allSchemas = [], protectedFields = {}) {
this.__data = {}; this.__data = {};
this.__protectedFields = protectedFields; this.__protectedFields = protectedFields;
allSchemas.forEach(schema => { allSchemas.forEach((schema) => {
if (volatileClasses.includes(schema.className)) { if (volatileClasses.includes(schema.className)) {
return; return;
} }
@@ -580,7 +580,7 @@ class SchemaData {
}); });
// Inject the in-memory classes // Inject the in-memory classes
volatileClasses.forEach(className => { volatileClasses.forEach((className) => {
Object.defineProperty(this, className, { Object.defineProperty(this, className, {
get: () => { get: () => {
if (!this.__data[className]) { if (!this.__data[className]) {
@@ -721,11 +721,11 @@ export default class SchemaController {
} }
this.reloadDataPromise = this.getAllClasses(options) this.reloadDataPromise = this.getAllClasses(options)
.then( .then(
allSchemas => { (allSchemas) => {
this.schemaData = new SchemaData(allSchemas, this.protectedFields); this.schemaData = new SchemaData(allSchemas, this.protectedFields);
delete this.reloadDataPromise; delete this.reloadDataPromise;
}, },
err => { (err) => {
this.schemaData = new SchemaData(); this.schemaData = new SchemaData();
delete this.reloadDataPromise; delete this.reloadDataPromise;
throw err; throw err;
@@ -741,7 +741,7 @@ export default class SchemaController {
if (options.clearCache) { if (options.clearCache) {
return this.setAllClasses(); return this.setAllClasses();
} }
return this._cache.getAllClasses().then(allClasses => { return this._cache.getAllClasses().then((allClasses) => {
if (allClasses && allClasses.length) { if (allClasses && allClasses.length) {
return Promise.resolve(allClasses); return Promise.resolve(allClasses);
} }
@@ -752,12 +752,12 @@ export default class SchemaController {
setAllClasses(): Promise<Array<Schema>> { setAllClasses(): Promise<Array<Schema>> {
return this._dbAdapter return this._dbAdapter
.getAllClasses() .getAllClasses()
.then(allSchemas => allSchemas.map(injectDefaultSchema)) .then((allSchemas) => allSchemas.map(injectDefaultSchema))
.then(allSchemas => { .then((allSchemas) => {
/* eslint-disable no-console */ /* eslint-disable no-console */
this._cache this._cache
.setAllClasses(allSchemas) .setAllClasses(allSchemas)
.catch(error => .catch((error) =>
console.error('Error saving schema to cache:', error) console.error('Error saving schema to cache:', error)
); );
/* eslint-enable no-console */ /* eslint-enable no-console */
@@ -784,13 +784,13 @@ export default class SchemaController {
indexes: data.indexes, indexes: data.indexes,
}); });
} }
return this._cache.getOneSchema(className).then(cached => { return this._cache.getOneSchema(className).then((cached) => {
if (cached && !options.clearCache) { if (cached && !options.clearCache) {
return Promise.resolve(cached); return Promise.resolve(cached);
} }
return this.setAllClasses().then(allSchemas => { return this.setAllClasses().then((allSchemas) => {
const oneSchema = allSchemas.find( const oneSchema = allSchemas.find(
schema => schema.className === className (schema) => schema.className === className
); );
if (!oneSchema) { if (!oneSchema) {
return Promise.reject(undefined); return Promise.reject(undefined);
@@ -841,7 +841,7 @@ export default class SchemaController {
}) })
) )
.then(convertAdapterSchemaToParseSchema) .then(convertAdapterSchemaToParseSchema)
.catch(error => { .catch((error) => {
if (error && error.code === Parse.Error.DUPLICATE_VALUE) { if (error && error.code === Parse.Error.DUPLICATE_VALUE) {
throw new Parse.Error( throw new Parse.Error(
Parse.Error.INVALID_CLASS_NAME, Parse.Error.INVALID_CLASS_NAME,
@@ -861,9 +861,9 @@ export default class SchemaController {
database: DatabaseController database: DatabaseController
) { ) {
return this.getOneSchema(className) return this.getOneSchema(className)
.then(schema => { .then((schema) => {
const existingFields = schema.fields; const existingFields = schema.fields;
Object.keys(submittedFields).forEach(name => { Object.keys(submittedFields).forEach((name) => {
const field = submittedFields[name]; const field = submittedFields[name];
if (existingFields[name] && field.__op !== 'Delete') { if (existingFields[name] && field.__op !== 'Delete') {
throw new Parse.Error(255, `Field ${name} exists, cannot update.`); throw new Parse.Error(255, `Field ${name} exists, cannot update.`);
@@ -899,7 +899,7 @@ export default class SchemaController {
// Do all deletions first, then a single save to _SCHEMA collection to handle all additions. // Do all deletions first, then a single save to _SCHEMA collection to handle all additions.
const deletedFields: string[] = []; const deletedFields: string[] = [];
const insertedFields = []; const insertedFields = [];
Object.keys(submittedFields).forEach(fieldName => { Object.keys(submittedFields).forEach((fieldName) => {
if (submittedFields[fieldName].__op === 'Delete') { if (submittedFields[fieldName].__op === 'Delete') {
deletedFields.push(fieldName); deletedFields.push(fieldName);
} else { } else {
@@ -916,14 +916,14 @@ export default class SchemaController {
deletePromise // Delete Everything deletePromise // Delete Everything
.then(() => this.reloadData({ clearCache: true })) // Reload our Schema, so we have all the new values .then(() => this.reloadData({ clearCache: true })) // Reload our Schema, so we have all the new values
.then(() => { .then(() => {
const promises = insertedFields.map(fieldName => { const promises = insertedFields.map((fieldName) => {
const type = submittedFields[fieldName]; const type = submittedFields[fieldName];
return this.enforceFieldExists(className, fieldName, type); return this.enforceFieldExists(className, fieldName, type);
}); });
return Promise.all(promises); return Promise.all(promises);
}) })
.then(results => { .then((results) => {
enforceFields = results.filter(result => !!result); enforceFields = results.filter((result) => !!result);
return this.setPermissions( return this.setPermissions(
className, className,
classLevelPermissions, classLevelPermissions,
@@ -955,7 +955,7 @@ export default class SchemaController {
}) })
); );
}) })
.catch(error => { .catch((error) => {
if (error === undefined) { if (error === undefined) {
throw new Parse.Error( throw new Parse.Error(
Parse.Error.INVALID_CLASS_NAME, Parse.Error.INVALID_CLASS_NAME,
@@ -1095,7 +1095,7 @@ export default class SchemaController {
} }
const geoPoints = Object.keys(fields).filter( const geoPoints = Object.keys(fields).filter(
key => fields[key] && fields[key].type === 'GeoPoint' (key) => fields[key] && fields[key].type === 'GeoPoint'
); );
if (geoPoints.length > 1) { if (geoPoints.length > 1) {
return { return {
@@ -1180,7 +1180,7 @@ export default class SchemaController {
return this._dbAdapter return this._dbAdapter
.addFieldIfNotExists(className, fieldName, type) .addFieldIfNotExists(className, fieldName, type)
.catch(error => { .catch((error) => {
if (error.code == Parse.Error.INCORRECT_TYPE) { if (error.code == Parse.Error.INCORRECT_TYPE) {
// Make sure that we throw errors when it is appropriate to do so. // Make sure that we throw errors when it is appropriate to do so.
throw error; throw error;
@@ -1244,7 +1244,7 @@ export default class SchemaController {
); );
} }
fieldNames.forEach(fieldName => { fieldNames.forEach((fieldName) => {
if (!fieldNameIsValid(fieldName)) { if (!fieldNameIsValid(fieldName)) {
throw new Parse.Error( throw new Parse.Error(
Parse.Error.INVALID_KEY_NAME, Parse.Error.INVALID_KEY_NAME,
@@ -1258,7 +1258,7 @@ export default class SchemaController {
}); });
return this.getOneSchema(className, false, { clearCache: true }) return this.getOneSchema(className, false, { clearCache: true })
.catch(error => { .catch((error) => {
if (error === undefined) { if (error === undefined) {
throw new Parse.Error( throw new Parse.Error(
Parse.Error.INVALID_CLASS_NAME, Parse.Error.INVALID_CLASS_NAME,
@@ -1268,8 +1268,8 @@ export default class SchemaController {
throw error; throw error;
} }
}) })
.then(schema => { .then((schema) => {
fieldNames.forEach(fieldName => { fieldNames.forEach((fieldName) => {
if (!schema.fields[fieldName]) { if (!schema.fields[fieldName]) {
throw new Parse.Error( throw new Parse.Error(
255, 255,
@@ -1283,7 +1283,7 @@ export default class SchemaController {
.deleteFields(className, schema, fieldNames) .deleteFields(className, schema, fieldNames)
.then(() => { .then(() => {
return Promise.all( return Promise.all(
fieldNames.map(fieldName => { fieldNames.map((fieldName) => {
const field = schemaFields[fieldName]; const field = schemaFields[fieldName];
if (field && field.type === 'Relation') { if (field && field.type === 'Relation') {
//For relations, drop the _Join table //For relations, drop the _Join table
@@ -1335,7 +1335,7 @@ export default class SchemaController {
promises.push(schema.enforceFieldExists(className, fieldName, expected)); promises.push(schema.enforceFieldExists(className, fieldName, expected));
} }
const results = await Promise.all(promises); const results = await Promise.all(promises);
const enforceFields = results.filter(result => !!result); const enforceFields = results.filter((result) => !!result);
if (enforceFields.length !== 0) { if (enforceFields.length !== 0) {
await this.reloadData({ clearCache: true }); await this.reloadData({ clearCache: true });
@@ -1353,7 +1353,7 @@ export default class SchemaController {
return Promise.resolve(this); return Promise.resolve(this);
} }
const missingColumns = columns.filter(function(column) { const missingColumns = columns.filter(function (column) {
if (query && query.objectId) { if (query && query.objectId) {
if (object[column] && typeof object[column] === 'object') { if (object[column] && typeof object[column] === 'object') {
// Trying to delete a required column // Trying to delete a required column
@@ -1401,7 +1401,7 @@ export default class SchemaController {
} }
// Check permissions against the aclGroup provided (array of userId/roles) // Check permissions against the aclGroup provided (array of userId/roles)
if ( if (
aclGroup.some(acl => { aclGroup.some((acl) => {
return perms[acl] === true; return perms[acl] === true;
}) })
) { ) {
@@ -1594,7 +1594,7 @@ function buildMergedSchemaObject(
// Given a schema promise, construct another schema promise that // Given a schema promise, construct another schema promise that
// validates this field once the schema loads. // validates this field once the schema loads.
function thenValidateRequiredColumns(schemaPromise, className, object, query) { function thenValidateRequiredColumns(schemaPromise, className, object, query) {
return schemaPromise.then(schema => { return schemaPromise.then((schema) => {
return schema.validateRequiredColumns(className, object, query); return schema.validateRequiredColumns(className, object, query);
}); });
} }

View File

@@ -70,7 +70,7 @@ export class UserController extends AdaptableController {
'_User', '_User',
{ username: username, emailVerified: true } { username: username, emailVerified: true }
); );
return checkIfAlreadyVerified.execute().then(result => { return checkIfAlreadyVerified.execute().then((result) => {
if (result.results.length) { if (result.results.length) {
return Promise.resolve(result.results.length[0]); return Promise.resolve(result.results.length[0]);
} }
@@ -88,7 +88,7 @@ export class UserController extends AdaptableController {
}, },
{ limit: 1 } { limit: 1 }
) )
.then(results => { .then((results) => {
if (results.length != 1) { if (results.length != 1) {
throw 'Failed to reset password: username / email / token is invalid'; throw 'Failed to reset password: username / email / token is invalid';
} }
@@ -127,7 +127,7 @@ export class UserController extends AdaptableController {
'_User', '_User',
where where
); );
return query.execute().then(function(result) { return query.execute().then(function (result) {
if (result.results.length != 1) { if (result.results.length != 1) {
throw undefined; throw undefined;
} }
@@ -141,7 +141,7 @@ export class UserController extends AdaptableController {
} }
const token = encodeURIComponent(user._email_verify_token); const token = encodeURIComponent(user._email_verify_token);
// We may need to fetch the user in case of update email // We may need to fetch the user in case of update email
this.getUserIfNeeded(user).then(user => { this.getUserIfNeeded(user).then((user) => {
const username = encodeURIComponent(user.username); const username = encodeURIComponent(user.username);
const link = buildEmailLink( const link = buildEmailLink(
@@ -179,7 +179,7 @@ export class UserController extends AdaptableController {
} }
resendVerificationEmail(username) { resendVerificationEmail(username) {
return this.getUserIfNeeded({ username: username }).then(aUser => { return this.getUserIfNeeded({ username: username }).then((aUser) => {
if (!aUser || aUser.emailVerified) { if (!aUser || aUser.emailVerified) {
throw undefined; throw undefined;
} }
@@ -216,7 +216,7 @@ export class UserController extends AdaptableController {
// TODO: No adapter? // TODO: No adapter?
} }
return this.setPasswordResetToken(email).then(user => { return this.setPasswordResetToken(email).then((user) => {
const token = encodeURIComponent(user._perishable_token); const token = encodeURIComponent(user._perishable_token);
const username = encodeURIComponent(user.username); const username = encodeURIComponent(user.username);
@@ -244,8 +244,8 @@ export class UserController extends AdaptableController {
updatePassword(username, token, password) { updatePassword(username, token, password) {
return this.checkResetTokenValidity(username, token) return this.checkResetTokenValidity(username, token)
.then(user => updateUserPassword(user.objectId, password, this.config)) .then((user) => updateUserPassword(user.objectId, password, this.config))
.catch(error => { .catch((error) => {
if (error && error.message) { if (error && error.message) {
// in case of Parse.Error, fail with the error message only // in case of Parse.Error, fail with the error message only
return Promise.reject(error.message); return Promise.reject(error.message);

View File

@@ -46,7 +46,7 @@ class ParseGraphQLServer {
config: req.config, config: req.config,
auth: req.auth, auth: req.auth,
}, },
formatError: error => { formatError: (error) => {
// Allow to console.log here to debug // Allow to console.log here to debug
return error; return error;
}, },
@@ -91,7 +91,7 @@ class ParseGraphQLServer {
app.use(this.config.graphQLPath, handleParseErrors); app.use(this.config.graphQLPath, handleParseErrors);
app.use( app.use(
this.config.graphQLPath, this.config.graphQLPath,
graphqlExpress(async req => await this._getGraphQLOptions(req)) graphqlExpress(async (req) => await this._getGraphQLOptions(req))
); );
} }

View File

@@ -22,13 +22,13 @@ export function toGraphQLError(error) {
return new ApolloError(message, code); return new ApolloError(message, code);
} }
export const extractKeysAndInclude = selectedFields => { export const extractKeysAndInclude = (selectedFields) => {
selectedFields = selectedFields.filter( selectedFields = selectedFields.filter(
field => !field.includes('__typename') (field) => !field.includes('__typename')
); );
// Handles "id" field for both current and included objects // Handles "id" field for both current and included objects
selectedFields = selectedFields.map(field => { selectedFields = selectedFields.map((field) => {
if (field === 'id') return 'objectId'; if (field === 'id') return 'objectId';
return field.endsWith('.id') return field.endsWith('.id')
? `${field.substring(0, field.lastIndexOf('.id'))}.objectId` ? `${field.substring(0, field.lastIndexOf('.id'))}.objectId`
@@ -57,6 +57,6 @@ export const extractKeysAndInclude = selectedFields => {
return { keys, include }; return { keys, include };
}; };
export const getParseClassMutationConfig = function(parseClassConfig) { export const getParseClassMutationConfig = function (parseClassConfig) {
return (parseClassConfig && parseClassConfig.mutation) || {}; return (parseClassConfig && parseClassConfig.mutation) || {};
}; };

View File

@@ -88,7 +88,7 @@ class Client {
} }
_pushEvent(type: string): Function { _pushEvent(type: string): Function {
return function( return function (
subscriptionId: number, subscriptionId: number,
parseObjectJSON: any, parseObjectJSON: any,
parseOriginalObjectJSON: any parseOriginalObjectJSON: any

View File

@@ -10,7 +10,7 @@ function useRedis(config: any): boolean {
return typeof redisURL !== 'undefined' && redisURL !== ''; return typeof redisURL !== 'undefined' && redisURL !== '';
} }
ParsePubSub.createPublisher = function(config: any): any { ParsePubSub.createPublisher = function (config: any): any {
if (useRedis(config)) { if (useRedis(config)) {
return RedisPubSub.createPublisher(config); return RedisPubSub.createPublisher(config);
} else { } else {
@@ -26,7 +26,7 @@ ParsePubSub.createPublisher = function(config: any): any {
} }
}; };
ParsePubSub.createSubscriber = function(config: any): void { ParsePubSub.createSubscriber = function (config: any): void {
if (useRedis(config)) { if (useRedis(config)) {
return RedisPubSub.createSubscriber(config); return RedisPubSub.createSubscriber(config);
} else { } else {

View File

@@ -12,8 +12,8 @@ export class ParseWebSocketServer {
wss.onListen = () => { wss.onListen = () => {
logger.info('Parse LiveQuery Server starts running'); logger.info('Parse LiveQuery Server starts running');
}; };
wss.onConnection = ws => { wss.onConnection = (ws) => {
ws.on('error', error => { ws.on('error', (error) => {
logger.error(error.message); logger.error(error.message);
logger.error(JSON.stringify(ws)); logger.error(JSON.stringify(ws));
}); });
@@ -27,7 +27,7 @@ export class ParseWebSocketServer {
} }
}, config.websocketTimeout || 10 * 1000); }, config.websocketTimeout || 10 * 1000);
}; };
wss.onError = error => { wss.onError = (error) => {
logger.error(error); logger.error(error);
}; };
wss.start(); wss.start();
@@ -46,7 +46,7 @@ export class ParseWebSocket extends events.EventEmitter {
constructor(ws: any) { constructor(ws: any) {
super(); super();
ws.onmessage = request => ws.onmessage = (request) =>
this.emit('message', request && request.data ? request.data : request); this.emit('message', request && request.data ? request.data : request);
ws.onclose = () => this.emit('disconnect'); ws.onclose = () => this.emit('disconnect');
this.ws = ws; this.ws = ws;

View File

@@ -191,7 +191,7 @@ function matchesKeyConstraints(object, key, constraints) {
var compareTo; var compareTo;
if (constraints.__type) { if (constraints.__type) {
if (constraints.__type === 'Pointer') { if (constraints.__type === 'Pointer') {
return equalObjectsGeneric(object[key], constraints, function(obj, ptr) { return equalObjectsGeneric(object[key], constraints, function (obj, ptr) {
return ( return (
typeof obj !== 'undefined' && typeof obj !== 'undefined' &&
ptr.className === obj.className && ptr.className === obj.className &&

View File

@@ -5,7 +5,7 @@ import logger from '../logger';
function userForSessionToken(sessionToken) { function userForSessionToken(sessionToken) {
var q = new Parse.Query('_Session'); var q = new Parse.Query('_Session');
q.equalTo('sessionToken', sessionToken); q.equalTo('sessionToken', sessionToken);
return q.first({ useMasterKey: true }).then(function(session) { return q.first({ useMasterKey: true }).then(function (session) {
if (!session) { if (!session) {
return Promise.reject('No session found for session token'); return Promise.reject('No session found for session token');
} }
@@ -40,7 +40,7 @@ class SessionTokenCache {
return Promise.resolve(userId); return Promise.resolve(userId);
} }
return userForSessionToken(sessionToken).then( return userForSessionToken(sessionToken).then(
user => { (user) => {
logger.verbose( logger.verbose(
'Fetch userId %s of sessionToken %s from Parse', 'Fetch userId %s of sessionToken %s from Parse',
user.id, user.id,
@@ -50,7 +50,7 @@ class SessionTokenCache {
this.cache.set(sessionToken, userId); this.cache.set(sessionToken, userId);
return Promise.resolve(userId); return Promise.resolve(userId);
}, },
error => { (error) => {
logger.error( logger.error(
'Can not fetch userId for sessionToken %j, error %j', 'Can not fetch userId for sessionToken %j, error %j',
sessionToken, sessionToken,

View File

@@ -1,5 +1,5 @@
function numberParser(key) { function numberParser(key) {
return function(opt) { return function (opt) {
const intOpt = parseInt(opt); const intOpt = parseInt(opt);
if (!Number.isInteger(intOpt)) { if (!Number.isInteger(intOpt)) {
throw new Error(`Key ${key} has invalid value ${opt}`); throw new Error(`Key ${key} has invalid value ${opt}`);
@@ -9,7 +9,7 @@ function numberParser(key) {
} }
function numberOrBoolParser(key) { function numberOrBoolParser(key) {
return function(opt) { return function (opt) {
if (typeof opt === 'boolean') { if (typeof opt === 'boolean') {
return opt; return opt;
} }

View File

@@ -76,7 +76,7 @@ export class PushWorker {
installations, installations,
locales locales
); );
const promises = Object.keys(grouppedInstallations).map(locale => { const promises = Object.keys(grouppedInstallations).map((locale) => {
const installations = grouppedInstallations[locale]; const installations = grouppedInstallations[locale];
const body = bodiesPerLocales[locale]; const body = bodiesPerLocales[locale];
return this.sendToAdapter( return this.sendToAdapter(
@@ -94,7 +94,7 @@ export class PushWorker {
logger.verbose(`Sending push to ${installations.length}`); logger.verbose(`Sending push to ${installations.length}`);
return this.adapter return this.adapter
.send(body, installations, pushStatus.objectId) .send(body, installations, pushStatus.objectId)
.then(results => { .then((results) => {
return pushStatus.trackSent(results, UTCOffset).then(() => results); return pushStatus.trackSent(results, UTCOffset).then(() => results);
}); });
} }
@@ -103,7 +103,7 @@ export class PushWorker {
const badgeInstallationsMap = groupByBadge(installations); const badgeInstallationsMap = groupByBadge(installations);
// Map the on the badges count and return the send result // Map the on the badges count and return the send result
const promises = Object.keys(badgeInstallationsMap).map(badge => { const promises = Object.keys(badgeInstallationsMap).map((badge) => {
const payload = deepcopy(body); const payload = deepcopy(body);
payload.data.badge = parseInt(badge); payload.data.badge = parseInt(badge);
const installations = badgeInstallationsMap[badge]; const installations = badgeInstallationsMap[badge];

View File

@@ -29,7 +29,7 @@ export function getLocalesFromPush(body) {
return [ return [
...new Set( ...new Set(
Object.keys(data).reduce((memo, key) => { Object.keys(data).reduce((memo, key) => {
localizableKeys.forEach(localizableKey => { localizableKeys.forEach((localizableKey) => {
if (key.indexOf(`${localizableKey}-`) == 0) { if (key.indexOf(`${localizableKey}-`) == 0) {
memo.push(key.slice(localizableKey.length + 1)); memo.push(key.slice(localizableKey.length + 1));
} }
@@ -46,7 +46,7 @@ export function transformPushBodyForLocale(body, locale) {
return body; return body;
} }
body = deepcopy(body); body = deepcopy(body);
localizableKeys.forEach(key => { localizableKeys.forEach((key) => {
const localeValue = body.data[`${key}-${locale}`]; const localeValue = body.data[`${key}-${locale}`];
if (localeValue) { if (localeValue) {
body.data[key] = localeValue; body.data[key] = localeValue;
@@ -59,8 +59,8 @@ export function stripLocalesFromBody(body) {
if (!body.data) { if (!body.data) {
return body; return body;
} }
Object.keys(body.data).forEach(key => { Object.keys(body.data).forEach((key) => {
localizableKeys.forEach(localizableKey => { localizableKeys.forEach((localizableKey) => {
if (key.indexOf(`${localizableKey}-`) == 0) { if (key.indexOf(`${localizableKey}-`) == 0) {
delete body.data[key]; delete body.data[key];
} }
@@ -84,7 +84,7 @@ export function groupByLocaleIdentifier(installations, locales = []) {
return installations.reduce( return installations.reduce(
(map, installation) => { (map, installation) => {
let added = false; let added = false;
locales.forEach(locale => { locales.forEach((locale) => {
if (added) { if (added) {
return; return;
} }

View File

@@ -70,9 +70,9 @@ export class AggregateRouter extends ClassesRouter {
body.where, body.where,
options, options,
req.info.clientSDK, req.info.clientSDK,
req.info.context, req.info.context
) )
.then(response => { .then((response) => {
for (const result of response.results) { for (const result of response.results) {
if (typeof result === 'object') { if (typeof result === 'object') {
UsersRouter.removeHiddenProperties(result); UsersRouter.removeHiddenProperties(result);
@@ -110,12 +110,12 @@ export class AggregateRouter extends ClassesRouter {
static getPipeline(body) { static getPipeline(body) {
let pipeline = body.pipeline || body; let pipeline = body.pipeline || body;
if (!Array.isArray(pipeline)) { if (!Array.isArray(pipeline)) {
pipeline = Object.keys(pipeline).map(key => { pipeline = Object.keys(pipeline).map((key) => {
return { [key]: pipeline[key] }; return { [key]: pipeline[key] };
}); });
} }
return pipeline.map(stage => { return pipeline.map((stage) => {
const keys = Object.keys(stage); const keys = Object.keys(stage);
if (keys.length != 1) { if (keys.length != 1) {
throw new Error( throw new Error(
@@ -157,7 +157,7 @@ export class AggregateRouter extends ClassesRouter {
'GET', 'GET',
'/aggregate/:className', '/aggregate/:className',
middleware.promiseEnforceMasterKeyAccess, middleware.promiseEnforceMasterKeyAccess,
req => { (req) => {
return this.handleFind(req); return this.handleFind(req);
} }
); );

View File

@@ -22,10 +22,10 @@ export class AudiencesRouter extends ClassesRouter {
body.where, body.where,
options, options,
req.info.clientSDK, req.info.clientSDK,
req.info.context, req.info.context
) )
.then(response => { .then((response) => {
response.results.forEach(item => { response.results.forEach((item) => {
item.query = JSON.parse(item.query); item.query = JSON.parse(item.query);
}); });
@@ -34,7 +34,7 @@ export class AudiencesRouter extends ClassesRouter {
} }
handleGet(req) { handleGet(req) {
return super.handleGet(req).then(data => { return super.handleGet(req).then((data) => {
data.response.query = JSON.parse(data.response.query); data.response.query = JSON.parse(data.response.query);
return data; return data;
@@ -46,7 +46,7 @@ export class AudiencesRouter extends ClassesRouter {
'GET', 'GET',
'/push_audiences', '/push_audiences',
middleware.promiseEnforceMasterKeyAccess, middleware.promiseEnforceMasterKeyAccess,
req => { (req) => {
return this.handleFind(req); return this.handleFind(req);
} }
); );
@@ -54,7 +54,7 @@ export class AudiencesRouter extends ClassesRouter {
'GET', 'GET',
'/push_audiences/:objectId', '/push_audiences/:objectId',
middleware.promiseEnforceMasterKeyAccess, middleware.promiseEnforceMasterKeyAccess,
req => { (req) => {
return this.handleGet(req); return this.handleGet(req);
} }
); );
@@ -62,7 +62,7 @@ export class AudiencesRouter extends ClassesRouter {
'POST', 'POST',
'/push_audiences', '/push_audiences',
middleware.promiseEnforceMasterKeyAccess, middleware.promiseEnforceMasterKeyAccess,
req => { (req) => {
return this.handleCreate(req); return this.handleCreate(req);
} }
); );
@@ -70,7 +70,7 @@ export class AudiencesRouter extends ClassesRouter {
'PUT', 'PUT',
'/push_audiences/:objectId', '/push_audiences/:objectId',
middleware.promiseEnforceMasterKeyAccess, middleware.promiseEnforceMasterKeyAccess,
req => { (req) => {
return this.handleUpdate(req); return this.handleUpdate(req);
} }
); );
@@ -78,7 +78,7 @@ export class AudiencesRouter extends ClassesRouter {
'DELETE', 'DELETE',
'/push_audiences/:objectId', '/push_audiences/:objectId',
middleware.promiseEnforceMasterKeyAccess, middleware.promiseEnforceMasterKeyAccess,
req => { (req) => {
return this.handleDelete(req); return this.handleDelete(req);
} }
); );

View File

@@ -41,9 +41,9 @@ export class ClassesRouter extends PromiseRouter {
body.where, body.where,
options, options,
req.info.clientSDK, req.info.clientSDK,
req.info.context, req.info.context
) )
.then(response => { .then((response) => {
return { response: response }; return { response: response };
}); });
} }
@@ -93,7 +93,7 @@ export class ClassesRouter extends PromiseRouter {
options, options,
req.info.clientSDK req.info.clientSDK
) )
.then(response => { .then((response) => {
if (!response.results || response.results.length == 0) { if (!response.results || response.results.length == 0) {
throw new Parse.Error( throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND, Parse.Error.OBJECT_NOT_FOUND,
@@ -241,19 +241,19 @@ export class ClassesRouter extends PromiseRouter {
} }
mountRoutes() { mountRoutes() {
this.route('GET', '/classes/:className', req => { this.route('GET', '/classes/:className', (req) => {
return this.handleFind(req); return this.handleFind(req);
}); });
this.route('GET', '/classes/:className/:objectId', req => { this.route('GET', '/classes/:className/:objectId', (req) => {
return this.handleGet(req); return this.handleGet(req);
}); });
this.route('POST', '/classes/:className', req => { this.route('POST', '/classes/:className', (req) => {
return this.handleCreate(req); return this.handleCreate(req);
}); });
this.route('PUT', '/classes/:className/:objectId', req => { this.route('PUT', '/classes/:className/:objectId', (req) => {
return this.handleUpdate(req); return this.handleUpdate(req);
}); });
this.route('DELETE', '/classes/:className/:objectId', req => { this.route('DELETE', '/classes/:className/:objectId', (req) => {
return this.handleDelete(req); return this.handleDelete(req);
}); });
} }

View File

@@ -58,7 +58,7 @@ export class CloudCodeRouter extends PromiseRouter {
static getJobs(req) { static getJobs(req) {
return rest return rest
.find(req.config, req.auth, '_JobSchedule', {}, {}) .find(req.config, req.auth, '_JobSchedule', {}, {})
.then(scheduledJobs => { .then((scheduledJobs) => {
return { return {
response: scheduledJobs.results, response: scheduledJobs.results,
}; };
@@ -70,10 +70,10 @@ export class CloudCodeRouter extends PromiseRouter {
const jobs = triggers.getJobs(config.applicationId) || {}; const jobs = triggers.getJobs(config.applicationId) || {};
return rest return rest
.find(req.config, req.auth, '_JobSchedule', {}, {}) .find(req.config, req.auth, '_JobSchedule', {}, {})
.then(scheduledJobs => { .then((scheduledJobs) => {
return { return {
response: { response: {
in_use: scheduledJobs.results.map(job => job.jobName), in_use: scheduledJobs.results.map((job) => job.jobName),
jobs: Object.keys(jobs), jobs: Object.keys(jobs),
}, },
}; };
@@ -107,7 +107,7 @@ export class CloudCodeRouter extends PromiseRouter {
undefined, undefined,
req.info.context req.info.context
) )
.then(response => { .then((response) => {
return { return {
response, response,
}; };
@@ -118,7 +118,7 @@ export class CloudCodeRouter extends PromiseRouter {
const { objectId } = req.params; const { objectId } = req.params;
return rest return rest
.del(req.config, req.auth, '_JobSchedule', objectId, req.info.context) .del(req.config, req.auth, '_JobSchedule', objectId, req.info.context)
.then(response => { .then((response) => {
return { return {
response, response,
}; };

View File

@@ -8,7 +8,7 @@ export class FeaturesRouter extends PromiseRouter {
'GET', 'GET',
'/serverInfo', '/serverInfo',
middleware.promiseEnforceMasterKeyAccess, middleware.promiseEnforceMasterKeyAccess,
req => { (req) => {
const { config } = req; const { config } = req;
const features = { const features = {
globalConfig: { globalConfig: {

View File

@@ -11,7 +11,7 @@ import { logger } from '../logger';
function parseObject(obj) { function parseObject(obj) {
if (Array.isArray(obj)) { if (Array.isArray(obj)) {
return obj.map(item => { return obj.map((item) => {
return parseObject(item); return parseObject(item);
}); });
} else if (obj && obj.__type == 'Date') { } else if (obj && obj.__type == 'Date') {
@@ -40,11 +40,11 @@ export class FunctionsRouter extends PromiseRouter {
'POST', 'POST',
'/jobs/:jobName', '/jobs/:jobName',
promiseEnforceMasterKeyAccess, promiseEnforceMasterKeyAccess,
function(req) { function (req) {
return FunctionsRouter.handleCloudJob(req); return FunctionsRouter.handleCloudJob(req);
} }
); );
this.route('POST', '/jobs', promiseEnforceMasterKeyAccess, function(req) { this.route('POST', '/jobs', promiseEnforceMasterKeyAccess, function (req) {
return FunctionsRouter.handleCloudJob(req); return FunctionsRouter.handleCloudJob(req);
}); });
} }
@@ -68,7 +68,7 @@ export class FunctionsRouter extends PromiseRouter {
message: jobHandler.setMessage.bind(jobHandler), message: jobHandler.setMessage.bind(jobHandler),
}; };
return jobHandler.setRunning(jobName, params).then(jobStatus => { return jobHandler.setRunning(jobName, params).then((jobStatus) => {
request.jobId = jobStatus.objectId; request.jobId = jobStatus.objectId;
// run the function async // run the function async
process.nextTick(() => { process.nextTick(() => {
@@ -77,10 +77,10 @@ export class FunctionsRouter extends PromiseRouter {
return jobFunction(request); return jobFunction(request);
}) })
.then( .then(
result => { (result) => {
jobHandler.setSucceeded(result); jobHandler.setSucceeded(result);
}, },
error => { (error) => {
jobHandler.setFailed(error); jobHandler.setFailed(error);
} }
); );
@@ -96,14 +96,14 @@ export class FunctionsRouter extends PromiseRouter {
static createResponseObject(resolve, reject, message) { static createResponseObject(resolve, reject, message) {
return { return {
success: function(result) { success: function (result) {
resolve({ resolve({
response: { response: {
result: Parse._encode(result), result: Parse._encode(result),
}, },
}); });
}, },
error: function(message) { error: function (message) {
// parse error, process away // parse error, process away
if (message instanceof Parse.Error) { if (message instanceof Parse.Error) {
return reject(message); return reject(message);
@@ -161,12 +161,12 @@ export class FunctionsRouter extends PromiseRouter {
} }
} }
return new Promise(function(resolve, reject) { return new Promise(function (resolve, reject) {
const userString = const userString =
req.auth && req.auth.user ? req.auth.user.id : undefined; req.auth && req.auth.user ? req.auth.user.id : undefined;
const cleanInput = logger.truncateLogMessage(JSON.stringify(params)); const cleanInput = logger.truncateLogMessage(JSON.stringify(params));
const { success, error, message } = FunctionsRouter.createResponseObject( const { success, error, message } = FunctionsRouter.createResponseObject(
result => { (result) => {
try { try {
const cleanResult = logger.truncateLogMessage( const cleanResult = logger.truncateLogMessage(
JSON.stringify(result.response.result) JSON.stringify(result.response.result)
@@ -184,7 +184,7 @@ export class FunctionsRouter extends PromiseRouter {
reject(e); reject(e);
} }
}, },
error => { (error) => {
try { try {
logger.error( logger.error(
`Failed running cloud function ${functionName} for user ${userString} with:\n Input: ${cleanInput}\n Error: ` + `Failed running cloud function ${functionName} for user ${userString} with:\n Input: ${cleanInput}\n Error: ` +

View File

@@ -7,7 +7,7 @@ export class GlobalConfigRouter extends PromiseRouter {
getGlobalConfig(req) { getGlobalConfig(req) {
return req.config.database return req.config.database
.find('_GlobalConfig', { objectId: '1' }, { limit: 1 }) .find('_GlobalConfig', { objectId: '1' }, { limit: 1 })
.then(results => { .then((results) => {
if (results.length != 1) { if (results.length != 1) {
// If there is no config in the database - return empty config. // If there is no config in the database - return empty config.
return { response: { params: {} } }; return { response: { params: {} } };
@@ -51,14 +51,14 @@ export class GlobalConfigRouter extends PromiseRouter {
} }
mountRoutes() { mountRoutes() {
this.route('GET', '/config', req => { this.route('GET', '/config', (req) => {
return this.getGlobalConfig(req); return this.getGlobalConfig(req);
}); });
this.route( this.route(
'PUT', 'PUT',
'/config', '/config',
middleware.promiseEnforceMasterKeyAccess, middleware.promiseEnforceMasterKeyAccess,
req => { (req) => {
return this.updateGlobalConfig(req); return this.updateGlobalConfig(req);
} }
); );

View File

@@ -32,7 +32,7 @@ export class GraphQLRouter extends PromiseRouter {
'GET', 'GET',
GraphQLConfigPath, GraphQLConfigPath,
middleware.promiseEnforceMasterKeyAccess, middleware.promiseEnforceMasterKeyAccess,
req => { (req) => {
return this.getGraphQLConfig(req); return this.getGraphQLConfig(req);
} }
); );
@@ -40,7 +40,7 @@ export class GraphQLRouter extends PromiseRouter {
'PUT', 'PUT',
GraphQLConfigPath, GraphQLConfigPath,
middleware.promiseEnforceMasterKeyAccess, middleware.promiseEnforceMasterKeyAccess,
req => { (req) => {
return this.updateGraphQLConfig(req); return this.updateGraphQLConfig(req);
} }
); );

View File

@@ -6,13 +6,13 @@ export class HooksRouter extends PromiseRouter {
createHook(aHook, config) { createHook(aHook, config) {
return config.hooksController return config.hooksController
.createHook(aHook) .createHook(aHook)
.then(hook => ({ response: hook })); .then((hook) => ({ response: hook }));
} }
updateHook(aHook, config) { updateHook(aHook, config) {
return config.hooksController return config.hooksController
.updateHook(aHook) .updateHook(aHook)
.then(hook => ({ response: hook })); .then((hook) => ({ response: hook }));
} }
handlePost(req) { handlePost(req) {
@@ -24,7 +24,7 @@ export class HooksRouter extends PromiseRouter {
if (req.params.functionName) { if (req.params.functionName) {
return hooksController return hooksController
.getFunction(req.params.functionName) .getFunction(req.params.functionName)
.then(foundFunction => { .then((foundFunction) => {
if (!foundFunction) { if (!foundFunction) {
throw new Parse.Error( throw new Parse.Error(
143, 143,
@@ -36,10 +36,10 @@ export class HooksRouter extends PromiseRouter {
} }
return hooksController.getFunctions().then( return hooksController.getFunctions().then(
functions => { (functions) => {
return { response: functions || [] }; return { response: functions || [] };
}, },
err => { (err) => {
throw err; throw err;
} }
); );
@@ -50,7 +50,7 @@ export class HooksRouter extends PromiseRouter {
if (req.params.className && req.params.triggerName) { if (req.params.className && req.params.triggerName) {
return hooksController return hooksController
.getTrigger(req.params.className, req.params.triggerName) .getTrigger(req.params.className, req.params.triggerName)
.then(foundTrigger => { .then((foundTrigger) => {
if (!foundTrigger) { if (!foundTrigger) {
throw new Parse.Error( throw new Parse.Error(
143, 143,
@@ -63,7 +63,7 @@ export class HooksRouter extends PromiseRouter {
return hooksController return hooksController
.getTriggers() .getTriggers()
.then(triggers => ({ response: triggers || [] })); .then((triggers) => ({ response: triggers || [] }));
} }
handleDelete(req) { handleDelete(req) {

View File

@@ -32,7 +32,7 @@ function validateWithAppStore(url, receipt) {
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
}).then(httpResponse => { }).then((httpResponse) => {
const body = httpResponse.data; const body = httpResponse.data;
if (body && body.status === 0) { if (body && body.status === 0) {
// No need to pass anything, status is OK // No need to pass anything, status is OK
@@ -54,7 +54,7 @@ function getFileForProductIdentifier(productIdentifier, req) {
req.info.clientSDK, req.info.clientSDK,
req.info.context req.info.context
) )
.then(function(result) { .then(function (result) {
const products = result.results; const products = result.results;
if (!products || products.length != 1) { if (!products || products.length != 1) {
// Error not found or too many // Error not found or too many
@@ -106,13 +106,13 @@ export class IAPValidationRouter extends PromiseRouter {
() => { () => {
return successCallback(); return successCallback();
}, },
error => { (error) => {
if (error.status == 21007) { if (error.status == 21007) {
return validateWithAppStore(IAP_SANDBOX_URL, receipt).then( return validateWithAppStore(IAP_SANDBOX_URL, receipt).then(
() => { () => {
return successCallback(); return successCallback();
}, },
error => { (error) => {
return errorCallback(error); return errorCallback(error);
} }
); );

View File

@@ -24,25 +24,25 @@ export class InstallationsRouter extends ClassesRouter {
req.info.clientSDK, req.info.clientSDK,
req.info.context req.info.context
) )
.then(response => { .then((response) => {
return { response: response }; return { response: response };
}); });
} }
mountRoutes() { mountRoutes() {
this.route('GET', '/installations', req => { this.route('GET', '/installations', (req) => {
return this.handleFind(req); return this.handleFind(req);
}); });
this.route('GET', '/installations/:objectId', req => { this.route('GET', '/installations/:objectId', (req) => {
return this.handleGet(req); return this.handleGet(req);
}); });
this.route('POST', '/installations', req => { this.route('POST', '/installations', (req) => {
return this.handleCreate(req); return this.handleCreate(req);
}); });
this.route('PUT', '/installations/:objectId', req => { this.route('PUT', '/installations/:objectId', (req) => {
return this.handleUpdate(req); return this.handleUpdate(req);
}); });
this.route('DELETE', '/installations/:objectId', req => { this.route('DELETE', '/installations/:objectId', (req) => {
return this.handleDelete(req); return this.handleDelete(req);
}); });
} }

View File

@@ -9,7 +9,7 @@ export class LogsRouter extends PromiseRouter {
'/scriptlog', '/scriptlog',
middleware.promiseEnforceMasterKeyAccess, middleware.promiseEnforceMasterKeyAccess,
this.validateRequest, this.validateRequest,
req => { (req) => {
return this.handleGET(req); return this.handleGET(req);
} }
); );
@@ -50,7 +50,7 @@ export class LogsRouter extends PromiseRouter {
level, level,
}; };
return req.config.loggerController.getLogs(options).then(result => { return req.config.loggerController.getLogs(options).then((result) => {
return Promise.resolve({ return Promise.resolve({
response: result, response: result,
}); });

View File

@@ -191,14 +191,14 @@ export class PublicAPIRouter extends PromiseRouter {
success: true, success: true,
}); });
}, },
err => { (err) => {
return Promise.resolve({ return Promise.resolve({
success: false, success: false,
err, err,
}); });
} }
) )
.then(result => { .then((result) => {
const params = qs.stringify({ const params = qs.stringify({
username: username, username: username,
token: token, token: token,
@@ -277,10 +277,10 @@ export class PublicAPIRouter extends PromiseRouter {
this.route( this.route(
'GET', 'GET',
'/apps/:appId/verify_email', '/apps/:appId/verify_email',
req => { (req) => {
this.setConfig(req); this.setConfig(req);
}, },
req => { (req) => {
return this.verifyEmail(req); return this.verifyEmail(req);
} }
); );
@@ -288,25 +288,25 @@ export class PublicAPIRouter extends PromiseRouter {
this.route( this.route(
'POST', 'POST',
'/apps/:appId/resend_verification_email', '/apps/:appId/resend_verification_email',
req => { (req) => {
this.setConfig(req); this.setConfig(req);
}, },
req => { (req) => {
return this.resendVerificationEmail(req); return this.resendVerificationEmail(req);
} }
); );
this.route('GET', '/apps/choose_password', req => { this.route('GET', '/apps/choose_password', (req) => {
return this.changePassword(req); return this.changePassword(req);
}); });
this.route( this.route(
'POST', 'POST',
'/apps/:appId/request_password_reset', '/apps/:appId/request_password_reset',
req => { (req) => {
this.setConfig(req); this.setConfig(req);
}, },
req => { (req) => {
return this.resetPassword(req); return this.resetPassword(req);
} }
); );
@@ -314,10 +314,10 @@ export class PublicAPIRouter extends PromiseRouter {
this.route( this.route(
'GET', 'GET',
'/apps/:appId/request_password_reset', '/apps/:appId/request_password_reset',
req => { (req) => {
this.setConfig(req); this.setConfig(req);
}, },
req => { (req) => {
return this.requestResetPassword(req); return this.requestResetPassword(req);
} }
); );

View File

@@ -21,7 +21,7 @@ export class PurgeRouter extends PromiseRouter {
} }
return { response: {} }; return { response: {} };
}) })
.catch(error => { .catch((error) => {
if (!error || (error && error.code === Parse.Error.OBJECT_NOT_FOUND)) { if (!error || (error && error.code === Parse.Error.OBJECT_NOT_FOUND)) {
return { response: {} }; return { response: {} };
} }
@@ -34,7 +34,7 @@ export class PurgeRouter extends PromiseRouter {
'DELETE', 'DELETE',
'/purge/:className', '/purge/:className',
middleware.promiseEnforceMasterKeyAccess, middleware.promiseEnforceMasterKeyAccess,
req => { (req) => {
return this.handlePurge(req); return this.handlePurge(req);
} }
); );

View File

@@ -29,12 +29,12 @@ export class PushRouter extends PromiseRouter {
const where = PushRouter.getQueryCondition(req); const where = PushRouter.getQueryCondition(req);
let resolve; let resolve;
const promise = new Promise(_resolve => { const promise = new Promise((_resolve) => {
resolve = _resolve; resolve = _resolve;
}); });
let pushStatusId; let pushStatusId;
pushController pushController
.sendPush(req.body, where, req.config, req.auth, objectId => { .sendPush(req.body, where, req.config, req.auth, (objectId) => {
pushStatusId = objectId; pushStatusId = objectId;
resolve({ resolve({
headers: { headers: {
@@ -45,7 +45,7 @@ export class PushRouter extends PromiseRouter {
}, },
}); });
}) })
.catch(err => { .catch((err) => {
req.config.loggerController.error( req.config.loggerController.error(
`_PushStatus ${pushStatusId}: error while sending push`, `_PushStatus ${pushStatusId}: error while sending push`,
err err

View File

@@ -6,19 +6,19 @@ export class RolesRouter extends ClassesRouter {
} }
mountRoutes() { mountRoutes() {
this.route('GET', '/roles', req => { this.route('GET', '/roles', (req) => {
return this.handleFind(req); return this.handleFind(req);
}); });
this.route('GET', '/roles/:objectId', req => { this.route('GET', '/roles/:objectId', (req) => {
return this.handleGet(req); return this.handleGet(req);
}); });
this.route('POST', '/roles', req => { this.route('POST', '/roles', (req) => {
return this.handleCreate(req); return this.handleCreate(req);
}); });
this.route('PUT', '/roles/:objectId', req => { this.route('PUT', '/roles/:objectId', (req) => {
return this.handleUpdate(req); return this.handleUpdate(req);
}); });
this.route('DELETE', '/roles/:objectId', req => { this.route('DELETE', '/roles/:objectId', (req) => {
return this.handleDelete(req); return this.handleDelete(req);
}); });
} }

View File

@@ -16,17 +16,17 @@ function classNameMismatchResponse(bodyClass, pathClass) {
function getAllSchemas(req) { function getAllSchemas(req) {
return req.config.database return req.config.database
.loadSchema({ clearCache: true }) .loadSchema({ clearCache: true })
.then(schemaController => schemaController.getAllClasses(true)) .then((schemaController) => schemaController.getAllClasses(true))
.then(schemas => ({ response: { results: schemas } })); .then((schemas) => ({ response: { results: schemas } }));
} }
function getOneSchema(req) { function getOneSchema(req) {
const className = req.params.className; const className = req.params.className;
return req.config.database return req.config.database
.loadSchema({ clearCache: true }) .loadSchema({ clearCache: true })
.then(schemaController => schemaController.getOneSchema(className, true)) .then((schemaController) => schemaController.getOneSchema(className, true))
.then(schema => ({ response: schema })) .then((schema) => ({ response: schema }))
.catch(error => { .catch((error) => {
if (error === undefined) { if (error === undefined) {
throw new Parse.Error( throw new Parse.Error(
Parse.Error.INVALID_CLASS_NAME, Parse.Error.INVALID_CLASS_NAME,
@@ -64,7 +64,7 @@ function createSchema(req) {
return req.config.database return req.config.database
.loadSchema({ clearCache: true }) .loadSchema({ clearCache: true })
.then(schema => .then((schema) =>
schema.addClassIfNotExists( schema.addClassIfNotExists(
className, className,
req.body.fields, req.body.fields,
@@ -72,7 +72,7 @@ function createSchema(req) {
req.body.indexes req.body.indexes
) )
) )
.then(schema => ({ response: schema })); .then((schema) => ({ response: schema }));
} }
function modifySchema(req) { function modifySchema(req) {
@@ -91,7 +91,7 @@ function modifySchema(req) {
return req.config.database return req.config.database
.loadSchema({ clearCache: true }) .loadSchema({ clearCache: true })
.then(schema => .then((schema) =>
schema.updateClass( schema.updateClass(
className, className,
submittedFields, submittedFields,
@@ -100,10 +100,10 @@ function modifySchema(req) {
req.config.database req.config.database
) )
) )
.then(result => ({ response: result })); .then((result) => ({ response: result }));
} }
const deleteSchema = req => { const deleteSchema = (req) => {
if (req.auth.isReadOnly) { if (req.auth.isReadOnly) {
throw new Parse.Error( throw new Parse.Error(
Parse.Error.OPERATION_FORBIDDEN, Parse.Error.OPERATION_FORBIDDEN,

View File

@@ -26,7 +26,7 @@ export class SessionsRouter extends ClassesRouter {
req.info.clientSDK, req.info.clientSDK,
req.info.context req.info.context
) )
.then(response => { .then((response) => {
if (!response.results || response.results.length == 0) { if (!response.results || response.results.length == 0) {
throw new Parse.Error( throw new Parse.Error(
Parse.Error.INVALID_SESSION_TOKEN, Parse.Error.INVALID_SESSION_TOKEN,
@@ -74,25 +74,25 @@ export class SessionsRouter extends ClassesRouter {
} }
mountRoutes() { mountRoutes() {
this.route('GET', '/sessions/me', req => { this.route('GET', '/sessions/me', (req) => {
return this.handleMe(req); return this.handleMe(req);
}); });
this.route('GET', '/sessions', req => { this.route('GET', '/sessions', (req) => {
return this.handleFind(req); return this.handleFind(req);
}); });
this.route('GET', '/sessions/:objectId', req => { this.route('GET', '/sessions/:objectId', (req) => {
return this.handleGet(req); return this.handleGet(req);
}); });
this.route('POST', '/sessions', req => { this.route('POST', '/sessions', (req) => {
return this.handleCreate(req); return this.handleCreate(req);
}); });
this.route('PUT', '/sessions/:objectId', req => { this.route('PUT', '/sessions/:objectId', (req) => {
return this.handleUpdate(req); return this.handleUpdate(req);
}); });
this.route('DELETE', '/sessions/:objectId', req => { this.route('DELETE', '/sessions/:objectId', (req) => {
return this.handleDelete(req); return this.handleDelete(req);
}); });
this.route('POST', '/upgradeToRevocableSession', req => { this.route('POST', '/upgradeToRevocableSession', (req) => {
return this.handleUpdateToRevocableSession(req); return this.handleUpdateToRevocableSession(req);
}); });
} }

View File

@@ -83,7 +83,7 @@ export class UsersRouter extends ClassesRouter {
} }
return req.config.database return req.config.database
.find('_User', query) .find('_User', query)
.then(results => { .then((results) => {
if (!results.length) { if (!results.length) {
throw new Parse.Error( throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND, Parse.Error.OBJECT_NOT_FOUND,
@@ -96,14 +96,14 @@ export class UsersRouter extends ClassesRouter {
req.config.loggerController.warn( req.config.loggerController.warn(
"There is a user which email is the same as another user's username, logging in based on username" "There is a user which email is the same as another user's username, logging in based on username"
); );
user = results.filter(user => user.username === username)[0]; user = results.filter((user) => user.username === username)[0];
} else { } else {
user = results[0]; user = results[0];
} }
return passwordCrypto.compare(password, user.password); return passwordCrypto.compare(password, user.password);
}) })
.then(correct => { .then((correct) => {
isValidPassword = correct; isValidPassword = correct;
const accountLockoutPolicy = new AccountLockout(user, req.config); const accountLockoutPolicy = new AccountLockout(user, req.config);
return accountLockoutPolicy.handleLoginAttempt(isValidPassword); return accountLockoutPolicy.handleLoginAttempt(isValidPassword);
@@ -145,7 +145,7 @@ export class UsersRouter extends ClassesRouter {
// Sometimes the authData still has null on that keys // Sometimes the authData still has null on that keys
// https://github.com/parse-community/parse-server/issues/935 // https://github.com/parse-community/parse-server/issues/935
if (user.authData) { if (user.authData) {
Object.keys(user.authData).forEach(provider => { Object.keys(user.authData).forEach((provider) => {
if (user.authData[provider] === null) { if (user.authData[provider] === null) {
delete user.authData[provider]; delete user.authData[provider];
} }
@@ -157,7 +157,7 @@ export class UsersRouter extends ClassesRouter {
return resolve(user); return resolve(user);
}) })
.catch(error => { .catch((error) => {
return reject(error); return reject(error);
}); });
}); });
@@ -181,7 +181,7 @@ export class UsersRouter extends ClassesRouter {
req.info.clientSDK, req.info.clientSDK,
req.info.context req.info.context
) )
.then(response => { .then((response) => {
if ( if (
!response.results || !response.results ||
response.results.length == 0 || response.results.length == 0 ||
@@ -282,13 +282,13 @@ export class UsersRouter extends ClassesRouter {
handleVerifyPassword(req) { handleVerifyPassword(req) {
return this._authenticateUserFromRequest(req) return this._authenticateUserFromRequest(req)
.then(user => { .then((user) => {
// Remove hidden properties. // Remove hidden properties.
UsersRouter.removeHiddenProperties(user); UsersRouter.removeHiddenProperties(user);
return { response: user }; return { response: user };
}) })
.catch(error => { .catch((error) => {
throw error; throw error;
}); });
} }
@@ -306,7 +306,7 @@ export class UsersRouter extends ClassesRouter {
req.info.clientSDK, req.info.clientSDK,
req.info.context req.info.context
) )
.then(records => { .then((records) => {
if (records.results && records.results.length) { if (records.results && records.results.length) {
return rest return rest
.del( .del(
@@ -383,7 +383,7 @@ export class UsersRouter extends ClassesRouter {
response: {}, response: {},
}); });
}, },
err => { (err) => {
if (err.code === Parse.Error.OBJECT_NOT_FOUND) { if (err.code === Parse.Error.OBJECT_NOT_FOUND) {
// Return success so that this endpoint can't // Return success so that this endpoint can't
// be used to enumerate valid emails // be used to enumerate valid emails
@@ -414,68 +414,70 @@ export class UsersRouter extends ClassesRouter {
); );
} }
return req.config.database.find('_User', { email: email }).then(results => { return req.config.database
if (!results.length || results.length < 1) { .find('_User', { email: email })
throw new Parse.Error( .then((results) => {
Parse.Error.EMAIL_NOT_FOUND, if (!results.length || results.length < 1) {
`No user found with email ${email}` throw new Parse.Error(
); Parse.Error.EMAIL_NOT_FOUND,
} `No user found with email ${email}`
const user = results[0]; );
}
const user = results[0];
// remove password field, messes with saving on postgres // remove password field, messes with saving on postgres
delete user.password; delete user.password;
if (user.emailVerified) { if (user.emailVerified) {
throw new Parse.Error( throw new Parse.Error(
Parse.Error.OTHER_CAUSE, Parse.Error.OTHER_CAUSE,
`Email ${email} is already verified.` `Email ${email} is already verified.`
); );
} }
const userController = req.config.userController; const userController = req.config.userController;
return userController.regenerateEmailVerifyToken(user).then(() => { return userController.regenerateEmailVerifyToken(user).then(() => {
userController.sendVerificationEmail(user); userController.sendVerificationEmail(user);
return { response: {} }; return { response: {} };
});
}); });
});
} }
mountRoutes() { mountRoutes() {
this.route('GET', '/users', req => { this.route('GET', '/users', (req) => {
return this.handleFind(req); return this.handleFind(req);
}); });
this.route('POST', '/users', req => { this.route('POST', '/users', (req) => {
return this.handleCreate(req); return this.handleCreate(req);
}); });
this.route('GET', '/users/me', req => { this.route('GET', '/users/me', (req) => {
return this.handleMe(req); return this.handleMe(req);
}); });
this.route('GET', '/users/:objectId', req => { this.route('GET', '/users/:objectId', (req) => {
return this.handleGet(req); return this.handleGet(req);
}); });
this.route('PUT', '/users/:objectId', req => { this.route('PUT', '/users/:objectId', (req) => {
return this.handleUpdate(req); return this.handleUpdate(req);
}); });
this.route('DELETE', '/users/:objectId', req => { this.route('DELETE', '/users/:objectId', (req) => {
return this.handleDelete(req); return this.handleDelete(req);
}); });
this.route('GET', '/login', req => { this.route('GET', '/login', (req) => {
return this.handleLogIn(req); return this.handleLogIn(req);
}); });
this.route('POST', '/login', req => { this.route('POST', '/login', (req) => {
return this.handleLogIn(req); return this.handleLogIn(req);
}); });
this.route('POST', '/logout', req => { this.route('POST', '/logout', (req) => {
return this.handleLogOut(req); return this.handleLogOut(req);
}); });
this.route('POST', '/requestPasswordReset', req => { this.route('POST', '/requestPasswordReset', (req) => {
return this.handleResetRequest(req); return this.handleResetRequest(req);
}); });
this.route('POST', '/verificationEmailRequest', req => { this.route('POST', '/verificationEmailRequest', (req) => {
return this.handleVerificationEmailRequest(req); return this.handleVerificationEmailRequest(req);
}); });
this.route('GET', '/verifyPassword', req => { this.route('GET', '/verifyPassword', (req) => {
return this.handleVerifyPassword(req); return this.handleVerifyPassword(req);
}); });
} }

View File

@@ -4,7 +4,7 @@ import { ParseServer } from '../index';
runner({ runner({
definitions, definitions,
start: function(program, options, logOptions) { start: function (program, options, logOptions) {
logOptions(); logOptions();
ParseServer.createLiveQueryServer(undefined, options); ParseServer.createLiveQueryServer(undefined, options);
}, },

View File

@@ -5,7 +5,7 @@ import cluster from 'cluster';
import os from 'os'; import os from 'os';
import runner from './utils/runner'; import runner from './utils/runner';
const help = function() { const help = function () {
console.log(' Get Started guide:'); console.log(' Get Started guide:');
console.log(''); console.log('');
console.log(' Please have a look at the get started guide!'); console.log(' Please have a look at the get started guide!');
@@ -39,7 +39,7 @@ runner({
definitions, definitions,
help, help,
usage: '[options] <path/to/configuration.json>', usage: '[options] <path/to/configuration.json>',
start: function(program, options, logOptions) { start: function (program, options, logOptions) {
if (!options.appId || !options.masterKey) { if (!options.appId || !options.masterKey) {
program.outputHelp(); program.outputHelp();
console.error(''); console.error('');

View File

@@ -38,7 +38,7 @@ var ParseCloud = {};
* @param {String} name The name of the Cloud Function * @param {String} name The name of the Cloud Function
* @param {Function} data The Cloud Function to register. This function can be an async function and should take one parameter a {@link Parse.Cloud.FunctionRequest}. * @param {Function} data The Cloud Function to register. This function can be an async function and should take one parameter a {@link Parse.Cloud.FunctionRequest}.
*/ */
ParseCloud.define = function(functionName, handler, validationHandler) { ParseCloud.define = function (functionName, handler, validationHandler) {
triggers.addFunction( triggers.addFunction(
functionName, functionName,
handler, handler,
@@ -58,7 +58,7 @@ ParseCloud.define = function(functionName, handler, validationHandler) {
* @param {Function} func The Background Job to register. This function can be async should take a single parameters a {@link Parse.Cloud.JobRequest} * @param {Function} func The Background Job to register. This function can be async should take a single parameters a {@link Parse.Cloud.JobRequest}
* *
*/ */
ParseCloud.job = function(functionName, handler) { ParseCloud.job = function (functionName, handler) {
triggers.addJob(functionName, handler, Parse.applicationId); triggers.addJob(functionName, handler, Parse.applicationId);
}; };
@@ -85,7 +85,7 @@ ParseCloud.job = function(functionName, handler) {
* @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass. * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass.
* @param {Function} func The function to run before a save. This function can be async and should take one parameter a {@link Parse.Cloud.TriggerRequest}; * @param {Function} func The function to run before a save. This function can be async and should take one parameter a {@link Parse.Cloud.TriggerRequest};
*/ */
ParseCloud.beforeSave = function(parseClass, handler) { ParseCloud.beforeSave = function (parseClass, handler) {
var className = getClassName(parseClass); var className = getClassName(parseClass);
triggers.addTrigger( triggers.addTrigger(
triggers.Types.beforeSave, triggers.Types.beforeSave,
@@ -116,7 +116,7 @@ ParseCloud.beforeSave = function(parseClass, handler) {
* @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the before delete function for. This can instead be a String that is the className of the subclass. * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the before delete function for. This can instead be a String that is the className of the subclass.
* @param {Function} func The function to run before a delete. This function can be async and should take one parameter, a {@link Parse.Cloud.TriggerRequest}. * @param {Function} func The function to run before a delete. This function can be async and should take one parameter, a {@link Parse.Cloud.TriggerRequest}.
*/ */
ParseCloud.beforeDelete = function(parseClass, handler) { ParseCloud.beforeDelete = function (parseClass, handler) {
var className = getClassName(parseClass); var className = getClassName(parseClass);
triggers.addTrigger( triggers.addTrigger(
triggers.Types.beforeDelete, triggers.Types.beforeDelete,
@@ -149,7 +149,7 @@ ParseCloud.beforeDelete = function(parseClass, handler) {
* @name Parse.Cloud.beforeLogin * @name Parse.Cloud.beforeLogin
* @param {Function} func The function to run before a login. This function can be async and should take one parameter a {@link Parse.Cloud.TriggerRequest}; * @param {Function} func The function to run before a login. This function can be async and should take one parameter a {@link Parse.Cloud.TriggerRequest};
*/ */
ParseCloud.beforeLogin = function(handler) { ParseCloud.beforeLogin = function (handler) {
let className = '_User'; let className = '_User';
if (typeof handler === 'string' || isParseObjectConstructor(handler)) { if (typeof handler === 'string' || isParseObjectConstructor(handler)) {
// validation will occur downstream, this is to maintain internal // validation will occur downstream, this is to maintain internal
@@ -185,7 +185,7 @@ ParseCloud.beforeLogin = function(handler) {
* @name Parse.Cloud.afterLogin * @name Parse.Cloud.afterLogin
* @param {Function} func The function to run after a login. This function can be async and should take one parameter a {@link Parse.Cloud.TriggerRequest}; * @param {Function} func The function to run after a login. This function can be async and should take one parameter a {@link Parse.Cloud.TriggerRequest};
*/ */
ParseCloud.afterLogin = function(handler) { ParseCloud.afterLogin = function (handler) {
let className = '_User'; let className = '_User';
if (typeof handler === 'string' || isParseObjectConstructor(handler)) { if (typeof handler === 'string' || isParseObjectConstructor(handler)) {
// validation will occur downstream, this is to maintain internal // validation will occur downstream, this is to maintain internal
@@ -220,7 +220,7 @@ ParseCloud.afterLogin = function(handler) {
* @name Parse.Cloud.afterLogout * @name Parse.Cloud.afterLogout
* @param {Function} func The function to run after a logout. This function can be async and should take one parameter a {@link Parse.Cloud.TriggerRequest}; * @param {Function} func The function to run after a logout. This function can be async and should take one parameter a {@link Parse.Cloud.TriggerRequest};
*/ */
ParseCloud.afterLogout = function(handler) { ParseCloud.afterLogout = function (handler) {
let className = '_Session'; let className = '_Session';
if (typeof handler === 'string' || isParseObjectConstructor(handler)) { if (typeof handler === 'string' || isParseObjectConstructor(handler)) {
// validation will occur downstream, this is to maintain internal // validation will occur downstream, this is to maintain internal
@@ -258,7 +258,7 @@ ParseCloud.afterLogout = function(handler) {
* @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass. * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass.
* @param {Function} func The function to run after a save. This function can be an async function and should take just one parameter, {@link Parse.Cloud.TriggerRequest}. * @param {Function} func The function to run after a save. This function can be an async function and should take just one parameter, {@link Parse.Cloud.TriggerRequest}.
*/ */
ParseCloud.afterSave = function(parseClass, handler) { ParseCloud.afterSave = function (parseClass, handler) {
var className = getClassName(parseClass); var className = getClassName(parseClass);
triggers.addTrigger( triggers.addTrigger(
triggers.Types.afterSave, triggers.Types.afterSave,
@@ -289,7 +289,7 @@ ParseCloud.afterSave = function(parseClass, handler) {
* @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after delete function for. This can instead be a String that is the className of the subclass. * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after delete function for. This can instead be a String that is the className of the subclass.
* @param {Function} func The function to run after a delete. This function can be async and should take just one parameter, {@link Parse.Cloud.TriggerRequest}. * @param {Function} func The function to run after a delete. This function can be async and should take just one parameter, {@link Parse.Cloud.TriggerRequest}.
*/ */
ParseCloud.afterDelete = function(parseClass, handler) { ParseCloud.afterDelete = function (parseClass, handler) {
var className = getClassName(parseClass); var className = getClassName(parseClass);
triggers.addTrigger( triggers.addTrigger(
triggers.Types.afterDelete, triggers.Types.afterDelete,
@@ -320,7 +320,7 @@ ParseCloud.afterDelete = function(parseClass, handler) {
* @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the before find function for. This can instead be a String that is the className of the subclass. * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the before find function for. This can instead be a String that is the className of the subclass.
* @param {Function} func The function to run before a find. This function can be async and should take just one parameter, {@link Parse.Cloud.BeforeFindRequest}. * @param {Function} func The function to run before a find. This function can be async and should take just one parameter, {@link Parse.Cloud.BeforeFindRequest}.
*/ */
ParseCloud.beforeFind = function(parseClass, handler) { ParseCloud.beforeFind = function (parseClass, handler) {
var className = getClassName(parseClass); var className = getClassName(parseClass);
triggers.addTrigger( triggers.addTrigger(
triggers.Types.beforeFind, triggers.Types.beforeFind,
@@ -351,7 +351,7 @@ ParseCloud.beforeFind = function(parseClass, handler) {
* @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after find function for. This can instead be a String that is the className of the subclass. * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after find function for. This can instead be a String that is the className of the subclass.
* @param {Function} func The function to run before a find. This function can be async and should take just one parameter, {@link Parse.Cloud.AfterFindRequest}. * @param {Function} func The function to run before a find. This function can be async and should take just one parameter, {@link Parse.Cloud.AfterFindRequest}.
*/ */
ParseCloud.afterFind = function(parseClass, handler) { ParseCloud.afterFind = function (parseClass, handler) {
const className = getClassName(parseClass); const className = getClassName(parseClass);
triggers.addTrigger( triggers.addTrigger(
triggers.Types.afterFind, triggers.Types.afterFind,
@@ -376,7 +376,7 @@ ParseCloud.afterFind = function(parseClass, handler) {
* @name Parse.Cloud.beforeSaveFile * @name Parse.Cloud.beforeSaveFile
* @param {Function} func The function to run before saving a file. This function can be async and should take just one parameter, {@link Parse.Cloud.FileTriggerRequest}. * @param {Function} func The function to run before saving a file. This function can be async and should take just one parameter, {@link Parse.Cloud.FileTriggerRequest}.
*/ */
ParseCloud.beforeSaveFile = function(handler) { ParseCloud.beforeSaveFile = function (handler) {
triggers.addFileTrigger( triggers.addFileTrigger(
triggers.Types.beforeSaveFile, triggers.Types.beforeSaveFile,
handler, handler,
@@ -399,7 +399,7 @@ ParseCloud.beforeSaveFile = function(handler) {
* @name Parse.Cloud.afterSaveFile * @name Parse.Cloud.afterSaveFile
* @param {Function} func The function to run after saving a file. This function can be async and should take just one parameter, {@link Parse.Cloud.FileTriggerRequest}. * @param {Function} func The function to run after saving a file. This function can be async and should take just one parameter, {@link Parse.Cloud.FileTriggerRequest}.
*/ */
ParseCloud.afterSaveFile = function(handler) { ParseCloud.afterSaveFile = function (handler) {
triggers.addFileTrigger( triggers.addFileTrigger(
triggers.Types.afterSaveFile, triggers.Types.afterSaveFile,
handler, handler,
@@ -422,11 +422,11 @@ ParseCloud.afterSaveFile = function(handler) {
* @name Parse.Cloud.beforeDeleteFile * @name Parse.Cloud.beforeDeleteFile
* @param {Function} func The function to run before deleting a file. This function can be async and should take just one parameter, {@link Parse.Cloud.FileTriggerRequest}. * @param {Function} func The function to run before deleting a file. This function can be async and should take just one parameter, {@link Parse.Cloud.FileTriggerRequest}.
*/ */
ParseCloud.beforeDeleteFile = function(handler) { ParseCloud.beforeDeleteFile = function (handler) {
triggers.addFileTrigger( triggers.addFileTrigger(
triggers.Types.beforeDeleteFile, triggers.Types.beforeDeleteFile,
handler, handler,
Parse.applicationId, Parse.applicationId
); );
}; };
@@ -445,15 +445,15 @@ ParseCloud.beforeDeleteFile = function(handler) {
* @name Parse.Cloud.afterDeleteFile * @name Parse.Cloud.afterDeleteFile
* @param {Function} func The function to after before deleting a file. This function can be async and should take just one parameter, {@link Parse.Cloud.FileTriggerRequest}. * @param {Function} func The function to after before deleting a file. This function can be async and should take just one parameter, {@link Parse.Cloud.FileTriggerRequest}.
*/ */
ParseCloud.afterDeleteFile = function(handler) { ParseCloud.afterDeleteFile = function (handler) {
triggers.addFileTrigger( triggers.addFileTrigger(
triggers.Types.afterDeleteFile, triggers.Types.afterDeleteFile,
handler, handler,
Parse.applicationId, Parse.applicationId
); );
}; };
ParseCloud.onLiveQueryEvent = function(handler) { ParseCloud.onLiveQueryEvent = function (handler) {
triggers.addLiveQueryEventHandler(handler, Parse.applicationId); triggers.addLiveQueryEventHandler(handler, Parse.applicationId);
}; };

View File

@@ -10,9 +10,9 @@ const clients = {
}; };
function makeCallback(resolve, reject) { function makeCallback(resolve, reject) {
return function(response) { return function (response) {
const chunks = []; const chunks = [];
response.on('data', chunk => { response.on('data', (chunk) => {
chunks.push(chunk); chunks.push(chunk);
}); });
response.on('end', () => { response.on('end', () => {
@@ -30,11 +30,11 @@ function makeCallback(resolve, reject) {
}; };
} }
const encodeBody = function({ body, headers = {} }) { const encodeBody = function ({ body, headers = {} }) {
if (typeof body !== 'object') { if (typeof body !== 'object') {
return { body, headers }; return { body, headers };
} }
var contentTypeKeys = Object.keys(headers).filter(key => { var contentTypeKeys = Object.keys(headers).filter((key) => {
return key.match(/content-type/i) != null; return key.match(/content-type/i) != null;
}); });
@@ -118,7 +118,7 @@ module.exports = function httpRequest(options) {
followRedirects: options.followRedirects === true, followRedirects: options.followRedirects === true,
}; };
if (requestOptions.headers) { if (requestOptions.headers) {
Object.keys(requestOptions.headers).forEach(key => { Object.keys(requestOptions.headers).forEach((key) => {
if (typeof requestOptions.headers[key] === 'undefined') { if (typeof requestOptions.headers[key] === 'undefined') {
delete requestOptions.headers[key]; delete requestOptions.headers[key];
} }
@@ -144,7 +144,7 @@ module.exports = function httpRequest(options) {
if (options.body) { if (options.body) {
req.write(options.body); req.write(options.body);
} }
req.on('error', error => { req.on('error', (error) => {
reject(error); reject(error);
}); });
req.end(); req.end();

View File

@@ -76,7 +76,7 @@ function urlParse(url, parseQueryString, slashesDenoteHost) {
} }
/* istanbul ignore next: improve coverage */ /* istanbul ignore next: improve coverage */
Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { Url.prototype.parse = function (url, parseQueryString, slashesDenoteHost) {
if (typeof url !== 'string') { if (typeof url !== 'string') {
throw new TypeError('Parameter "url" must be a string, not ' + typeof url); throw new TypeError('Parameter "url" must be a string, not ' + typeof url);
} }
@@ -528,7 +528,7 @@ function urlFormat(obj) {
} }
/* istanbul ignore next: improve coverage */ /* istanbul ignore next: improve coverage */
Url.prototype.format = function() { Url.prototype.format = function () {
var auth = this.auth || ''; var auth = this.auth || '';
if (auth) { if (auth) {
auth = encodeAuth(auth); auth = encodeAuth(auth);
@@ -611,7 +611,7 @@ function urlResolve(source, relative) {
} }
/* istanbul ignore next: improve coverage */ /* istanbul ignore next: improve coverage */
Url.prototype.resolve = function(relative) { Url.prototype.resolve = function (relative) {
return this.resolveObject(urlParse(relative, false, true)).format(); return this.resolveObject(urlParse(relative, false, true)).format();
}; };
@@ -622,7 +622,7 @@ function urlResolveObject(source, relative) {
} }
/* istanbul ignore next: improve coverage */ /* istanbul ignore next: improve coverage */
Url.prototype.resolveObject = function(relative) { Url.prototype.resolveObject = function (relative) {
if (typeof relative === 'string') { if (typeof relative === 'string') {
var rel = new Url(); var rel = new Url();
rel.parse(relative, false, true); rel.parse(relative, false, true);
@@ -912,7 +912,7 @@ Url.prototype.resolveObject = function(relative) {
}; };
/* istanbul ignore next: improve coverage */ /* istanbul ignore next: improve coverage */
Url.prototype.parseHost = function() { Url.prototype.parseHost = function () {
var host = this.host; var host = this.host;
var port = portPattern.exec(host); var port = portPattern.exec(host);
if (port) { if (port) {