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

@@ -3,12 +3,15 @@ import * as middleware from '../middlewares';
import Parse from 'parse/node';
export class PurgeRouter extends PromiseRouter {
handlePurge(req) {
if (req.auth.isReadOnly) {
throw new Parse.Error(Parse.Error.OPERATION_FORBIDDEN, 'read-only masterKey isn\'t allowed to purge a schema.');
throw new Parse.Error(
Parse.Error.OPERATION_FORBIDDEN,
"read-only masterKey isn't allowed to purge a schema."
);
}
return req.config.database.purgeCollection(req.params.className)
return req.config.database
.purgeCollection(req.params.className)
.then(() => {
var cacheAdapter = req.config.cacheController;
if (req.params.className == '_Session') {
@@ -16,17 +19,25 @@ export class PurgeRouter extends PromiseRouter {
} else if (req.params.className == '_Role') {
cacheAdapter.role.clear();
}
return {response: {}};
}).catch((error) => {
return { response: {} };
})
.catch(error => {
if (!error || (error && error.code === Parse.Error.OBJECT_NOT_FOUND)) {
return {response: {}};
return { response: {} };
}
throw error;
});
}
mountRoutes() {
this.route('DELETE', '/purge/:className', middleware.promiseEnforceMasterKeyAccess, (req) => { return this.handlePurge(req); });
this.route(
'DELETE',
'/purge/:className',
middleware.promiseEnforceMasterKeyAccess,
req => {
return this.handlePurge(req);
}
);
}
}