Use Prettier JS (#5017)

* Adds prettier

* Run lint before tests
This commit is contained in:
Florent Vilmart
2018-09-01 13:58:06 -04:00
committed by GitHub
parent 189cd259ee
commit d83a0b6808
240 changed files with 41098 additions and 29020 deletions

View File

@@ -1,41 +1,56 @@
import PromiseRouter from '../PromiseRouter';
import * as middleware from "../middlewares";
import { Parse } from "parse/node";
import PromiseRouter from '../PromiseRouter';
import * as middleware from '../middlewares';
import { Parse } from 'parse/node';
export class PushRouter extends PromiseRouter {
mountRoutes() {
this.route("POST", "/push", middleware.promiseEnforceMasterKeyAccess, PushRouter.handlePOST);
this.route(
'POST',
'/push',
middleware.promiseEnforceMasterKeyAccess,
PushRouter.handlePOST
);
}
static handlePOST(req) {
if (req.auth.isReadOnly) {
throw new Parse.Error(Parse.Error.OPERATION_FORBIDDEN, 'read-only masterKey isn\'t allowed to send push notifications.');
throw new Parse.Error(
Parse.Error.OPERATION_FORBIDDEN,
"read-only masterKey isn't allowed to send push notifications."
);
}
const pushController = req.config.pushController;
if (!pushController) {
throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED, 'Push controller is not set');
throw new Parse.Error(
Parse.Error.PUSH_MISCONFIGURED,
'Push controller is not set'
);
}
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) => {
pushStatusId = objectId;
resolve({
headers: {
'X-Parse-Push-Status-Id': pushStatusId
},
response: {
result: true
}
pushController
.sendPush(req.body, where, req.config, req.auth, objectId => {
pushStatusId = objectId;
resolve({
headers: {
'X-Parse-Push-Status-Id': pushStatusId,
},
response: {
result: true,
},
});
})
.catch(err => {
req.config.loggerController.error(
`_PushStatus ${pushStatusId}: error while sending push`,
err
);
});
}).catch((err) => {
req.config.loggerController.error(`_PushStatus ${pushStatusId}: error while sending push`, err);
});
return promise;
}
@@ -51,18 +66,23 @@ export class PushRouter extends PromiseRouter {
let where;
if (hasWhere && hasChannels) {
throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED,
'Channels and query can not be set at the same time.');
throw new Parse.Error(
Parse.Error.PUSH_MISCONFIGURED,
'Channels and query can not be set at the same time.'
);
} else if (hasWhere) {
where = body.where;
} else if (hasChannels) {
where = {
"channels": {
"$in": body.channels
}
}
channels: {
$in: body.channels,
},
};
} else {
throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED, 'Sending a push requires either "channels" or a "where" query.');
throw new Parse.Error(
Parse.Error.PUSH_MISCONFIGURED,
'Sending a push requires either "channels" or a "where" query.'
);
}
return where;
}