From e6a6354b291a53709ec5bbbdff8b0d8855ad2808 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Mon, 13 Jul 2020 13:06:52 -0500 Subject: [PATCH] Run Prettier JS (#6795) --- package-lock.json | 82 +++++++++------------ package.json | 10 +-- spec/support/CustomAuth.js | 4 +- spec/support/CustomAuthFunction.js | 6 +- spec/support/CustomMiddleware.js | 2 +- src/Controllers/AnalyticsController.js | 4 +- src/Controllers/HooksController.js | 28 ++++---- src/Controllers/LoggerController.js | 6 +- src/Controllers/ParseGraphQLController.js | 8 +-- src/Controllers/PushController.js | 2 +- src/Controllers/SchemaCache.js | 4 +- src/Controllers/SchemaController.js | 60 ++++++++-------- src/Controllers/UserController.js | 16 ++--- src/GraphQL/ParseGraphQLServer.js | 4 +- src/GraphQL/parseGraphQLUtils.js | 8 +-- src/LiveQuery/Client.js | 2 +- src/LiveQuery/ParsePubSub.js | 4 +- src/LiveQuery/ParseWebSocketServer.js | 8 +-- src/LiveQuery/QueryTools.js | 2 +- src/LiveQuery/SessionTokenCache.js | 6 +- src/Options/parsers.js | 4 +- src/Push/PushWorker.js | 6 +- src/Push/utils.js | 10 +-- src/Routers/AggregateRouter.js | 10 +-- src/Routers/AudiencesRouter.js | 18 ++--- src/Routers/ClassesRouter.js | 16 ++--- src/Routers/CloudCodeRouter.js | 10 +-- src/Routers/FeaturesRouter.js | 2 +- src/Routers/FunctionsRouter.js | 22 +++--- src/Routers/GlobalConfigRouter.js | 6 +- src/Routers/GraphQLRouter.js | 4 +- src/Routers/HooksRouter.js | 14 ++-- src/Routers/IAPValidationRouter.js | 8 +-- src/Routers/InstallationsRouter.js | 12 ++-- src/Routers/LogsRouter.js | 4 +- src/Routers/PublicAPIRouter.js | 22 +++--- src/Routers/PurgeRouter.js | 4 +- src/Routers/PushRouter.js | 6 +- src/Routers/RolesRouter.js | 10 +-- src/Routers/SchemasRouter.js | 20 +++--- src/Routers/SessionsRouter.js | 16 ++--- src/Routers/UsersRouter.js | 88 ++++++++++++----------- src/cli/parse-live-query-server.js | 2 +- src/cli/parse-server.js | 4 +- src/cloud-code/Parse.Cloud.js | 36 +++++----- src/cloud-code/httpRequest.js | 12 ++-- src/vendor/mongodbUrl.js | 10 +-- 47 files changed, 313 insertions(+), 329 deletions(-) diff --git a/package-lock.json b/package-lock.json index cf34f023..1d008235 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,11 +47,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": { "version": "7.10.0", "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.10.0.tgz", @@ -1137,66 +1132,52 @@ } }, "@graphql-tools/delegate": { - "version": "6.0.12", - "resolved": "https://registry.npmjs.org/@graphql-tools/delegate/-/delegate-6.0.12.tgz", - "integrity": "sha512-52bac1Ct1s0c8aSTVCbnc5FI2LC+NqUFSs+5/mP1k5hIEW2GROGBeZdbRs2GQaHir1vKUYIyHzlZIIBMzOZ/gA==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@graphql-tools/delegate/-/delegate-6.0.1.tgz", + "integrity": "sha512-eb6KyskEOTOe3cJtqQGwoyjSxWZKvARPoS7bUB1ZY7SzSAFvDUomee3ercLVk9PTNwv+BE2ePpsFyAZkBhF4Xg==", "requires": { - "@ardatan/aggregate-error": "0.0.1", - "@graphql-tools/schema": "6.0.12", - "@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", + "@graphql-tools/schema": "6.0.1", + "@graphql-tools/utils": "6.0.1", "tslib": "~2.0.0" } }, "@graphql-tools/schema": { - "version": "6.0.12", - "resolved": "https://registry.npmjs.org/@graphql-tools/schema/-/schema-6.0.12.tgz", - "integrity": "sha512-XUmKJ+ipENaxuXIX4GapsLAUl1dFQBUg+S4ZbgtKVlwrPhZJ9bkjIqnUHk3wg4S4VXqzLX97ol1e4g9N6XLkYg==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@graphql-tools/schema/-/schema-6.0.1.tgz", + "integrity": "sha512-/X9Uji9BCulP5vx69pLD6TcmETRKl71qVAZbNUEURklpU3kty8zrCqs6gqO2nz4nEJzYRrXFTMf+zZ6L7Ae3ew==", "requires": { - "@graphql-tools/utils": "6.0.12", + "@graphql-tools/utils": "6.0.1", "tslib": "~2.0.0" } }, "@graphql-tools/stitch": { - "version": "6.0.12", - "resolved": "https://registry.npmjs.org/@graphql-tools/stitch/-/stitch-6.0.12.tgz", - "integrity": "sha512-I+9l5Ws30Fn3nx0CIDUDMGP0nhexMEJyzfQn1t9DuOTy2QHPQ5YpaZ8hxv6y5+X23EJBU9AebqvNSvWNEO6XJQ==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@graphql-tools/stitch/-/stitch-6.0.1.tgz", + "integrity": "sha512-2zQEYHpzQ67A59W3bD+YB+jjpAT24UT5a7Gpu5V4+sBsLEQdT0rnkUUQR4YYj4TshRDEPDbv2LcjuPAX3+QMPg==", "requires": { - "@graphql-tools/delegate": "6.0.12", - "@graphql-tools/merge": "6.0.12", - "@graphql-tools/schema": "6.0.12", - "@graphql-tools/utils": "6.0.12", - "@graphql-tools/wrap": "6.0.12", + "@graphql-tools/delegate": "6.0.1", + "@graphql-tools/schema": "6.0.1", + "@graphql-tools/utils": "6.0.1", + "@graphql-tools/wrap": "6.0.1", "tslib": "~2.0.0" } }, "@graphql-tools/utils": { - "version": "6.0.12", - "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-6.0.12.tgz", - "integrity": "sha512-MuFSkxXCe2QoD5QJPJ/1WIm0YnBzzXpkq9d/XznVAWptHFRwtwIbZ1xcREjYquFvoZ7ddsjZfyvUN/5ulmHhhg==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-6.0.1.tgz", + "integrity": "sha512-HqqJFYFG464ydL6XgUkwmYJLO/VzCsD86Bl25AX7aCLabPpn4O/pwCKSKRFsGQZvZbrth+urkHpyRU82Iqw2RQ==", "requires": { - "@ardatan/aggregate-error": "0.0.1", "camel-case": "4.1.1" } }, "@graphql-tools/wrap": { - "version": "6.0.12", - "resolved": "https://registry.npmjs.org/@graphql-tools/wrap/-/wrap-6.0.12.tgz", - "integrity": "sha512-x/t6004aNLzTbOFzZiau15fY2+TBy0wbFqP2du+I+yh8j6KmAU1YkPolBJ4bAI04WD3qcLNh7Rai+VhOxidOkw==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@graphql-tools/wrap/-/wrap-6.0.1.tgz", + "integrity": "sha512-8D5TZalct+7yqXbkv6fdpLs81/60T3EjL1SP/xAjvRlKCy3nrGL31xLeJmch6sqH3yQvzhD9sISmkjs6xTNAqQ==", "requires": { - "@graphql-tools/delegate": "6.0.12", - "@graphql-tools/schema": "6.0.12", - "@graphql-tools/utils": "6.0.12", - "aggregate-error": "3.0.1", + "@graphql-tools/delegate": "6.0.1", + "@graphql-tools/schema": "6.0.1", + "@graphql-tools/utils": "6.0.1", "tslib": "~2.0.0" } }, @@ -1786,6 +1767,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.0.1.tgz", "integrity": "sha512-quoaXsZ9/BLNae5yiNoUz+Nhkwz83GhWwtYFglcjEQB2NDHCIpApbqXxIFnm4Pq/Nvhrsq5sYJFyohrrxnTGAA==", + "dev": true, "requires": { "clean-stack": "^2.0.0", "indent-string": "^4.0.0" @@ -3065,7 +3047,8 @@ "clean-stack": { "version": "2.2.0", "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": { "version": "0.3.2", @@ -5491,9 +5474,9 @@ } }, "graphql-tag": { - "version": "2.10.3", - "resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.10.3.tgz", - "integrity": "sha512-4FOv3ZKfA4WdOKJeHdz6B3F/vxBLSgmBcGeAFPf4n1F64ltJUvOOerNj0rsJxONQGdhUMynQIvd6LzB+1J5oKA==" + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.10.1.tgz", + "integrity": "sha512-jApXqWBzNXQ8jYa/HLkZJaVw9jgwNqZkywa2zfFn16Iv1Zb7ELNHkJaXHR7Quvd5SIGsy6Ny7SUKATgnu05uEg==" }, "graphql-tools": { "version": "4.0.8", @@ -5864,7 +5847,8 @@ "indent-string": { "version": "4.0.0", "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": { "version": "1.12.0", diff --git a/package.json b/package.json index 819f84f3..b2b7d73f 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,8 @@ "license": "BSD-3-Clause", "dependencies": { "@apollographql/graphql-playground-html": "1.6.26", - "@graphql-tools/stitch": "^6.0.1", - "@graphql-tools/utils": "^6.0.1", + "@graphql-tools/stitch": "6.0.1", + "@graphql-tools/utils": "6.0.1", "@parse/fs-files-adapter": "1.0.1", "@parse/push-adapter": "3.2.0", "@parse/s3-files-adapter": "1.4.0", @@ -36,7 +36,7 @@ "follow-redirects": "1.12.1", "graphql": "15.1.0", "graphql-list-fields": "2.0.2", - "graphql-relay": "^0.6.0", + "graphql-relay": "0.6.0", "graphql-upload": "11.0.0", "intersect": "1.0.1", "jsonwebtoken": "8.5.1", @@ -48,7 +48,7 @@ "mongodb": "3.5.9", "parse": "2.14.0", "pg-promise": "10.5.7", - "pluralize": "^8.0.0", + "pluralize": "8.0.0", "redis": "3.0.2", "semver": "7.3.2", "subscriptions-transport-ws": "0.9.16", @@ -80,7 +80,7 @@ "eslint-plugin-flowtype": "5.1.3", "flow-bin": "0.119.1", "form-data": "3.0.0", - "graphql-tag": "^2.10.1", + "graphql-tag": "2.10.1", "husky": "4.2.5", "jasmine": "3.5.0", "jsdoc": "3.6.3", diff --git a/spec/support/CustomAuth.js b/spec/support/CustomAuth.js index 922b77ac..f6698e5b 100644 --- a/spec/support/CustomAuth.js +++ b/spec/support/CustomAuth.js @@ -1,8 +1,8 @@ module.exports = { - validateAppId: function() { + validateAppId: function () { return Promise.resolve(); }, - validateAuthData: function(authData) { + validateAuthData: function (authData) { if (authData.token == 'my-token') { return Promise.resolve(); } diff --git a/spec/support/CustomAuthFunction.js b/spec/support/CustomAuthFunction.js index 8dd5a31f..721ed543 100644 --- a/spec/support/CustomAuthFunction.js +++ b/spec/support/CustomAuthFunction.js @@ -1,9 +1,9 @@ -module.exports = function(validAuthData) { +module.exports = function (validAuthData) { return { - validateAppId: function() { + validateAppId: function () { return Promise.resolve(); }, - validateAuthData: function(authData) { + validateAuthData: function (authData) { if (authData.token == validAuthData.token) { return Promise.resolve(); } diff --git a/spec/support/CustomMiddleware.js b/spec/support/CustomMiddleware.js index 368500b8..97e71bd6 100644 --- a/spec/support/CustomMiddleware.js +++ b/spec/support/CustomMiddleware.js @@ -1,4 +1,4 @@ -module.exports = function(req, res, next) { +module.exports = function (req, res, next) { res.set('X-Yolo', '1'); next(); }; diff --git a/src/Controllers/AnalyticsController.js b/src/Controllers/AnalyticsController.js index 89aa48ed..9c316b3f 100644 --- a/src/Controllers/AnalyticsController.js +++ b/src/Controllers/AnalyticsController.js @@ -7,7 +7,7 @@ export class AnalyticsController extends AdaptableController { .then(() => { return this.adapter.appOpened(req.body, req); }) - .then(response => { + .then((response) => { return { response: response || {} }; }) .catch(() => { @@ -20,7 +20,7 @@ export class AnalyticsController extends AdaptableController { .then(() => { return this.adapter.trackEvent(req.params.eventName, req.body, req); }) - .then(response => { + .then((response) => { return { response: response || {} }; }) .catch(() => { diff --git a/src/Controllers/HooksController.js b/src/Controllers/HooksController.js index 3ac09b30..e2d2e65c 100644 --- a/src/Controllers/HooksController.js +++ b/src/Controllers/HooksController.js @@ -27,9 +27,9 @@ export class HooksController { } load() { - return this._getHooks().then(hooks => { + return this._getHooks().then((hooks) => { hooks = hooks || []; - hooks.forEach(hook => { + hooks.forEach((hook) => { this.addHookToTriggers(hook); }); }); @@ -37,7 +37,7 @@ export class HooksController { getFunction(functionName) { return this._getHooks({ functionName: functionName }).then( - results => results[0] + (results) => results[0] ); } @@ -49,7 +49,7 @@ export class HooksController { return this._getHooks({ className: className, triggerName: triggerName, - }).then(results => results[0]); + }).then((results) => results[0]); } getTriggers() { @@ -75,8 +75,8 @@ export class HooksController { _getHooks(query = {}) { return this.database .find(DefaultHooksCollectionName, query) - .then(results => { - return results.map(result => { + .then((results) => { + return results.map((result) => { delete result.objectId; return result; }); @@ -156,7 +156,7 @@ export class HooksController { createHook(aHook) { if (aHook.functionName) { - return this.getFunction(aHook.functionName).then(result => { + return this.getFunction(aHook.functionName).then((result) => { if (result) { throw new Parse.Error( 143, @@ -168,13 +168,11 @@ export class HooksController { }); } else if (aHook.className && aHook.triggerName) { return this.getTrigger(aHook.className, aHook.triggerName).then( - result => { + (result) => { if (result) { throw new Parse.Error( 143, - `class ${aHook.className} already has trigger ${ - aHook.triggerName - }` + `class ${aHook.className} already has trigger ${aHook.triggerName}` ); } return this.createOrUpdateHook(aHook); @@ -187,7 +185,7 @@ export class HooksController { updateHook(aHook) { if (aHook.functionName) { - return this.getFunction(aHook.functionName).then(result => { + return this.getFunction(aHook.functionName).then((result) => { if (result) { return this.createOrUpdateHook(aHook); } @@ -198,7 +196,7 @@ export class HooksController { }); } else if (aHook.className && aHook.triggerName) { return this.getTrigger(aHook.className, aHook.triggerName).then( - result => { + (result) => { if (result) { return this.createOrUpdateHook(aHook); } @@ -211,7 +209,7 @@ export class HooksController { } function wrapToHTTPRequest(hook, key) { - return req => { + return (req) => { const jsonBody = {}; for (var i in req) { jsonBody[i] = req[i]; @@ -245,7 +243,7 @@ function wrapToHTTPRequest(hook, key) { 'Making outgoing webhook request without webhookKey being set!' ); } - return request(jsonRequest).then(response => { + return request(jsonRequest).then((response) => { let err; let result; let body = response.data; diff --git a/src/Controllers/LoggerController.js b/src/Controllers/LoggerController.js index 54effc3d..9caac1ad 100644 --- a/src/Controllers/LoggerController.js +++ b/src/Controllers/LoggerController.js @@ -61,7 +61,7 @@ export class LoggerController extends AdaptableController { } maskSensitive(argArray) { - return argArray.map(e => { + return argArray.map((e) => { if (!e) { return e; } @@ -78,7 +78,7 @@ export class LoggerController extends AdaptableController { e.url = this.maskSensitiveUrl(e.url); } else if (Array.isArray(e.url)) { // for strings in array - e.url = e.url.map(item => { + e.url = e.url.map((item) => { if (typeof item === 'string') { return this.maskSensitiveUrl(item); } @@ -115,7 +115,7 @@ export class LoggerController extends AdaptableController { args = this.maskSensitive([...args]); args = [].concat( level, - args.map(arg => { + args.map((arg) => { if (typeof arg === 'function') { return arg(); } diff --git a/src/Controllers/ParseGraphQLController.js b/src/Controllers/ParseGraphQLController.js index 35919d8d..0f41e3ee 100644 --- a/src/Controllers/ParseGraphQLController.js +++ b/src/Controllers/ParseGraphQLController.js @@ -137,7 +137,7 @@ class ParseGraphQLController { } if (classConfigs !== null) { if (Array.isArray(classConfigs)) { - classConfigs.forEach(classConfig => { + classConfigs.forEach((classConfig) => { const errorMessage = this._validateClassConfig(classConfig); if (errorMessage) { errorMessages.push( @@ -332,9 +332,9 @@ class ParseGraphQLController { } } -const isValidStringArray = function(array): boolean { +const isValidStringArray = function (array): boolean { 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; }; /** @@ -342,7 +342,7 @@ const isValidStringArray = function(array): boolean { * object, i.e. not an array, null, date * etc. */ -const isValidSimpleObject = function(obj): boolean { +const isValidSimpleObject = function (obj): boolean { return ( typeof obj === 'object' && !Array.isArray(obj) && diff --git a/src/Controllers/PushController.js b/src/Controllers/PushController.js index 47392358..60c2ffb7 100644 --- a/src/Controllers/PushController.js +++ b/src/Controllers/PushController.js @@ -137,7 +137,7 @@ export class PushController { pushStatus ); }) - .catch(err => { + .catch((err) => { return pushStatus.fail(err).then(() => { throw err; }); diff --git a/src/Controllers/SchemaCache.js b/src/Controllers/SchemaCache.js index 55d70eab..4583c9c0 100644 --- a/src/Controllers/SchemaCache.js +++ b/src/Controllers/SchemaCache.js @@ -41,9 +41,9 @@ export default class SchemaCache { if (!this.ttl) { 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 || []; - const schema = cachedSchemas.find(cachedSchema => { + const schema = cachedSchemas.find((cachedSchema) => { return cachedSchema.className === className; }); if (schema) { diff --git a/src/Controllers/SchemaController.js b/src/Controllers/SchemaController.js index 435a4b55..fa2c05b3 100644 --- a/src/Controllers/SchemaController.js +++ b/src/Controllers/SchemaController.js @@ -545,7 +545,7 @@ class SchemaData { constructor(allSchemas = [], protectedFields = {}) { this.__data = {}; this.__protectedFields = protectedFields; - allSchemas.forEach(schema => { + allSchemas.forEach((schema) => { if (volatileClasses.includes(schema.className)) { return; } @@ -580,7 +580,7 @@ class SchemaData { }); // Inject the in-memory classes - volatileClasses.forEach(className => { + volatileClasses.forEach((className) => { Object.defineProperty(this, className, { get: () => { if (!this.__data[className]) { @@ -721,11 +721,11 @@ export default class SchemaController { } this.reloadDataPromise = this.getAllClasses(options) .then( - allSchemas => { + (allSchemas) => { this.schemaData = new SchemaData(allSchemas, this.protectedFields); delete this.reloadDataPromise; }, - err => { + (err) => { this.schemaData = new SchemaData(); delete this.reloadDataPromise; throw err; @@ -741,7 +741,7 @@ export default class SchemaController { if (options.clearCache) { return this.setAllClasses(); } - return this._cache.getAllClasses().then(allClasses => { + return this._cache.getAllClasses().then((allClasses) => { if (allClasses && allClasses.length) { return Promise.resolve(allClasses); } @@ -752,12 +752,12 @@ export default class SchemaController { setAllClasses(): Promise> { return this._dbAdapter .getAllClasses() - .then(allSchemas => allSchemas.map(injectDefaultSchema)) - .then(allSchemas => { + .then((allSchemas) => allSchemas.map(injectDefaultSchema)) + .then((allSchemas) => { /* eslint-disable no-console */ this._cache .setAllClasses(allSchemas) - .catch(error => + .catch((error) => console.error('Error saving schema to cache:', error) ); /* eslint-enable no-console */ @@ -784,13 +784,13 @@ export default class SchemaController { indexes: data.indexes, }); } - return this._cache.getOneSchema(className).then(cached => { + return this._cache.getOneSchema(className).then((cached) => { if (cached && !options.clearCache) { return Promise.resolve(cached); } - return this.setAllClasses().then(allSchemas => { + return this.setAllClasses().then((allSchemas) => { const oneSchema = allSchemas.find( - schema => schema.className === className + (schema) => schema.className === className ); if (!oneSchema) { return Promise.reject(undefined); @@ -841,7 +841,7 @@ export default class SchemaController { }) ) .then(convertAdapterSchemaToParseSchema) - .catch(error => { + .catch((error) => { if (error && error.code === Parse.Error.DUPLICATE_VALUE) { throw new Parse.Error( Parse.Error.INVALID_CLASS_NAME, @@ -861,9 +861,9 @@ export default class SchemaController { database: DatabaseController ) { return this.getOneSchema(className) - .then(schema => { + .then((schema) => { const existingFields = schema.fields; - Object.keys(submittedFields).forEach(name => { + Object.keys(submittedFields).forEach((name) => { const field = submittedFields[name]; if (existingFields[name] && field.__op !== 'Delete') { 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. const deletedFields: string[] = []; const insertedFields = []; - Object.keys(submittedFields).forEach(fieldName => { + Object.keys(submittedFields).forEach((fieldName) => { if (submittedFields[fieldName].__op === 'Delete') { deletedFields.push(fieldName); } else { @@ -916,14 +916,14 @@ export default class SchemaController { deletePromise // Delete Everything .then(() => this.reloadData({ clearCache: true })) // Reload our Schema, so we have all the new values .then(() => { - const promises = insertedFields.map(fieldName => { + const promises = insertedFields.map((fieldName) => { const type = submittedFields[fieldName]; return this.enforceFieldExists(className, fieldName, type); }); return Promise.all(promises); }) - .then(results => { - enforceFields = results.filter(result => !!result); + .then((results) => { + enforceFields = results.filter((result) => !!result); return this.setPermissions( className, classLevelPermissions, @@ -955,7 +955,7 @@ export default class SchemaController { }) ); }) - .catch(error => { + .catch((error) => { if (error === undefined) { throw new Parse.Error( Parse.Error.INVALID_CLASS_NAME, @@ -1095,7 +1095,7 @@ export default class SchemaController { } const geoPoints = Object.keys(fields).filter( - key => fields[key] && fields[key].type === 'GeoPoint' + (key) => fields[key] && fields[key].type === 'GeoPoint' ); if (geoPoints.length > 1) { return { @@ -1180,7 +1180,7 @@ export default class SchemaController { return this._dbAdapter .addFieldIfNotExists(className, fieldName, type) - .catch(error => { + .catch((error) => { if (error.code == Parse.Error.INCORRECT_TYPE) { // Make sure that we throw errors when it is appropriate to do so. throw error; @@ -1244,7 +1244,7 @@ export default class SchemaController { ); } - fieldNames.forEach(fieldName => { + fieldNames.forEach((fieldName) => { if (!fieldNameIsValid(fieldName)) { throw new Parse.Error( Parse.Error.INVALID_KEY_NAME, @@ -1258,7 +1258,7 @@ export default class SchemaController { }); return this.getOneSchema(className, false, { clearCache: true }) - .catch(error => { + .catch((error) => { if (error === undefined) { throw new Parse.Error( Parse.Error.INVALID_CLASS_NAME, @@ -1268,8 +1268,8 @@ export default class SchemaController { throw error; } }) - .then(schema => { - fieldNames.forEach(fieldName => { + .then((schema) => { + fieldNames.forEach((fieldName) => { if (!schema.fields[fieldName]) { throw new Parse.Error( 255, @@ -1283,7 +1283,7 @@ export default class SchemaController { .deleteFields(className, schema, fieldNames) .then(() => { return Promise.all( - fieldNames.map(fieldName => { + fieldNames.map((fieldName) => { const field = schemaFields[fieldName]; if (field && field.type === 'Relation') { //For relations, drop the _Join table @@ -1335,7 +1335,7 @@ export default class SchemaController { promises.push(schema.enforceFieldExists(className, fieldName, expected)); } const results = await Promise.all(promises); - const enforceFields = results.filter(result => !!result); + const enforceFields = results.filter((result) => !!result); if (enforceFields.length !== 0) { await this.reloadData({ clearCache: true }); @@ -1353,7 +1353,7 @@ export default class SchemaController { return Promise.resolve(this); } - const missingColumns = columns.filter(function(column) { + const missingColumns = columns.filter(function (column) { if (query && query.objectId) { if (object[column] && typeof object[column] === 'object') { // Trying to delete a required column @@ -1401,7 +1401,7 @@ export default class SchemaController { } // Check permissions against the aclGroup provided (array of userId/roles) if ( - aclGroup.some(acl => { + aclGroup.some((acl) => { return perms[acl] === true; }) ) { @@ -1594,7 +1594,7 @@ function buildMergedSchemaObject( // Given a schema promise, construct another schema promise that // validates this field once the schema loads. function thenValidateRequiredColumns(schemaPromise, className, object, query) { - return schemaPromise.then(schema => { + return schemaPromise.then((schema) => { return schema.validateRequiredColumns(className, object, query); }); } diff --git a/src/Controllers/UserController.js b/src/Controllers/UserController.js index 2d7b4444..3a00731d 100644 --- a/src/Controllers/UserController.js +++ b/src/Controllers/UserController.js @@ -70,7 +70,7 @@ export class UserController extends AdaptableController { '_User', { username: username, emailVerified: true } ); - return checkIfAlreadyVerified.execute().then(result => { + return checkIfAlreadyVerified.execute().then((result) => { if (result.results.length) { return Promise.resolve(result.results.length[0]); } @@ -88,7 +88,7 @@ export class UserController extends AdaptableController { }, { limit: 1 } ) - .then(results => { + .then((results) => { if (results.length != 1) { throw 'Failed to reset password: username / email / token is invalid'; } @@ -127,7 +127,7 @@ export class UserController extends AdaptableController { '_User', where ); - return query.execute().then(function(result) { + return query.execute().then(function (result) { if (result.results.length != 1) { throw undefined; } @@ -141,7 +141,7 @@ export class UserController extends AdaptableController { } const token = encodeURIComponent(user._email_verify_token); // 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 link = buildEmailLink( @@ -179,7 +179,7 @@ export class UserController extends AdaptableController { } resendVerificationEmail(username) { - return this.getUserIfNeeded({ username: username }).then(aUser => { + return this.getUserIfNeeded({ username: username }).then((aUser) => { if (!aUser || aUser.emailVerified) { throw undefined; } @@ -216,7 +216,7 @@ export class UserController extends AdaptableController { // TODO: No adapter? } - return this.setPasswordResetToken(email).then(user => { + return this.setPasswordResetToken(email).then((user) => { const token = encodeURIComponent(user._perishable_token); const username = encodeURIComponent(user.username); @@ -244,8 +244,8 @@ export class UserController extends AdaptableController { updatePassword(username, token, password) { return this.checkResetTokenValidity(username, token) - .then(user => updateUserPassword(user.objectId, password, this.config)) - .catch(error => { + .then((user) => updateUserPassword(user.objectId, password, this.config)) + .catch((error) => { if (error && error.message) { // in case of Parse.Error, fail with the error message only return Promise.reject(error.message); diff --git a/src/GraphQL/ParseGraphQLServer.js b/src/GraphQL/ParseGraphQLServer.js index a0417218..10f124b2 100644 --- a/src/GraphQL/ParseGraphQLServer.js +++ b/src/GraphQL/ParseGraphQLServer.js @@ -46,7 +46,7 @@ class ParseGraphQLServer { config: req.config, auth: req.auth, }, - formatError: error => { + formatError: (error) => { // Allow to console.log here to debug return error; }, @@ -91,7 +91,7 @@ class ParseGraphQLServer { app.use(this.config.graphQLPath, handleParseErrors); app.use( this.config.graphQLPath, - graphqlExpress(async req => await this._getGraphQLOptions(req)) + graphqlExpress(async (req) => await this._getGraphQLOptions(req)) ); } diff --git a/src/GraphQL/parseGraphQLUtils.js b/src/GraphQL/parseGraphQLUtils.js index 825f37dd..2d7b1238 100644 --- a/src/GraphQL/parseGraphQLUtils.js +++ b/src/GraphQL/parseGraphQLUtils.js @@ -22,13 +22,13 @@ export function toGraphQLError(error) { return new ApolloError(message, code); } -export const extractKeysAndInclude = selectedFields => { +export const extractKeysAndInclude = (selectedFields) => { selectedFields = selectedFields.filter( - field => !field.includes('__typename') + (field) => !field.includes('__typename') ); // Handles "id" field for both current and included objects - selectedFields = selectedFields.map(field => { + selectedFields = selectedFields.map((field) => { if (field === 'id') return 'objectId'; return field.endsWith('.id') ? `${field.substring(0, field.lastIndexOf('.id'))}.objectId` @@ -57,6 +57,6 @@ export const extractKeysAndInclude = selectedFields => { return { keys, include }; }; -export const getParseClassMutationConfig = function(parseClassConfig) { +export const getParseClassMutationConfig = function (parseClassConfig) { return (parseClassConfig && parseClassConfig.mutation) || {}; }; diff --git a/src/LiveQuery/Client.js b/src/LiveQuery/Client.js index 40e934d0..26cd9998 100644 --- a/src/LiveQuery/Client.js +++ b/src/LiveQuery/Client.js @@ -88,7 +88,7 @@ class Client { } _pushEvent(type: string): Function { - return function( + return function ( subscriptionId: number, parseObjectJSON: any, parseOriginalObjectJSON: any diff --git a/src/LiveQuery/ParsePubSub.js b/src/LiveQuery/ParsePubSub.js index 59639ea3..c8678abb 100644 --- a/src/LiveQuery/ParsePubSub.js +++ b/src/LiveQuery/ParsePubSub.js @@ -10,7 +10,7 @@ function useRedis(config: any): boolean { return typeof redisURL !== 'undefined' && redisURL !== ''; } -ParsePubSub.createPublisher = function(config: any): any { +ParsePubSub.createPublisher = function (config: any): any { if (useRedis(config)) { return RedisPubSub.createPublisher(config); } 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)) { return RedisPubSub.createSubscriber(config); } else { diff --git a/src/LiveQuery/ParseWebSocketServer.js b/src/LiveQuery/ParseWebSocketServer.js index 606056fc..418dcbca 100644 --- a/src/LiveQuery/ParseWebSocketServer.js +++ b/src/LiveQuery/ParseWebSocketServer.js @@ -12,8 +12,8 @@ export class ParseWebSocketServer { wss.onListen = () => { logger.info('Parse LiveQuery Server starts running'); }; - wss.onConnection = ws => { - ws.on('error', error => { + wss.onConnection = (ws) => { + ws.on('error', (error) => { logger.error(error.message); logger.error(JSON.stringify(ws)); }); @@ -27,7 +27,7 @@ export class ParseWebSocketServer { } }, config.websocketTimeout || 10 * 1000); }; - wss.onError = error => { + wss.onError = (error) => { logger.error(error); }; wss.start(); @@ -46,7 +46,7 @@ export class ParseWebSocket extends events.EventEmitter { constructor(ws: any) { super(); - ws.onmessage = request => + ws.onmessage = (request) => this.emit('message', request && request.data ? request.data : request); ws.onclose = () => this.emit('disconnect'); this.ws = ws; diff --git a/src/LiveQuery/QueryTools.js b/src/LiveQuery/QueryTools.js index c5e588d0..f3471bd1 100644 --- a/src/LiveQuery/QueryTools.js +++ b/src/LiveQuery/QueryTools.js @@ -191,7 +191,7 @@ function matchesKeyConstraints(object, key, constraints) { var compareTo; if (constraints.__type) { if (constraints.__type === 'Pointer') { - return equalObjectsGeneric(object[key], constraints, function(obj, ptr) { + return equalObjectsGeneric(object[key], constraints, function (obj, ptr) { return ( typeof obj !== 'undefined' && ptr.className === obj.className && diff --git a/src/LiveQuery/SessionTokenCache.js b/src/LiveQuery/SessionTokenCache.js index 282235ba..e02359ae 100644 --- a/src/LiveQuery/SessionTokenCache.js +++ b/src/LiveQuery/SessionTokenCache.js @@ -5,7 +5,7 @@ import logger from '../logger'; function userForSessionToken(sessionToken) { var q = new Parse.Query('_Session'); q.equalTo('sessionToken', sessionToken); - return q.first({ useMasterKey: true }).then(function(session) { + return q.first({ useMasterKey: true }).then(function (session) { if (!session) { return Promise.reject('No session found for session token'); } @@ -40,7 +40,7 @@ class SessionTokenCache { return Promise.resolve(userId); } return userForSessionToken(sessionToken).then( - user => { + (user) => { logger.verbose( 'Fetch userId %s of sessionToken %s from Parse', user.id, @@ -50,7 +50,7 @@ class SessionTokenCache { this.cache.set(sessionToken, userId); return Promise.resolve(userId); }, - error => { + (error) => { logger.error( 'Can not fetch userId for sessionToken %j, error %j', sessionToken, diff --git a/src/Options/parsers.js b/src/Options/parsers.js index e03fcaaa..812c1bc2 100644 --- a/src/Options/parsers.js +++ b/src/Options/parsers.js @@ -1,5 +1,5 @@ function numberParser(key) { - return function(opt) { + return function (opt) { const intOpt = parseInt(opt); if (!Number.isInteger(intOpt)) { throw new Error(`Key ${key} has invalid value ${opt}`); @@ -9,7 +9,7 @@ function numberParser(key) { } function numberOrBoolParser(key) { - return function(opt) { + return function (opt) { if (typeof opt === 'boolean') { return opt; } diff --git a/src/Push/PushWorker.js b/src/Push/PushWorker.js index d16542ae..6eac468b 100644 --- a/src/Push/PushWorker.js +++ b/src/Push/PushWorker.js @@ -76,7 +76,7 @@ export class PushWorker { installations, locales ); - const promises = Object.keys(grouppedInstallations).map(locale => { + const promises = Object.keys(grouppedInstallations).map((locale) => { const installations = grouppedInstallations[locale]; const body = bodiesPerLocales[locale]; return this.sendToAdapter( @@ -94,7 +94,7 @@ export class PushWorker { logger.verbose(`Sending push to ${installations.length}`); return this.adapter .send(body, installations, pushStatus.objectId) - .then(results => { + .then((results) => { return pushStatus.trackSent(results, UTCOffset).then(() => results); }); } @@ -103,7 +103,7 @@ export class PushWorker { const badgeInstallationsMap = groupByBadge(installations); // 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); payload.data.badge = parseInt(badge); const installations = badgeInstallationsMap[badge]; diff --git a/src/Push/utils.js b/src/Push/utils.js index ce702391..ad155097 100644 --- a/src/Push/utils.js +++ b/src/Push/utils.js @@ -29,7 +29,7 @@ export function getLocalesFromPush(body) { return [ ...new Set( Object.keys(data).reduce((memo, key) => { - localizableKeys.forEach(localizableKey => { + localizableKeys.forEach((localizableKey) => { if (key.indexOf(`${localizableKey}-`) == 0) { memo.push(key.slice(localizableKey.length + 1)); } @@ -46,7 +46,7 @@ export function transformPushBodyForLocale(body, locale) { return body; } body = deepcopy(body); - localizableKeys.forEach(key => { + localizableKeys.forEach((key) => { const localeValue = body.data[`${key}-${locale}`]; if (localeValue) { body.data[key] = localeValue; @@ -59,8 +59,8 @@ export function stripLocalesFromBody(body) { if (!body.data) { return body; } - Object.keys(body.data).forEach(key => { - localizableKeys.forEach(localizableKey => { + Object.keys(body.data).forEach((key) => { + localizableKeys.forEach((localizableKey) => { if (key.indexOf(`${localizableKey}-`) == 0) { delete body.data[key]; } @@ -84,7 +84,7 @@ export function groupByLocaleIdentifier(installations, locales = []) { return installations.reduce( (map, installation) => { let added = false; - locales.forEach(locale => { + locales.forEach((locale) => { if (added) { return; } diff --git a/src/Routers/AggregateRouter.js b/src/Routers/AggregateRouter.js index f68400ab..fd6a70a6 100644 --- a/src/Routers/AggregateRouter.js +++ b/src/Routers/AggregateRouter.js @@ -70,9 +70,9 @@ export class AggregateRouter extends ClassesRouter { body.where, options, req.info.clientSDK, - req.info.context, + req.info.context ) - .then(response => { + .then((response) => { for (const result of response.results) { if (typeof result === 'object') { UsersRouter.removeHiddenProperties(result); @@ -110,12 +110,12 @@ export class AggregateRouter extends ClassesRouter { static getPipeline(body) { let pipeline = body.pipeline || body; if (!Array.isArray(pipeline)) { - pipeline = Object.keys(pipeline).map(key => { + pipeline = Object.keys(pipeline).map((key) => { return { [key]: pipeline[key] }; }); } - return pipeline.map(stage => { + return pipeline.map((stage) => { const keys = Object.keys(stage); if (keys.length != 1) { throw new Error( @@ -157,7 +157,7 @@ export class AggregateRouter extends ClassesRouter { 'GET', '/aggregate/:className', middleware.promiseEnforceMasterKeyAccess, - req => { + (req) => { return this.handleFind(req); } ); diff --git a/src/Routers/AudiencesRouter.js b/src/Routers/AudiencesRouter.js index ecf4a22f..1d915505 100644 --- a/src/Routers/AudiencesRouter.js +++ b/src/Routers/AudiencesRouter.js @@ -22,10 +22,10 @@ export class AudiencesRouter extends ClassesRouter { body.where, options, req.info.clientSDK, - req.info.context, + req.info.context ) - .then(response => { - response.results.forEach(item => { + .then((response) => { + response.results.forEach((item) => { item.query = JSON.parse(item.query); }); @@ -34,7 +34,7 @@ export class AudiencesRouter extends ClassesRouter { } handleGet(req) { - return super.handleGet(req).then(data => { + return super.handleGet(req).then((data) => { data.response.query = JSON.parse(data.response.query); return data; @@ -46,7 +46,7 @@ export class AudiencesRouter extends ClassesRouter { 'GET', '/push_audiences', middleware.promiseEnforceMasterKeyAccess, - req => { + (req) => { return this.handleFind(req); } ); @@ -54,7 +54,7 @@ export class AudiencesRouter extends ClassesRouter { 'GET', '/push_audiences/:objectId', middleware.promiseEnforceMasterKeyAccess, - req => { + (req) => { return this.handleGet(req); } ); @@ -62,7 +62,7 @@ export class AudiencesRouter extends ClassesRouter { 'POST', '/push_audiences', middleware.promiseEnforceMasterKeyAccess, - req => { + (req) => { return this.handleCreate(req); } ); @@ -70,7 +70,7 @@ export class AudiencesRouter extends ClassesRouter { 'PUT', '/push_audiences/:objectId', middleware.promiseEnforceMasterKeyAccess, - req => { + (req) => { return this.handleUpdate(req); } ); @@ -78,7 +78,7 @@ export class AudiencesRouter extends ClassesRouter { 'DELETE', '/push_audiences/:objectId', middleware.promiseEnforceMasterKeyAccess, - req => { + (req) => { return this.handleDelete(req); } ); diff --git a/src/Routers/ClassesRouter.js b/src/Routers/ClassesRouter.js index 9a2469c2..d86ee76d 100644 --- a/src/Routers/ClassesRouter.js +++ b/src/Routers/ClassesRouter.js @@ -41,9 +41,9 @@ export class ClassesRouter extends PromiseRouter { body.where, options, req.info.clientSDK, - req.info.context, + req.info.context ) - .then(response => { + .then((response) => { return { response: response }; }); } @@ -93,7 +93,7 @@ export class ClassesRouter extends PromiseRouter { options, req.info.clientSDK ) - .then(response => { + .then((response) => { if (!response.results || response.results.length == 0) { throw new Parse.Error( Parse.Error.OBJECT_NOT_FOUND, @@ -241,19 +241,19 @@ export class ClassesRouter extends PromiseRouter { } mountRoutes() { - this.route('GET', '/classes/:className', req => { + this.route('GET', '/classes/:className', (req) => { return this.handleFind(req); }); - this.route('GET', '/classes/:className/:objectId', req => { + this.route('GET', '/classes/:className/:objectId', (req) => { return this.handleGet(req); }); - this.route('POST', '/classes/:className', req => { + this.route('POST', '/classes/:className', (req) => { return this.handleCreate(req); }); - this.route('PUT', '/classes/:className/:objectId', req => { + this.route('PUT', '/classes/:className/:objectId', (req) => { return this.handleUpdate(req); }); - this.route('DELETE', '/classes/:className/:objectId', req => { + this.route('DELETE', '/classes/:className/:objectId', (req) => { return this.handleDelete(req); }); } diff --git a/src/Routers/CloudCodeRouter.js b/src/Routers/CloudCodeRouter.js index 9f4a82a2..3c3ef4f1 100644 --- a/src/Routers/CloudCodeRouter.js +++ b/src/Routers/CloudCodeRouter.js @@ -58,7 +58,7 @@ export class CloudCodeRouter extends PromiseRouter { static getJobs(req) { return rest .find(req.config, req.auth, '_JobSchedule', {}, {}) - .then(scheduledJobs => { + .then((scheduledJobs) => { return { response: scheduledJobs.results, }; @@ -70,10 +70,10 @@ export class CloudCodeRouter extends PromiseRouter { const jobs = triggers.getJobs(config.applicationId) || {}; return rest .find(req.config, req.auth, '_JobSchedule', {}, {}) - .then(scheduledJobs => { + .then((scheduledJobs) => { return { response: { - in_use: scheduledJobs.results.map(job => job.jobName), + in_use: scheduledJobs.results.map((job) => job.jobName), jobs: Object.keys(jobs), }, }; @@ -107,7 +107,7 @@ export class CloudCodeRouter extends PromiseRouter { undefined, req.info.context ) - .then(response => { + .then((response) => { return { response, }; @@ -118,7 +118,7 @@ export class CloudCodeRouter extends PromiseRouter { const { objectId } = req.params; return rest .del(req.config, req.auth, '_JobSchedule', objectId, req.info.context) - .then(response => { + .then((response) => { return { response, }; diff --git a/src/Routers/FeaturesRouter.js b/src/Routers/FeaturesRouter.js index c0cc56d7..4822d135 100644 --- a/src/Routers/FeaturesRouter.js +++ b/src/Routers/FeaturesRouter.js @@ -8,7 +8,7 @@ export class FeaturesRouter extends PromiseRouter { 'GET', '/serverInfo', middleware.promiseEnforceMasterKeyAccess, - req => { + (req) => { const { config } = req; const features = { globalConfig: { diff --git a/src/Routers/FunctionsRouter.js b/src/Routers/FunctionsRouter.js index 9b5bcd2d..56a18de2 100644 --- a/src/Routers/FunctionsRouter.js +++ b/src/Routers/FunctionsRouter.js @@ -11,7 +11,7 @@ import { logger } from '../logger'; function parseObject(obj) { if (Array.isArray(obj)) { - return obj.map(item => { + return obj.map((item) => { return parseObject(item); }); } else if (obj && obj.__type == 'Date') { @@ -40,11 +40,11 @@ export class FunctionsRouter extends PromiseRouter { 'POST', '/jobs/:jobName', promiseEnforceMasterKeyAccess, - function(req) { + function (req) { return FunctionsRouter.handleCloudJob(req); } ); - this.route('POST', '/jobs', promiseEnforceMasterKeyAccess, function(req) { + this.route('POST', '/jobs', promiseEnforceMasterKeyAccess, function (req) { return FunctionsRouter.handleCloudJob(req); }); } @@ -68,7 +68,7 @@ export class FunctionsRouter extends PromiseRouter { message: jobHandler.setMessage.bind(jobHandler), }; - return jobHandler.setRunning(jobName, params).then(jobStatus => { + return jobHandler.setRunning(jobName, params).then((jobStatus) => { request.jobId = jobStatus.objectId; // run the function async process.nextTick(() => { @@ -77,10 +77,10 @@ export class FunctionsRouter extends PromiseRouter { return jobFunction(request); }) .then( - result => { + (result) => { jobHandler.setSucceeded(result); }, - error => { + (error) => { jobHandler.setFailed(error); } ); @@ -96,14 +96,14 @@ export class FunctionsRouter extends PromiseRouter { static createResponseObject(resolve, reject, message) { return { - success: function(result) { + success: function (result) { resolve({ response: { result: Parse._encode(result), }, }); }, - error: function(message) { + error: function (message) { // parse error, process away if (message instanceof Parse.Error) { 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 = req.auth && req.auth.user ? req.auth.user.id : undefined; const cleanInput = logger.truncateLogMessage(JSON.stringify(params)); const { success, error, message } = FunctionsRouter.createResponseObject( - result => { + (result) => { try { const cleanResult = logger.truncateLogMessage( JSON.stringify(result.response.result) @@ -184,7 +184,7 @@ export class FunctionsRouter extends PromiseRouter { reject(e); } }, - error => { + (error) => { try { logger.error( `Failed running cloud function ${functionName} for user ${userString} with:\n Input: ${cleanInput}\n Error: ` + diff --git a/src/Routers/GlobalConfigRouter.js b/src/Routers/GlobalConfigRouter.js index ca189ead..3173e380 100644 --- a/src/Routers/GlobalConfigRouter.js +++ b/src/Routers/GlobalConfigRouter.js @@ -7,7 +7,7 @@ export class GlobalConfigRouter extends PromiseRouter { getGlobalConfig(req) { return req.config.database .find('_GlobalConfig', { objectId: '1' }, { limit: 1 }) - .then(results => { + .then((results) => { if (results.length != 1) { // If there is no config in the database - return empty config. return { response: { params: {} } }; @@ -51,14 +51,14 @@ export class GlobalConfigRouter extends PromiseRouter { } mountRoutes() { - this.route('GET', '/config', req => { + this.route('GET', '/config', (req) => { return this.getGlobalConfig(req); }); this.route( 'PUT', '/config', middleware.promiseEnforceMasterKeyAccess, - req => { + (req) => { return this.updateGlobalConfig(req); } ); diff --git a/src/Routers/GraphQLRouter.js b/src/Routers/GraphQLRouter.js index cdf25659..9dc006b5 100644 --- a/src/Routers/GraphQLRouter.js +++ b/src/Routers/GraphQLRouter.js @@ -32,7 +32,7 @@ export class GraphQLRouter extends PromiseRouter { 'GET', GraphQLConfigPath, middleware.promiseEnforceMasterKeyAccess, - req => { + (req) => { return this.getGraphQLConfig(req); } ); @@ -40,7 +40,7 @@ export class GraphQLRouter extends PromiseRouter { 'PUT', GraphQLConfigPath, middleware.promiseEnforceMasterKeyAccess, - req => { + (req) => { return this.updateGraphQLConfig(req); } ); diff --git a/src/Routers/HooksRouter.js b/src/Routers/HooksRouter.js index 404094cb..16d37de0 100644 --- a/src/Routers/HooksRouter.js +++ b/src/Routers/HooksRouter.js @@ -6,13 +6,13 @@ export class HooksRouter extends PromiseRouter { createHook(aHook, config) { return config.hooksController .createHook(aHook) - .then(hook => ({ response: hook })); + .then((hook) => ({ response: hook })); } updateHook(aHook, config) { return config.hooksController .updateHook(aHook) - .then(hook => ({ response: hook })); + .then((hook) => ({ response: hook })); } handlePost(req) { @@ -24,7 +24,7 @@ export class HooksRouter extends PromiseRouter { if (req.params.functionName) { return hooksController .getFunction(req.params.functionName) - .then(foundFunction => { + .then((foundFunction) => { if (!foundFunction) { throw new Parse.Error( 143, @@ -36,10 +36,10 @@ export class HooksRouter extends PromiseRouter { } return hooksController.getFunctions().then( - functions => { + (functions) => { return { response: functions || [] }; }, - err => { + (err) => { throw err; } ); @@ -50,7 +50,7 @@ export class HooksRouter extends PromiseRouter { if (req.params.className && req.params.triggerName) { return hooksController .getTrigger(req.params.className, req.params.triggerName) - .then(foundTrigger => { + .then((foundTrigger) => { if (!foundTrigger) { throw new Parse.Error( 143, @@ -63,7 +63,7 @@ export class HooksRouter extends PromiseRouter { return hooksController .getTriggers() - .then(triggers => ({ response: triggers || [] })); + .then((triggers) => ({ response: triggers || [] })); } handleDelete(req) { diff --git a/src/Routers/IAPValidationRouter.js b/src/Routers/IAPValidationRouter.js index 2e67c526..58fb6815 100644 --- a/src/Routers/IAPValidationRouter.js +++ b/src/Routers/IAPValidationRouter.js @@ -32,7 +32,7 @@ function validateWithAppStore(url, receipt) { headers: { 'Content-Type': 'application/json', }, - }).then(httpResponse => { + }).then((httpResponse) => { const body = httpResponse.data; if (body && body.status === 0) { // No need to pass anything, status is OK @@ -54,7 +54,7 @@ function getFileForProductIdentifier(productIdentifier, req) { req.info.clientSDK, req.info.context ) - .then(function(result) { + .then(function (result) { const products = result.results; if (!products || products.length != 1) { // Error not found or too many @@ -106,13 +106,13 @@ export class IAPValidationRouter extends PromiseRouter { () => { return successCallback(); }, - error => { + (error) => { if (error.status == 21007) { return validateWithAppStore(IAP_SANDBOX_URL, receipt).then( () => { return successCallback(); }, - error => { + (error) => { return errorCallback(error); } ); diff --git a/src/Routers/InstallationsRouter.js b/src/Routers/InstallationsRouter.js index 28876b7f..c40f1345 100644 --- a/src/Routers/InstallationsRouter.js +++ b/src/Routers/InstallationsRouter.js @@ -24,25 +24,25 @@ export class InstallationsRouter extends ClassesRouter { req.info.clientSDK, req.info.context ) - .then(response => { + .then((response) => { return { response: response }; }); } mountRoutes() { - this.route('GET', '/installations', req => { + this.route('GET', '/installations', (req) => { return this.handleFind(req); }); - this.route('GET', '/installations/:objectId', req => { + this.route('GET', '/installations/:objectId', (req) => { return this.handleGet(req); }); - this.route('POST', '/installations', req => { + this.route('POST', '/installations', (req) => { return this.handleCreate(req); }); - this.route('PUT', '/installations/:objectId', req => { + this.route('PUT', '/installations/:objectId', (req) => { return this.handleUpdate(req); }); - this.route('DELETE', '/installations/:objectId', req => { + this.route('DELETE', '/installations/:objectId', (req) => { return this.handleDelete(req); }); } diff --git a/src/Routers/LogsRouter.js b/src/Routers/LogsRouter.js index 0bc2e234..93dbed21 100644 --- a/src/Routers/LogsRouter.js +++ b/src/Routers/LogsRouter.js @@ -9,7 +9,7 @@ export class LogsRouter extends PromiseRouter { '/scriptlog', middleware.promiseEnforceMasterKeyAccess, this.validateRequest, - req => { + (req) => { return this.handleGET(req); } ); @@ -50,7 +50,7 @@ export class LogsRouter extends PromiseRouter { level, }; - return req.config.loggerController.getLogs(options).then(result => { + return req.config.loggerController.getLogs(options).then((result) => { return Promise.resolve({ response: result, }); diff --git a/src/Routers/PublicAPIRouter.js b/src/Routers/PublicAPIRouter.js index 74538354..41b94389 100644 --- a/src/Routers/PublicAPIRouter.js +++ b/src/Routers/PublicAPIRouter.js @@ -191,14 +191,14 @@ export class PublicAPIRouter extends PromiseRouter { success: true, }); }, - err => { + (err) => { return Promise.resolve({ success: false, err, }); } ) - .then(result => { + .then((result) => { const params = qs.stringify({ username: username, token: token, @@ -277,10 +277,10 @@ export class PublicAPIRouter extends PromiseRouter { this.route( 'GET', '/apps/:appId/verify_email', - req => { + (req) => { this.setConfig(req); }, - req => { + (req) => { return this.verifyEmail(req); } ); @@ -288,25 +288,25 @@ export class PublicAPIRouter extends PromiseRouter { this.route( 'POST', '/apps/:appId/resend_verification_email', - req => { + (req) => { this.setConfig(req); }, - req => { + (req) => { return this.resendVerificationEmail(req); } ); - this.route('GET', '/apps/choose_password', req => { + this.route('GET', '/apps/choose_password', (req) => { return this.changePassword(req); }); this.route( 'POST', '/apps/:appId/request_password_reset', - req => { + (req) => { this.setConfig(req); }, - req => { + (req) => { return this.resetPassword(req); } ); @@ -314,10 +314,10 @@ export class PublicAPIRouter extends PromiseRouter { this.route( 'GET', '/apps/:appId/request_password_reset', - req => { + (req) => { this.setConfig(req); }, - req => { + (req) => { return this.requestResetPassword(req); } ); diff --git a/src/Routers/PurgeRouter.js b/src/Routers/PurgeRouter.js index 6d0aca0c..86abe902 100644 --- a/src/Routers/PurgeRouter.js +++ b/src/Routers/PurgeRouter.js @@ -21,7 +21,7 @@ export class PurgeRouter extends PromiseRouter { } return { response: {} }; }) - .catch(error => { + .catch((error) => { if (!error || (error && error.code === Parse.Error.OBJECT_NOT_FOUND)) { return { response: {} }; } @@ -34,7 +34,7 @@ export class PurgeRouter extends PromiseRouter { 'DELETE', '/purge/:className', middleware.promiseEnforceMasterKeyAccess, - req => { + (req) => { return this.handlePurge(req); } ); diff --git a/src/Routers/PushRouter.js b/src/Routers/PushRouter.js index b6542fce..f1c9f946 100644 --- a/src/Routers/PushRouter.js +++ b/src/Routers/PushRouter.js @@ -29,12 +29,12 @@ export class PushRouter extends PromiseRouter { const where = PushRouter.getQueryCondition(req); let resolve; - const promise = new Promise(_resolve => { + const promise = new Promise((_resolve) => { resolve = _resolve; }); let pushStatusId; pushController - .sendPush(req.body, where, req.config, req.auth, objectId => { + .sendPush(req.body, where, req.config, req.auth, (objectId) => { pushStatusId = objectId; resolve({ headers: { @@ -45,7 +45,7 @@ export class PushRouter extends PromiseRouter { }, }); }) - .catch(err => { + .catch((err) => { req.config.loggerController.error( `_PushStatus ${pushStatusId}: error while sending push`, err diff --git a/src/Routers/RolesRouter.js b/src/Routers/RolesRouter.js index e6a10df7..e36f02c6 100644 --- a/src/Routers/RolesRouter.js +++ b/src/Routers/RolesRouter.js @@ -6,19 +6,19 @@ export class RolesRouter extends ClassesRouter { } mountRoutes() { - this.route('GET', '/roles', req => { + this.route('GET', '/roles', (req) => { return this.handleFind(req); }); - this.route('GET', '/roles/:objectId', req => { + this.route('GET', '/roles/:objectId', (req) => { return this.handleGet(req); }); - this.route('POST', '/roles', req => { + this.route('POST', '/roles', (req) => { return this.handleCreate(req); }); - this.route('PUT', '/roles/:objectId', req => { + this.route('PUT', '/roles/:objectId', (req) => { return this.handleUpdate(req); }); - this.route('DELETE', '/roles/:objectId', req => { + this.route('DELETE', '/roles/:objectId', (req) => { return this.handleDelete(req); }); } diff --git a/src/Routers/SchemasRouter.js b/src/Routers/SchemasRouter.js index efc831dc..3c294569 100644 --- a/src/Routers/SchemasRouter.js +++ b/src/Routers/SchemasRouter.js @@ -16,17 +16,17 @@ function classNameMismatchResponse(bodyClass, pathClass) { function getAllSchemas(req) { return req.config.database .loadSchema({ clearCache: true }) - .then(schemaController => schemaController.getAllClasses(true)) - .then(schemas => ({ response: { results: schemas } })); + .then((schemaController) => schemaController.getAllClasses(true)) + .then((schemas) => ({ response: { results: schemas } })); } function getOneSchema(req) { const className = req.params.className; return req.config.database .loadSchema({ clearCache: true }) - .then(schemaController => schemaController.getOneSchema(className, true)) - .then(schema => ({ response: schema })) - .catch(error => { + .then((schemaController) => schemaController.getOneSchema(className, true)) + .then((schema) => ({ response: schema })) + .catch((error) => { if (error === undefined) { throw new Parse.Error( Parse.Error.INVALID_CLASS_NAME, @@ -64,7 +64,7 @@ function createSchema(req) { return req.config.database .loadSchema({ clearCache: true }) - .then(schema => + .then((schema) => schema.addClassIfNotExists( className, req.body.fields, @@ -72,7 +72,7 @@ function createSchema(req) { req.body.indexes ) ) - .then(schema => ({ response: schema })); + .then((schema) => ({ response: schema })); } function modifySchema(req) { @@ -91,7 +91,7 @@ function modifySchema(req) { return req.config.database .loadSchema({ clearCache: true }) - .then(schema => + .then((schema) => schema.updateClass( className, submittedFields, @@ -100,10 +100,10 @@ function modifySchema(req) { req.config.database ) ) - .then(result => ({ response: result })); + .then((result) => ({ response: result })); } -const deleteSchema = req => { +const deleteSchema = (req) => { if (req.auth.isReadOnly) { throw new Parse.Error( Parse.Error.OPERATION_FORBIDDEN, diff --git a/src/Routers/SessionsRouter.js b/src/Routers/SessionsRouter.js index dac7cff8..6d5e4b01 100644 --- a/src/Routers/SessionsRouter.js +++ b/src/Routers/SessionsRouter.js @@ -26,7 +26,7 @@ export class SessionsRouter extends ClassesRouter { req.info.clientSDK, req.info.context ) - .then(response => { + .then((response) => { if (!response.results || response.results.length == 0) { throw new Parse.Error( Parse.Error.INVALID_SESSION_TOKEN, @@ -74,25 +74,25 @@ export class SessionsRouter extends ClassesRouter { } mountRoutes() { - this.route('GET', '/sessions/me', req => { + this.route('GET', '/sessions/me', (req) => { return this.handleMe(req); }); - this.route('GET', '/sessions', req => { + this.route('GET', '/sessions', (req) => { return this.handleFind(req); }); - this.route('GET', '/sessions/:objectId', req => { + this.route('GET', '/sessions/:objectId', (req) => { return this.handleGet(req); }); - this.route('POST', '/sessions', req => { + this.route('POST', '/sessions', (req) => { return this.handleCreate(req); }); - this.route('PUT', '/sessions/:objectId', req => { + this.route('PUT', '/sessions/:objectId', (req) => { return this.handleUpdate(req); }); - this.route('DELETE', '/sessions/:objectId', req => { + this.route('DELETE', '/sessions/:objectId', (req) => { return this.handleDelete(req); }); - this.route('POST', '/upgradeToRevocableSession', req => { + this.route('POST', '/upgradeToRevocableSession', (req) => { return this.handleUpdateToRevocableSession(req); }); } diff --git a/src/Routers/UsersRouter.js b/src/Routers/UsersRouter.js index 05d00817..a5362ff9 100644 --- a/src/Routers/UsersRouter.js +++ b/src/Routers/UsersRouter.js @@ -83,7 +83,7 @@ export class UsersRouter extends ClassesRouter { } return req.config.database .find('_User', query) - .then(results => { + .then((results) => { if (!results.length) { throw new Parse.Error( Parse.Error.OBJECT_NOT_FOUND, @@ -96,14 +96,14 @@ export class UsersRouter extends ClassesRouter { req.config.loggerController.warn( "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 { user = results[0]; } return passwordCrypto.compare(password, user.password); }) - .then(correct => { + .then((correct) => { isValidPassword = correct; const accountLockoutPolicy = new AccountLockout(user, req.config); return accountLockoutPolicy.handleLoginAttempt(isValidPassword); @@ -145,7 +145,7 @@ export class UsersRouter extends ClassesRouter { // Sometimes the authData still has null on that keys // https://github.com/parse-community/parse-server/issues/935 if (user.authData) { - Object.keys(user.authData).forEach(provider => { + Object.keys(user.authData).forEach((provider) => { if (user.authData[provider] === null) { delete user.authData[provider]; } @@ -157,7 +157,7 @@ export class UsersRouter extends ClassesRouter { return resolve(user); }) - .catch(error => { + .catch((error) => { return reject(error); }); }); @@ -181,7 +181,7 @@ export class UsersRouter extends ClassesRouter { req.info.clientSDK, req.info.context ) - .then(response => { + .then((response) => { if ( !response.results || response.results.length == 0 || @@ -282,13 +282,13 @@ export class UsersRouter extends ClassesRouter { handleVerifyPassword(req) { return this._authenticateUserFromRequest(req) - .then(user => { + .then((user) => { // Remove hidden properties. UsersRouter.removeHiddenProperties(user); return { response: user }; }) - .catch(error => { + .catch((error) => { throw error; }); } @@ -306,7 +306,7 @@ export class UsersRouter extends ClassesRouter { req.info.clientSDK, req.info.context ) - .then(records => { + .then((records) => { if (records.results && records.results.length) { return rest .del( @@ -383,7 +383,7 @@ export class UsersRouter extends ClassesRouter { response: {}, }); }, - err => { + (err) => { if (err.code === Parse.Error.OBJECT_NOT_FOUND) { // Return success so that this endpoint can't // 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 => { - if (!results.length || results.length < 1) { - throw new Parse.Error( - Parse.Error.EMAIL_NOT_FOUND, - `No user found with email ${email}` - ); - } - const user = results[0]; + return req.config.database + .find('_User', { email: email }) + .then((results) => { + if (!results.length || results.length < 1) { + throw new Parse.Error( + Parse.Error.EMAIL_NOT_FOUND, + `No user found with email ${email}` + ); + } + const user = results[0]; - // remove password field, messes with saving on postgres - delete user.password; + // remove password field, messes with saving on postgres + delete user.password; - if (user.emailVerified) { - throw new Parse.Error( - Parse.Error.OTHER_CAUSE, - `Email ${email} is already verified.` - ); - } + if (user.emailVerified) { + throw new Parse.Error( + Parse.Error.OTHER_CAUSE, + `Email ${email} is already verified.` + ); + } - const userController = req.config.userController; - return userController.regenerateEmailVerifyToken(user).then(() => { - userController.sendVerificationEmail(user); - return { response: {} }; + const userController = req.config.userController; + return userController.regenerateEmailVerifyToken(user).then(() => { + userController.sendVerificationEmail(user); + return { response: {} }; + }); }); - }); } mountRoutes() { - this.route('GET', '/users', req => { + this.route('GET', '/users', (req) => { return this.handleFind(req); }); - this.route('POST', '/users', req => { + this.route('POST', '/users', (req) => { return this.handleCreate(req); }); - this.route('GET', '/users/me', req => { + this.route('GET', '/users/me', (req) => { return this.handleMe(req); }); - this.route('GET', '/users/:objectId', req => { + this.route('GET', '/users/:objectId', (req) => { return this.handleGet(req); }); - this.route('PUT', '/users/:objectId', req => { + this.route('PUT', '/users/:objectId', (req) => { return this.handleUpdate(req); }); - this.route('DELETE', '/users/:objectId', req => { + this.route('DELETE', '/users/:objectId', (req) => { return this.handleDelete(req); }); - this.route('GET', '/login', req => { + this.route('GET', '/login', (req) => { return this.handleLogIn(req); }); - this.route('POST', '/login', req => { + this.route('POST', '/login', (req) => { return this.handleLogIn(req); }); - this.route('POST', '/logout', req => { + this.route('POST', '/logout', (req) => { return this.handleLogOut(req); }); - this.route('POST', '/requestPasswordReset', req => { + this.route('POST', '/requestPasswordReset', (req) => { return this.handleResetRequest(req); }); - this.route('POST', '/verificationEmailRequest', req => { + this.route('POST', '/verificationEmailRequest', (req) => { return this.handleVerificationEmailRequest(req); }); - this.route('GET', '/verifyPassword', req => { + this.route('GET', '/verifyPassword', (req) => { return this.handleVerifyPassword(req); }); } diff --git a/src/cli/parse-live-query-server.js b/src/cli/parse-live-query-server.js index edcdeec7..525a202a 100644 --- a/src/cli/parse-live-query-server.js +++ b/src/cli/parse-live-query-server.js @@ -4,7 +4,7 @@ import { ParseServer } from '../index'; runner({ definitions, - start: function(program, options, logOptions) { + start: function (program, options, logOptions) { logOptions(); ParseServer.createLiveQueryServer(undefined, options); }, diff --git a/src/cli/parse-server.js b/src/cli/parse-server.js index 69611bd9..4828b550 100755 --- a/src/cli/parse-server.js +++ b/src/cli/parse-server.js @@ -5,7 +5,7 @@ import cluster from 'cluster'; import os from 'os'; import runner from './utils/runner'; -const help = function() { +const help = function () { console.log(' Get Started guide:'); console.log(''); console.log(' Please have a look at the get started guide!'); @@ -39,7 +39,7 @@ runner({ definitions, help, usage: '[options] ', - start: function(program, options, logOptions) { + start: function (program, options, logOptions) { if (!options.appId || !options.masterKey) { program.outputHelp(); console.error(''); diff --git a/src/cloud-code/Parse.Cloud.js b/src/cloud-code/Parse.Cloud.js index c4bd380b..861eb68b 100644 --- a/src/cloud-code/Parse.Cloud.js +++ b/src/cloud-code/Parse.Cloud.js @@ -38,7 +38,7 @@ var ParseCloud = {}; * @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}. */ -ParseCloud.define = function(functionName, handler, validationHandler) { +ParseCloud.define = function (functionName, handler, validationHandler) { triggers.addFunction( functionName, 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} * */ -ParseCloud.job = function(functionName, handler) { +ParseCloud.job = function (functionName, handler) { 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 {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); triggers.addTrigger( 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 {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); triggers.addTrigger( triggers.Types.beforeDelete, @@ -149,7 +149,7 @@ ParseCloud.beforeDelete = function(parseClass, handler) { * @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}; */ -ParseCloud.beforeLogin = function(handler) { +ParseCloud.beforeLogin = function (handler) { let className = '_User'; if (typeof handler === 'string' || isParseObjectConstructor(handler)) { // validation will occur downstream, this is to maintain internal @@ -185,7 +185,7 @@ ParseCloud.beforeLogin = function(handler) { * @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}; */ -ParseCloud.afterLogin = function(handler) { +ParseCloud.afterLogin = function (handler) { let className = '_User'; if (typeof handler === 'string' || isParseObjectConstructor(handler)) { // validation will occur downstream, this is to maintain internal @@ -220,7 +220,7 @@ ParseCloud.afterLogin = function(handler) { * @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}; */ -ParseCloud.afterLogout = function(handler) { +ParseCloud.afterLogout = function (handler) { let className = '_Session'; if (typeof handler === 'string' || isParseObjectConstructor(handler)) { // 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 {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); triggers.addTrigger( 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 {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); triggers.addTrigger( 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 {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); triggers.addTrigger( 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 {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); triggers.addTrigger( triggers.Types.afterFind, @@ -376,7 +376,7 @@ ParseCloud.afterFind = function(parseClass, handler) { * @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}. */ -ParseCloud.beforeSaveFile = function(handler) { +ParseCloud.beforeSaveFile = function (handler) { triggers.addFileTrigger( triggers.Types.beforeSaveFile, handler, @@ -399,7 +399,7 @@ ParseCloud.beforeSaveFile = function(handler) { * @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}. */ -ParseCloud.afterSaveFile = function(handler) { +ParseCloud.afterSaveFile = function (handler) { triggers.addFileTrigger( triggers.Types.afterSaveFile, handler, @@ -422,11 +422,11 @@ ParseCloud.afterSaveFile = function(handler) { * @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}. */ -ParseCloud.beforeDeleteFile = function(handler) { +ParseCloud.beforeDeleteFile = function (handler) { triggers.addFileTrigger( triggers.Types.beforeDeleteFile, handler, - Parse.applicationId, + Parse.applicationId ); }; @@ -445,15 +445,15 @@ ParseCloud.beforeDeleteFile = function(handler) { * @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}. */ -ParseCloud.afterDeleteFile = function(handler) { +ParseCloud.afterDeleteFile = function (handler) { triggers.addFileTrigger( triggers.Types.afterDeleteFile, handler, - Parse.applicationId, + Parse.applicationId ); }; -ParseCloud.onLiveQueryEvent = function(handler) { +ParseCloud.onLiveQueryEvent = function (handler) { triggers.addLiveQueryEventHandler(handler, Parse.applicationId); }; diff --git a/src/cloud-code/httpRequest.js b/src/cloud-code/httpRequest.js index 0dbf0834..81959ef7 100644 --- a/src/cloud-code/httpRequest.js +++ b/src/cloud-code/httpRequest.js @@ -10,9 +10,9 @@ const clients = { }; function makeCallback(resolve, reject) { - return function(response) { + return function (response) { const chunks = []; - response.on('data', chunk => { + response.on('data', (chunk) => { chunks.push(chunk); }); 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') { return { body, headers }; } - var contentTypeKeys = Object.keys(headers).filter(key => { + var contentTypeKeys = Object.keys(headers).filter((key) => { return key.match(/content-type/i) != null; }); @@ -118,7 +118,7 @@ module.exports = function httpRequest(options) { followRedirects: options.followRedirects === true, }; if (requestOptions.headers) { - Object.keys(requestOptions.headers).forEach(key => { + Object.keys(requestOptions.headers).forEach((key) => { if (typeof requestOptions.headers[key] === 'undefined') { delete requestOptions.headers[key]; } @@ -144,7 +144,7 @@ module.exports = function httpRequest(options) { if (options.body) { req.write(options.body); } - req.on('error', error => { + req.on('error', (error) => { reject(error); }); req.end(); diff --git a/src/vendor/mongodbUrl.js b/src/vendor/mongodbUrl.js index a96fd35f..0950508f 100644 --- a/src/vendor/mongodbUrl.js +++ b/src/vendor/mongodbUrl.js @@ -76,7 +76,7 @@ function urlParse(url, parseQueryString, slashesDenoteHost) { } /* istanbul ignore next: improve coverage */ -Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { +Url.prototype.parse = function (url, parseQueryString, slashesDenoteHost) { if (typeof url !== 'string') { throw new TypeError('Parameter "url" must be a string, not ' + typeof url); } @@ -528,7 +528,7 @@ function urlFormat(obj) { } /* istanbul ignore next: improve coverage */ -Url.prototype.format = function() { +Url.prototype.format = function () { var auth = this.auth || ''; if (auth) { auth = encodeAuth(auth); @@ -611,7 +611,7 @@ function urlResolve(source, relative) { } /* istanbul ignore next: improve coverage */ -Url.prototype.resolve = function(relative) { +Url.prototype.resolve = function (relative) { return this.resolveObject(urlParse(relative, false, true)).format(); }; @@ -622,7 +622,7 @@ function urlResolveObject(source, relative) { } /* istanbul ignore next: improve coverage */ -Url.prototype.resolveObject = function(relative) { +Url.prototype.resolveObject = function (relative) { if (typeof relative === 'string') { var rel = new Url(); rel.parse(relative, false, true); @@ -912,7 +912,7 @@ Url.prototype.resolveObject = function(relative) { }; /* istanbul ignore next: improve coverage */ -Url.prototype.parseHost = function() { +Url.prototype.parseHost = function () { var host = this.host; var port = portPattern.exec(host); if (port) {