chore: Upgrade Prettier 1.8 -> 2.0 (#1436)

This commit is contained in:
Tom Moor
2020-08-08 18:53:11 -07:00
committed by GitHub
parent 68dcb4de5f
commit e312b264a6
218 changed files with 1156 additions and 1169 deletions

View File

@ -10,7 +10,7 @@ import policy from "../policies";
const { authorize } = policy;
const router = new Router();
router.post("apiKeys.create", auth(), async ctx => {
router.post("apiKeys.create", auth(), async (ctx) => {
const { name } = ctx.body;
ctx.assertPresent(name, "name is required");
@ -36,7 +36,7 @@ router.post("apiKeys.create", auth(), async ctx => {
};
});
router.post("apiKeys.list", auth(), pagination(), async ctx => {
router.post("apiKeys.list", auth(), pagination(), async (ctx) => {
const user = ctx.state.user;
const keys = await ApiKey.findAll({
where: {
@ -53,7 +53,7 @@ router.post("apiKeys.list", auth(), pagination(), async ctx => {
};
});
router.post("apiKeys.delete", auth(), async ctx => {
router.post("apiKeys.delete", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertUuid(id, "id is required");

View File

@ -18,7 +18,7 @@ const { authorize } = policy;
const router = new Router();
const AWS_S3_ACL = process.env.AWS_S3_ACL || "private";
router.post("attachments.create", auth(), async ctx => {
router.post("attachments.create", auth(), async (ctx) => {
let { name, documentId, contentType, size } = ctx.body;
ctx.assertPresent(name, "name is required");
@ -31,7 +31,9 @@ router.post("attachments.create", auth(), async ctx => {
const acl =
ctx.body.public === undefined
? AWS_S3_ACL
: ctx.body.public ? "public-read" : "private";
: ctx.body.public
? "public-read"
: "private";
const credential = makeCredential();
const longDate = format(new Date(), "YYYYMMDDTHHmmss\\Z");
const policy = makePolicy(credential, longDate, acl);
@ -88,7 +90,7 @@ router.post("attachments.create", auth(), async ctx => {
};
});
router.post("attachments.redirect", auth(), async ctx => {
router.post("attachments.redirect", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertPresent(id, "id is required");

View File

@ -37,19 +37,19 @@ function filterServices(team) {
let output = services;
if (team && !team.googleId) {
output = reject(output, service => service.id === "google");
output = reject(output, (service) => service.id === "google");
}
if (team && !team.slackId) {
output = reject(output, service => service.id === "slack");
output = reject(output, (service) => service.id === "slack");
}
if (!team || !team.guestSignin) {
output = reject(output, service => service.id === "email");
output = reject(output, (service) => service.id === "email");
}
return output;
}
router.post("auth.config", async ctx => {
router.post("auth.config", async (ctx) => {
// If self hosted AND there is only one team then that team becomes the
// brand for the knowledge base and it's guest signin option is used for the
// root login page.
@ -100,7 +100,7 @@ router.post("auth.config", async ctx => {
};
});
router.post("auth.info", auth(), async ctx => {
router.post("auth.info", auth(), async (ctx) => {
const user = ctx.state.user;
const team = await Team.findByPk(user.teamId);

View File

@ -29,7 +29,7 @@ import policy from "../policies";
const { authorize } = policy;
const router = new Router();
router.post("collections.create", auth(), async ctx => {
router.post("collections.create", auth(), async (ctx) => {
const { name, color, description, icon, type } = ctx.body;
const isPrivate = ctx.body.private;
ctx.assertPresent(name, "name is required");
@ -74,7 +74,7 @@ router.post("collections.create", auth(), async ctx => {
};
});
router.post("collections.info", auth(), async ctx => {
router.post("collections.info", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertUuid(id, "id is required");
@ -90,7 +90,7 @@ router.post("collections.info", auth(), async ctx => {
};
});
router.post("collections.add_group", auth(), async ctx => {
router.post("collections.add_group", auth(), async (ctx) => {
const { id, groupId, permission = "read_write" } = ctx.body;
ctx.assertUuid(id, "id is required");
ctx.assertUuid(groupId, "groupId is required");
@ -140,7 +140,7 @@ router.post("collections.add_group", auth(), async ctx => {
};
});
router.post("collections.remove_group", auth(), async ctx => {
router.post("collections.remove_group", auth(), async (ctx) => {
const { id, groupId } = ctx.body;
ctx.assertUuid(id, "id is required");
ctx.assertUuid(groupId, "groupId is required");
@ -173,7 +173,7 @@ router.post(
"collections.group_memberships",
auth(),
pagination(),
async ctx => {
async (ctx) => {
const { id, query, permission } = ctx.body;
ctx.assertUuid(id, "id is required");
@ -226,13 +226,13 @@ router.post(
collectionGroupMemberships: memberships.map(
presentCollectionGroupMembership
),
groups: memberships.map(membership => presentGroup(membership.group)),
groups: memberships.map((membership) => presentGroup(membership.group)),
},
};
}
);
router.post("collections.add_user", auth(), async ctx => {
router.post("collections.add_user", auth(), async (ctx) => {
const { id, userId, permission = "read_write" } = ctx.body;
ctx.assertUuid(id, "id is required");
ctx.assertUuid(userId, "userId is required");
@ -282,7 +282,7 @@ router.post("collections.add_user", auth(), async ctx => {
};
});
router.post("collections.remove_user", auth(), async ctx => {
router.post("collections.remove_user", auth(), async (ctx) => {
const { id, userId } = ctx.body;
ctx.assertUuid(id, "id is required");
ctx.assertUuid(userId, "userId is required");
@ -313,7 +313,7 @@ router.post("collections.remove_user", auth(), async ctx => {
});
// DEPRECATED: Use collection.memberships which has pagination, filtering and permissions
router.post("collections.users", auth(), async ctx => {
router.post("collections.users", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertUuid(id, "id is required");
@ -330,7 +330,7 @@ router.post("collections.users", auth(), async ctx => {
};
});
router.post("collections.memberships", auth(), pagination(), async ctx => {
router.post("collections.memberships", auth(), pagination(), async (ctx) => {
const { id, query, permission } = ctx.body;
ctx.assertUuid(id, "id is required");
@ -380,12 +380,12 @@ router.post("collections.memberships", auth(), pagination(), async ctx => {
pagination: ctx.state.pagination,
data: {
memberships: memberships.map(presentMembership),
users: memberships.map(membership => presentUser(membership.user)),
users: memberships.map((membership) => presentUser(membership.user)),
},
};
});
router.post("collections.export", auth(), async ctx => {
router.post("collections.export", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertUuid(id, "id is required");
@ -411,7 +411,7 @@ router.post("collections.export", auth(), async ctx => {
ctx.body = fs.createReadStream(filePath);
});
router.post("collections.export_all", auth(), async ctx => {
router.post("collections.export_all", auth(), async (ctx) => {
const { download = false } = ctx.body;
const user = ctx.state.user;
@ -445,7 +445,7 @@ router.post("collections.export_all", auth(), async ctx => {
}
});
router.post("collections.update", auth(), async ctx => {
router.post("collections.update", auth(), async (ctx) => {
const { id, name, description, icon, color } = ctx.body;
const isPrivate = ctx.body.private;
ctx.assertPresent(name, "name is required");
@ -508,7 +508,7 @@ router.post("collections.update", auth(), async ctx => {
};
});
router.post("collections.list", auth(), pagination(), async ctx => {
router.post("collections.list", auth(), pagination(), async (ctx) => {
const user = ctx.state.user;
const collectionIds = await user.collectionIds();
let collections = await Collection.scope({
@ -530,7 +530,7 @@ router.post("collections.list", auth(), pagination(), async ctx => {
};
});
router.post("collections.delete", auth(), async ctx => {
router.post("collections.delete", auth(), async (ctx) => {
const { id } = ctx.body;
const user = ctx.state.user;
ctx.assertUuid(id, "id is required");

View File

@ -28,7 +28,7 @@ const Op = Sequelize.Op;
const { authorize, cannot } = policy;
const router = new Router();
router.post("documents.list", auth(), pagination(), async ctx => {
router.post("documents.list", auth(), pagination(), async (ctx) => {
const {
sort = "updatedAt",
template,
@ -90,7 +90,7 @@ router.post("documents.list", auth(), pagination(), async ctx => {
where = {
...where,
id: backlinks.map(backlink => backlink.reverseDocumentId),
id: backlinks.map((backlink) => backlink.reverseDocumentId),
};
}
@ -109,7 +109,7 @@ router.post("documents.list", auth(), pagination(), async ctx => {
});
const data = await Promise.all(
documents.map(document => presentDocument(document))
documents.map((document) => presentDocument(document))
);
const policies = presentPolicies(user, documents);
@ -121,7 +121,7 @@ router.post("documents.list", auth(), pagination(), async ctx => {
};
});
router.post("documents.pinned", auth(), pagination(), async ctx => {
router.post("documents.pinned", auth(), pagination(), async (ctx) => {
const { collectionId, sort = "updatedAt" } = ctx.body;
let direction = ctx.body.direction;
if (direction !== "ASC") direction = "DESC";
@ -154,7 +154,7 @@ router.post("documents.pinned", auth(), pagination(), async ctx => {
});
const data = await Promise.all(
documents.map(document => presentDocument(document))
documents.map((document) => presentDocument(document))
);
const policies = presentPolicies(user, documents);
@ -166,7 +166,7 @@ router.post("documents.pinned", auth(), pagination(), async ctx => {
};
});
router.post("documents.archived", auth(), pagination(), async ctx => {
router.post("documents.archived", auth(), pagination(), async (ctx) => {
const { sort = "updatedAt" } = ctx.body;
let direction = ctx.body.direction;
if (direction !== "ASC") direction = "DESC";
@ -192,7 +192,7 @@ router.post("documents.archived", auth(), pagination(), async ctx => {
});
const data = await Promise.all(
documents.map(document => presentDocument(document))
documents.map((document) => presentDocument(document))
);
const policies = presentPolicies(user, documents);
@ -204,7 +204,7 @@ router.post("documents.archived", auth(), pagination(), async ctx => {
};
});
router.post("documents.deleted", auth(), pagination(), async ctx => {
router.post("documents.deleted", auth(), pagination(), async (ctx) => {
const { sort = "deletedAt" } = ctx.body;
let direction = ctx.body.direction;
if (direction !== "ASC") direction = "DESC";
@ -232,7 +232,7 @@ router.post("documents.deleted", auth(), pagination(), async ctx => {
});
const data = await Promise.all(
documents.map(document => presentDocument(document))
documents.map((document) => presentDocument(document))
);
const policies = presentPolicies(user, documents);
@ -244,7 +244,7 @@ router.post("documents.deleted", auth(), pagination(), async ctx => {
};
});
router.post("documents.viewed", auth(), pagination(), async ctx => {
router.post("documents.viewed", auth(), pagination(), async (ctx) => {
let { sort = "updatedAt", direction } = ctx.body;
if (direction !== "ASC") direction = "DESC";
@ -275,9 +275,9 @@ router.post("documents.viewed", auth(), pagination(), async ctx => {
limit: ctx.state.pagination.limit,
});
const documents = views.map(view => view.document);
const documents = views.map((view) => view.document);
const data = await Promise.all(
documents.map(document => presentDocument(document))
documents.map((document) => presentDocument(document))
);
const policies = presentPolicies(user, documents);
@ -289,7 +289,7 @@ router.post("documents.viewed", auth(), pagination(), async ctx => {
};
});
router.post("documents.starred", auth(), pagination(), async ctx => {
router.post("documents.starred", auth(), pagination(), async (ctx) => {
let { sort = "updatedAt", direction } = ctx.body;
if (direction !== "ASC") direction = "DESC";
@ -326,9 +326,9 @@ router.post("documents.starred", auth(), pagination(), async ctx => {
limit: ctx.state.pagination.limit,
});
const documents = stars.map(star => star.document);
const documents = stars.map((star) => star.document);
const data = await Promise.all(
documents.map(document => presentDocument(document))
documents.map((document) => presentDocument(document))
);
const policies = presentPolicies(user, documents);
@ -340,7 +340,7 @@ router.post("documents.starred", auth(), pagination(), async ctx => {
};
});
router.post("documents.drafts", auth(), pagination(), async ctx => {
router.post("documents.drafts", auth(), pagination(), async (ctx) => {
let { sort = "updatedAt", direction } = ctx.body;
if (direction !== "ASC") direction = "DESC";
@ -363,7 +363,7 @@ router.post("documents.drafts", auth(), pagination(), async ctx => {
});
const data = await Promise.all(
documents.map(document => presentDocument(document))
documents.map((document) => presentDocument(document))
);
const policies = presentPolicies(user, documents);
@ -417,7 +417,7 @@ async function loadDocument({ id, shareId, user }) {
return document;
}
router.post("documents.info", auth({ required: false }), async ctx => {
router.post("documents.info", auth({ required: false }), async (ctx) => {
const { id, shareId } = ctx.body;
ctx.assertPresent(id || shareId, "id or shareId is required");
@ -431,7 +431,7 @@ router.post("documents.info", auth({ required: false }), async ctx => {
};
});
router.post("documents.export", auth({ required: false }), async ctx => {
router.post("documents.export", auth({ required: false }), async (ctx) => {
const { id, shareId } = ctx.body;
ctx.assertPresent(id || shareId, "id or shareId is required");
@ -443,7 +443,7 @@ router.post("documents.export", auth({ required: false }), async ctx => {
};
});
router.post("documents.restore", auth(), async ctx => {
router.post("documents.restore", auth(), async (ctx) => {
const { id, revisionId } = ctx.body;
ctx.assertPresent(id, "id is required");
@ -513,7 +513,7 @@ router.post("documents.restore", auth(), async ctx => {
};
});
router.post("documents.search", auth(), pagination(), async ctx => {
router.post("documents.search", auth(), pagination(), async (ctx) => {
const {
query,
includeArchived,
@ -559,9 +559,9 @@ router.post("documents.search", auth(), pagination(), async ctx => {
limit,
});
const documents = results.map(result => result.document);
const documents = results.map((result) => result.document);
const data = await Promise.all(
results.map(async result => {
results.map(async (result) => {
const document = await presentDocument(result.document);
return { ...result, document };
})
@ -576,7 +576,7 @@ router.post("documents.search", auth(), pagination(), async ctx => {
};
});
router.post("documents.pin", auth(), async ctx => {
router.post("documents.pin", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertPresent(id, "id is required");
@ -603,7 +603,7 @@ router.post("documents.pin", auth(), async ctx => {
};
});
router.post("documents.unpin", auth(), async ctx => {
router.post("documents.unpin", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertPresent(id, "id is required");
@ -630,7 +630,7 @@ router.post("documents.unpin", auth(), async ctx => {
};
});
router.post("documents.star", auth(), async ctx => {
router.post("documents.star", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertPresent(id, "id is required");
@ -657,7 +657,7 @@ router.post("documents.star", auth(), async ctx => {
};
});
router.post("documents.unstar", auth(), async ctx => {
router.post("documents.unstar", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertPresent(id, "id is required");
@ -684,7 +684,7 @@ router.post("documents.unstar", auth(), async ctx => {
};
});
router.post("documents.create", auth(), async ctx => {
router.post("documents.create", auth(), async (ctx) => {
const {
title = "",
text = "",
@ -786,7 +786,7 @@ router.post("documents.create", auth(), async ctx => {
};
});
router.post("documents.templatize", auth(), async ctx => {
router.post("documents.templatize", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertPresent(id, "id is required");
@ -826,7 +826,7 @@ router.post("documents.templatize", auth(), async ctx => {
};
});
router.post("documents.update", auth(), async ctx => {
router.post("documents.update", auth(), async (ctx) => {
const {
id,
title,
@ -917,7 +917,7 @@ router.post("documents.update", auth(), async ctx => {
};
});
router.post("documents.move", auth(), async ctx => {
router.post("documents.move", auth(), async (ctx) => {
const { id, collectionId, parentDocumentId, index } = ctx.body;
ctx.assertUuid(id, "id must be a uuid");
ctx.assertUuid(collectionId, "collectionId must be a uuid");
@ -964,17 +964,17 @@ router.post("documents.move", auth(), async ctx => {
ctx.body = {
data: {
documents: await Promise.all(
documents.map(document => presentDocument(document))
documents.map((document) => presentDocument(document))
),
collections: await Promise.all(
collections.map(collection => presentCollection(collection))
collections.map((collection) => presentCollection(collection))
),
},
policies: presentPolicies(user, documents),
};
});
router.post("documents.archive", auth(), async ctx => {
router.post("documents.archive", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertPresent(id, "id is required");
@ -1000,7 +1000,7 @@ router.post("documents.archive", auth(), async ctx => {
};
});
router.post("documents.delete", auth(), async ctx => {
router.post("documents.delete", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertPresent(id, "id is required");

View File

@ -11,7 +11,7 @@ const Op = Sequelize.Op;
const { authorize } = policy;
const router = new Router();
router.post("events.list", auth(), pagination(), async ctx => {
router.post("events.list", auth(), pagination(), async (ctx) => {
let { sort = "createdAt", direction, auditLog = false } = ctx.body;
if (direction !== "ASC") direction = "DESC";
@ -53,7 +53,7 @@ router.post("events.list", auth(), pagination(), async ctx => {
ctx.body = {
pagination: ctx.state.pagination,
data: events.map(event => presentEvent(event, auditLog)),
data: events.map((event) => presentEvent(event, auditLog)),
};
});

View File

@ -17,7 +17,7 @@ import policy from "../policies";
const { authorize } = policy;
const router = new Router();
router.post("groups.list", auth(), pagination(), async ctx => {
router.post("groups.list", auth(), pagination(), async (ctx) => {
const { sort = "updatedAt" } = ctx.body;
let direction = ctx.body.direction;
if (direction !== "ASC") direction = "DESC";
@ -34,7 +34,8 @@ router.post("groups.list", auth(), pagination(), async ctx => {
if (!user.isAdmin) {
groups = groups.filter(
group => group.groupMemberships.filter(gm => gm.userId === user.id).length
(group) =>
group.groupMemberships.filter((gm) => gm.userId === user.id).length
);
}
@ -43,9 +44,9 @@ router.post("groups.list", auth(), pagination(), async ctx => {
data: {
groups: groups.map(presentGroup),
groupMemberships: groups
.map(g =>
.map((g) =>
g.groupMemberships
.filter(membership => !!membership.user)
.filter((membership) => !!membership.user)
.slice(0, MAX_AVATAR_DISPLAY)
)
.flat()
@ -55,7 +56,7 @@ router.post("groups.list", auth(), pagination(), async ctx => {
};
});
router.post("groups.info", auth(), async ctx => {
router.post("groups.info", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertUuid(id, "id is required");
@ -69,7 +70,7 @@ router.post("groups.info", auth(), async ctx => {
};
});
router.post("groups.create", auth(), async ctx => {
router.post("groups.create", auth(), async (ctx) => {
const { name } = ctx.body;
ctx.assertPresent(name, "name is required");
@ -100,7 +101,7 @@ router.post("groups.create", auth(), async ctx => {
};
});
router.post("groups.update", auth(), async ctx => {
router.post("groups.update", auth(), async (ctx) => {
const { id, name } = ctx.body;
ctx.assertPresent(name, "name is required");
ctx.assertUuid(id, "id is required");
@ -130,7 +131,7 @@ router.post("groups.update", auth(), async ctx => {
};
});
router.post("groups.delete", auth(), async ctx => {
router.post("groups.delete", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertUuid(id, "id is required");
@ -154,7 +155,7 @@ router.post("groups.delete", auth(), async ctx => {
};
});
router.post("groups.memberships", auth(), pagination(), async ctx => {
router.post("groups.memberships", auth(), pagination(), async (ctx) => {
const { id, query } = ctx.body;
ctx.assertUuid(id, "id is required");
@ -190,12 +191,12 @@ router.post("groups.memberships", auth(), pagination(), async ctx => {
pagination: ctx.state.pagination,
data: {
groupMemberships: memberships.map(presentGroupMembership),
users: memberships.map(membership => presentUser(membership.user)),
users: memberships.map((membership) => presentUser(membership.user)),
},
};
});
router.post("groups.add_user", auth(), async ctx => {
router.post("groups.add_user", auth(), async (ctx) => {
const { id, userId } = ctx.body;
ctx.assertUuid(id, "id is required");
ctx.assertUuid(userId, "userId is required");
@ -249,7 +250,7 @@ router.post("groups.add_user", auth(), async ctx => {
};
});
router.post("groups.remove_user", auth(), async ctx => {
router.post("groups.remove_user", auth(), async (ctx) => {
const { id, userId } = ctx.body;
ctx.assertUuid(id, "id is required");
ctx.assertUuid(userId, "userId is required");

View File

@ -8,7 +8,7 @@ import * as Slack from "../slack";
const router = new Router();
// triggered by a user posting a getoutline.com link in Slack
router.post("hooks.unfurl", async ctx => {
router.post("hooks.unfurl", async (ctx) => {
const { challenge, token, event } = ctx.body;
if (challenge) return (ctx.body = ctx.body.challenge);
@ -49,7 +49,7 @@ router.post("hooks.unfurl", async ctx => {
});
// triggered by interactions with actions, dialogs, message buttons in Slack
router.post("hooks.interactive", async ctx => {
router.post("hooks.interactive", async (ctx) => {
const { payload } = ctx.body;
ctx.assertPresent(payload, "payload is required");
@ -98,7 +98,7 @@ router.post("hooks.interactive", async ctx => {
});
// triggered by the /outline command in Slack
router.post("hooks.slack", async ctx => {
router.post("hooks.slack", async (ctx) => {
const { token, team_id, user_id, text = "" } = ctx.body;
ctx.assertPresent(token, "token is required");
ctx.assertPresent(team_id, "team_id is required");

View File

@ -56,7 +56,7 @@ router.use("/", attachments.routes());
router.use("/", utils.routes());
router.use("/", groups.routes());
router.post("*", ctx => {
router.post("*", (ctx) => {
ctx.throw(new NotFoundError("Endpoint not found"));
});

View File

@ -10,7 +10,7 @@ import policy from "../policies";
const { authorize } = policy;
const router = new Router();
router.post("integrations.list", auth(), pagination(), async ctx => {
router.post("integrations.list", auth(), pagination(), async (ctx) => {
let { sort = "updatedAt", direction } = ctx.body;
if (direction !== "ASC") direction = "DESC";
@ -28,7 +28,7 @@ router.post("integrations.list", auth(), pagination(), async ctx => {
};
});
router.post("integrations.delete", auth(), async ctx => {
router.post("integrations.delete", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertUuid(id, "id is required");

View File

@ -48,7 +48,7 @@ export default function pagination(options?: Object) {
}
/* $FlowFixMeNowPlease This comment suppresses an error found when upgrading
* flow-bin@0.104.0. To view the error, delete this comment and run Flow. */
* flow-bin@0.104.0. To view the error, delete this comment and run Flow. */
ctx.state.pagination = {
limit,
offset,
@ -60,7 +60,7 @@ export default function pagination(options?: Object) {
query.offset = ctx.state.pagination.offset + query.limit;
/* $FlowFixMeNowPlease This comment suppresses an error found when upgrading
* flow-bin@0.104.0. To view the error, delete this comment and run Flow. */
* flow-bin@0.104.0. To view the error, delete this comment and run Flow. */
ctx.state.pagination.nextPath = `/api${
ctx.request.path
}?${querystring.stringify(query)}`;

View File

@ -9,7 +9,7 @@ import policy from "../policies";
const { authorize } = policy;
const router = new Router();
router.post("notificationSettings.create", auth(), async ctx => {
router.post("notificationSettings.create", auth(), async (ctx) => {
const { event } = ctx.body;
ctx.assertPresent(event, "event is required");
@ -29,7 +29,7 @@ router.post("notificationSettings.create", auth(), async ctx => {
};
});
router.post("notificationSettings.list", auth(), async ctx => {
router.post("notificationSettings.list", auth(), async (ctx) => {
const user = ctx.state.user;
const settings = await NotificationSetting.findAll({
where: {
@ -42,7 +42,7 @@ router.post("notificationSettings.list", auth(), async ctx => {
};
});
router.post("notificationSettings.delete", auth(), async ctx => {
router.post("notificationSettings.delete", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertUuid(id, "id is required");
@ -57,7 +57,7 @@ router.post("notificationSettings.delete", auth(), async ctx => {
};
});
router.post("notificationSettings.unsubscribe", async ctx => {
router.post("notificationSettings.unsubscribe", async (ctx) => {
const { id, token } = ctx.body;
ctx.assertUuid(id, "id is required");
ctx.assertPresent(token, "token is required");

View File

@ -10,7 +10,7 @@ import policy from "../policies";
const { authorize } = policy;
const router = new Router();
router.post("revisions.info", auth(), async ctx => {
router.post("revisions.info", auth(), async (ctx) => {
let { id } = ctx.body;
ctx.assertPresent(id, "id is required");
@ -31,7 +31,7 @@ router.post("revisions.info", auth(), async ctx => {
};
});
router.post("revisions.list", auth(), pagination(), async ctx => {
router.post("revisions.list", auth(), pagination(), async (ctx) => {
let { documentId, sort = "updatedAt", direction } = ctx.body;
if (direction !== "ASC") direction = "DESC";
ctx.assertPresent(documentId, "documentId is required");
@ -48,7 +48,7 @@ router.post("revisions.list", auth(), pagination(), async ctx => {
});
const data = await Promise.all(
revisions.map(revision => presentRevision(revision))
revisions.map((revision) => presentRevision(revision))
);
ctx.body = {

View File

@ -12,7 +12,7 @@ const Op = Sequelize.Op;
const { authorize } = policy;
const router = new Router();
router.post("shares.info", auth(), async ctx => {
router.post("shares.info", auth(), async (ctx) => {
const { id, documentId } = ctx.body;
ctx.assertUuid(id || documentId, "id or documentId is required");
@ -39,7 +39,7 @@ router.post("shares.info", auth(), async ctx => {
};
});
router.post("shares.list", auth(), pagination(), async ctx => {
router.post("shares.list", auth(), pagination(), async (ctx) => {
let { sort = "updatedAt", direction } = ctx.body;
if (direction !== "ASC") direction = "DESC";
@ -90,7 +90,7 @@ router.post("shares.list", auth(), pagination(), async ctx => {
};
});
router.post("shares.update", auth(), async ctx => {
router.post("shares.update", auth(), async (ctx) => {
const { id, published } = ctx.body;
ctx.assertUuid(id, "id is required");
ctx.assertPresent(published, "published is required");
@ -118,7 +118,7 @@ router.post("shares.update", auth(), async ctx => {
};
});
router.post("shares.create", auth(), async ctx => {
router.post("shares.create", auth(), async (ctx) => {
const { documentId } = ctx.body;
ctx.assertPresent(documentId, "documentId is required");
@ -160,7 +160,7 @@ router.post("shares.create", auth(), async ctx => {
};
});
router.post("shares.revoke", auth(), async ctx => {
router.post("shares.revoke", auth(), async (ctx) => {
const { id } = ctx.body;
ctx.assertUuid(id, "id is required");

View File

@ -9,7 +9,7 @@ import policy from "../policies";
const { authorize } = policy;
const router = new Router();
router.post("team.update", auth(), async ctx => {
router.post("team.update", auth(), async (ctx) => {
const {
name,
avatarUrl,

View File

@ -11,7 +11,7 @@ import policy from "../policies";
const { authorize } = policy;
const router = new Router();
router.post("users.list", auth(), pagination(), async ctx => {
router.post("users.list", auth(), pagination(), async (ctx) => {
const { sort = "createdAt", query, includeSuspended = false } = ctx.body;
let direction = ctx.body.direction;
if (direction !== "ASC") direction = "DESC";
@ -48,19 +48,19 @@ router.post("users.list", auth(), pagination(), async ctx => {
ctx.body = {
pagination: ctx.state.pagination,
data: users.map(listUser =>
data: users.map((listUser) =>
presentUser(listUser, { includeDetails: user.isAdmin })
),
};
});
router.post("users.info", auth(), async ctx => {
router.post("users.info", auth(), async (ctx) => {
ctx.body = {
data: presentUser(ctx.state.user),
};
});
router.post("users.update", auth(), async ctx => {
router.post("users.update", auth(), async (ctx) => {
const { user } = ctx.state;
const { name, avatarUrl } = ctx.body;
@ -76,7 +76,7 @@ router.post("users.update", auth(), async ctx => {
// Admin specific
router.post("users.promote", auth(), async ctx => {
router.post("users.promote", auth(), async (ctx) => {
const userId = ctx.body.id;
const teamId = ctx.state.user.teamId;
ctx.assertPresent(userId, "id is required");
@ -101,7 +101,7 @@ router.post("users.promote", auth(), async ctx => {
};
});
router.post("users.demote", auth(), async ctx => {
router.post("users.demote", auth(), async (ctx) => {
const userId = ctx.body.id;
const teamId = ctx.state.user.teamId;
ctx.assertPresent(userId, "id is required");
@ -126,7 +126,7 @@ router.post("users.demote", auth(), async ctx => {
};
});
router.post("users.suspend", auth(), async ctx => {
router.post("users.suspend", auth(), async (ctx) => {
const admin = ctx.state.user;
const userId = ctx.body.id;
const teamId = ctx.state.user.teamId;
@ -152,7 +152,7 @@ router.post("users.suspend", auth(), async ctx => {
};
});
router.post("users.activate", auth(), async ctx => {
router.post("users.activate", auth(), async (ctx) => {
const admin = ctx.state.user;
const userId = ctx.body.id;
const teamId = ctx.state.user.teamId;
@ -178,7 +178,7 @@ router.post("users.activate", auth(), async ctx => {
};
});
router.post("users.invite", auth(), async ctx => {
router.post("users.invite", auth(), async (ctx) => {
const { invites } = ctx.body;
ctx.assertPresent(invites, "invites is required");
@ -190,12 +190,12 @@ router.post("users.invite", auth(), async ctx => {
ctx.body = {
data: {
sent: response.sent,
users: response.users.map(user => presentUser(user)),
users: response.users.map((user) => presentUser(user)),
},
};
});
router.post("users.delete", auth(), async ctx => {
router.post("users.delete", auth(), async (ctx) => {
const { confirmation, id } = ctx.body;
ctx.assertPresent(confirmation, "confirmation is required");

View File

@ -9,7 +9,7 @@ import { Op } from "../sequelize";
const router = new Router();
const log = debug("utils");
router.post("utils.gc", async ctx => {
router.post("utils.gc", async (ctx) => {
const { token } = ctx.body;
if (process.env.UTILS_SECRET !== token) {
@ -28,7 +28,7 @@ router.post("utils.gc", async ctx => {
attributes: ["id"],
where,
});
const documentIds = documents.map(d => d.id);
const documentIds = documents.map((d) => d.id);
await Attachment.destroy({
where: {

View File

@ -8,7 +8,7 @@ import policy from "../policies";
const { authorize } = policy;
const router = new Router();
router.post("views.list", auth(), async ctx => {
router.post("views.list", auth(), async (ctx) => {
const { documentId } = ctx.body;
ctx.assertUuid(documentId, "documentId is required");
@ -23,7 +23,7 @@ router.post("views.list", auth(), async ctx => {
};
});
router.post("views.create", auth(), async ctx => {
router.post("views.create", auth(), async (ctx) => {
const { documentId } = ctx.body;
ctx.assertUuid(documentId, "documentId is required");