diff --git a/server/models/AuthenticationProvider.js b/server/models/AuthenticationProvider.js index 6087704ff..007082767 100644 --- a/server/models/AuthenticationProvider.js +++ b/server/models/AuthenticationProvider.js @@ -1,6 +1,6 @@ // @flow -import providers from "../auth/providers"; import { ValidationError } from "../errors"; +import providers from "../routes/auth/providers"; import { DataTypes, Op, sequelize } from "../sequelize"; const AuthenticationProvider = sequelize.define( diff --git a/server/api/__snapshots__/collections.test.js.snap b/server/routes/api/__snapshots__/collections.test.js.snap similarity index 100% rename from server/api/__snapshots__/collections.test.js.snap rename to server/routes/api/__snapshots__/collections.test.js.snap diff --git a/server/api/__snapshots__/documents.test.js.snap b/server/routes/api/__snapshots__/documents.test.js.snap similarity index 100% rename from server/api/__snapshots__/documents.test.js.snap rename to server/routes/api/__snapshots__/documents.test.js.snap diff --git a/server/api/__snapshots__/events.test.js.snap b/server/routes/api/__snapshots__/events.test.js.snap similarity index 100% rename from server/api/__snapshots__/events.test.js.snap rename to server/routes/api/__snapshots__/events.test.js.snap diff --git a/server/api/__snapshots__/groups.test.js.snap b/server/routes/api/__snapshots__/groups.test.js.snap similarity index 100% rename from server/api/__snapshots__/groups.test.js.snap rename to server/routes/api/__snapshots__/groups.test.js.snap diff --git a/server/api/__snapshots__/shares.test.js.snap b/server/routes/api/__snapshots__/shares.test.js.snap similarity index 100% rename from server/api/__snapshots__/shares.test.js.snap rename to server/routes/api/__snapshots__/shares.test.js.snap diff --git a/server/api/__snapshots__/users.test.js.snap b/server/routes/api/__snapshots__/users.test.js.snap similarity index 100% rename from server/api/__snapshots__/users.test.js.snap rename to server/routes/api/__snapshots__/users.test.js.snap diff --git a/server/api/__snapshots__/views.test.js.snap b/server/routes/api/__snapshots__/views.test.js.snap similarity index 100% rename from server/api/__snapshots__/views.test.js.snap rename to server/routes/api/__snapshots__/views.test.js.snap diff --git a/server/api/apiKeys.js b/server/routes/api/apiKeys.js similarity index 89% rename from server/api/apiKeys.js rename to server/routes/api/apiKeys.js index c54529119..b0fc22127 100644 --- a/server/api/apiKeys.js +++ b/server/routes/api/apiKeys.js @@ -1,10 +1,10 @@ // @flow import Router from "koa-router"; -import auth from "../middlewares/authentication"; -import { ApiKey, Event } from "../models"; -import policy from "../policies"; -import { presentApiKey } from "../presenters"; +import auth from "../../middlewares/authentication"; +import { ApiKey, Event } from "../../models"; +import policy from "../../policies"; +import { presentApiKey } from "../../presenters"; import pagination from "./middlewares/pagination"; const { authorize } = policy; diff --git a/server/api/attachments.js b/server/routes/api/attachments.js similarity index 94% rename from server/api/attachments.js rename to server/routes/api/attachments.js index 4e530b943..2c9257c0b 100644 --- a/server/api/attachments.js +++ b/server/routes/api/attachments.js @@ -2,17 +2,17 @@ import { format } from "date-fns"; import Router from "koa-router"; import { v4 as uuidv4 } from "uuid"; -import { NotFoundError } from "../errors"; -import auth from "../middlewares/authentication"; -import { Attachment, Document, Event } from "../models"; -import policy from "../policies"; +import { NotFoundError } from "../../errors"; +import auth from "../../middlewares/authentication"; +import { Attachment, Document, Event } from "../../models"; +import policy from "../../policies"; import { makePolicy, getSignature, publicS3Endpoint, makeCredential, getSignedUrl, -} from "../utils/s3"; +} from "../../utils/s3"; const { authorize } = policy; const router = new Router(); diff --git a/server/api/attachments.test.js b/server/routes/api/attachments.test.js similarity index 97% rename from server/api/attachments.test.js rename to server/routes/api/attachments.test.js index f3e4510ec..c0fd938c1 100644 --- a/server/api/attachments.test.js +++ b/server/routes/api/attachments.test.js @@ -1,15 +1,15 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import TestServer from "fetch-test-server"; -import { Attachment } from "../models"; -import webService from "../services/web"; +import { Attachment } from "../../models"; +import webService from "../../services/web"; import { buildUser, buildAdmin, buildCollection, buildAttachment, buildDocument, -} from "../test/factories"; -import { flushdb } from "../test/support"; +} from "../../test/factories"; +import { flushdb } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/api/auth.js b/server/routes/api/auth.js similarity index 90% rename from server/api/auth.js rename to server/routes/api/auth.js index d771d4d51..ece17079f 100644 --- a/server/api/auth.js +++ b/server/routes/api/auth.js @@ -1,12 +1,12 @@ // @flow import Router from "koa-router"; import { find } from "lodash"; -import { parseDomain, isCustomSubdomain } from "../../shared/utils/domains"; +import { parseDomain, isCustomSubdomain } from "../../../shared/utils/domains"; +import auth from "../../middlewares/authentication"; +import { Team } from "../../models"; +import { presentUser, presentTeam, presentPolicies } from "../../presenters"; +import { isCustomDomain } from "../../utils/domains"; import providers from "../auth/providers"; -import auth from "../middlewares/authentication"; -import { Team } from "../models"; -import { presentUser, presentTeam, presentPolicies } from "../presenters"; -import { isCustomDomain } from "../utils/domains"; const router = new Router(); diff --git a/server/api/auth.test.js b/server/routes/api/auth.test.js similarity index 97% rename from server/api/auth.test.js rename to server/routes/api/auth.test.js index b1b6d3536..cc47697ce 100644 --- a/server/api/auth.test.js +++ b/server/routes/api/auth.test.js @@ -1,8 +1,8 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import TestServer from "fetch-test-server"; -import webService from "../services/web"; -import { buildUser, buildTeam } from "../test/factories"; -import { flushdb } from "../test/support"; +import webService from "../../services/web"; +import { buildUser, buildTeam } from "../../test/factories"; +import { flushdb } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/api/authenticationProviders.js b/server/routes/api/authenticationProviders.js similarity index 90% rename from server/api/authenticationProviders.js rename to server/routes/api/authenticationProviders.js index 9f9ec8770..f6b81a151 100644 --- a/server/api/authenticationProviders.js +++ b/server/routes/api/authenticationProviders.js @@ -1,10 +1,13 @@ // @flow import Router from "koa-router"; +import auth from "../../middlewares/authentication"; +import { AuthenticationProvider, Event } from "../../models"; +import policy from "../../policies"; +import { + presentAuthenticationProvider, + presentPolicies, +} from "../../presenters"; import allAuthenticationProviders from "../auth/providers"; -import auth from "../middlewares/authentication"; -import { AuthenticationProvider, Event } from "../models"; -import policy from "../policies"; -import { presentAuthenticationProvider, presentPolicies } from "../presenters"; const router = new Router(); const { authorize } = policy; diff --git a/server/api/authenticationProviders.test.js b/server/routes/api/authenticationProviders.test.js similarity index 96% rename from server/api/authenticationProviders.test.js rename to server/routes/api/authenticationProviders.test.js index df50f8717..24491779d 100644 --- a/server/api/authenticationProviders.test.js +++ b/server/routes/api/authenticationProviders.test.js @@ -1,9 +1,9 @@ // @flow import TestServer from "fetch-test-server"; import { v4 as uuidv4 } from "uuid"; -import webService from "../services/web"; -import { buildUser, buildAdmin, buildTeam } from "../test/factories"; -import { flushdb } from "../test/support"; +import webService from "../../services/web"; +import { buildUser, buildAdmin, buildTeam } from "../../test/factories"; +import { flushdb } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/api/collections.js b/server/routes/api/collections.js similarity index 97% rename from server/api/collections.js rename to server/routes/api/collections.js index c0f304d70..adb0046e6 100644 --- a/server/api/collections.js +++ b/server/routes/api/collections.js @@ -1,9 +1,9 @@ // @flow import fractionalIndex from "fractional-index"; import Router from "koa-router"; -import { ValidationError } from "../errors"; -import { exportCollections } from "../exporter"; -import auth from "../middlewares/authentication"; +import { ValidationError } from "../../errors"; +import { exportCollections } from "../../exporter"; +import auth from "../../middlewares/authentication"; import { Collection, CollectionUser, @@ -14,8 +14,8 @@ import { Group, Attachment, FileOperation, -} from "../models"; -import policy from "../policies"; +} from "../../models"; +import policy from "../../policies"; import { presentCollection, presentUser, @@ -24,12 +24,12 @@ import { presentGroup, presentCollectionGroupMembership, presentFileOperation, -} from "../presenters"; -import { Op, sequelize } from "../sequelize"; +} from "../../presenters"; +import { Op, sequelize } from "../../sequelize"; -import collectionIndexing from "../utils/collectionIndexing"; -import removeIndexCollision from "../utils/removeIndexCollision"; -import { getAWSKeyForFileOp } from "../utils/s3"; +import collectionIndexing from "../../utils/collectionIndexing"; +import removeIndexCollision from "../../utils/removeIndexCollision"; +import { getAWSKeyForFileOp } from "../../utils/s3"; import pagination from "./middlewares/pagination"; const { authorize } = policy; diff --git a/server/api/collections.test.js b/server/routes/api/collections.test.js similarity index 99% rename from server/api/collections.test.js rename to server/routes/api/collections.test.js index d14b736c2..2f041fa24 100644 --- a/server/api/collections.test.js +++ b/server/routes/api/collections.test.js @@ -1,15 +1,15 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import TestServer from "fetch-test-server"; -import { Document, CollectionUser, CollectionGroup } from "../models"; -import webService from "../services/web"; +import { Document, CollectionUser, CollectionGroup } from "../../models"; +import webService from "../../services/web"; import { buildUser, buildAdmin, buildGroup, buildCollection, buildDocument, -} from "../test/factories"; -import { flushdb, seed } from "../test/support"; +} from "../../test/factories"; +import { flushdb, seed } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/api/documents.js b/server/routes/api/documents.js similarity index 98% rename from server/api/documents.js rename to server/routes/api/documents.js index ecdd95a71..89df61044 100644 --- a/server/api/documents.js +++ b/server/routes/api/documents.js @@ -1,18 +1,18 @@ // @flow import Router from "koa-router"; import Sequelize from "sequelize"; -import { subtractDate } from "../../shared/utils/date"; -import documentCreator from "../commands/documentCreator"; -import documentImporter from "../commands/documentImporter"; -import documentMover from "../commands/documentMover"; -import { documentPermanentDeleter } from "../commands/documentPermanentDeleter"; -import env from "../env"; +import { subtractDate } from "../../../shared/utils/date"; +import documentCreator from "../../commands/documentCreator"; +import documentImporter from "../../commands/documentImporter"; +import documentMover from "../../commands/documentMover"; +import { documentPermanentDeleter } from "../../commands/documentPermanentDeleter"; +import env from "../../env"; import { NotFoundError, InvalidRequestError, AuthorizationError, -} from "../errors"; -import auth from "../middlewares/authentication"; +} from "../../errors"; +import auth from "../../middlewares/authentication"; import { Backlink, Collection, @@ -25,14 +25,14 @@ import { User, View, Team, -} from "../models"; -import policy from "../policies"; +} from "../../models"; +import policy from "../../policies"; import { presentCollection, presentDocument, presentPolicies, -} from "../presenters"; -import { sequelize } from "../sequelize"; +} from "../../presenters"; +import { sequelize } from "../../sequelize"; import pagination from "./middlewares/pagination"; const Op = Sequelize.Op; diff --git a/server/api/documents.test.js b/server/routes/api/documents.test.js similarity index 99% rename from server/api/documents.test.js rename to server/routes/api/documents.test.js index c2e535b9b..68aab05f6 100644 --- a/server/api/documents.test.js +++ b/server/routes/api/documents.test.js @@ -8,15 +8,15 @@ import { Backlink, CollectionUser, SearchQuery, -} from "../models"; -import webService from "../services/web"; +} from "../../models"; +import webService from "../../services/web"; import { buildShare, buildCollection, buildUser, buildDocument, -} from "../test/factories"; -import { flushdb, seed } from "../test/support"; +} from "../../test/factories"; +import { flushdb, seed } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/api/events.js b/server/routes/api/events.js similarity index 91% rename from server/api/events.js rename to server/routes/api/events.js index 3900f7958..263c18495 100644 --- a/server/api/events.js +++ b/server/routes/api/events.js @@ -1,10 +1,10 @@ // @flow import Router from "koa-router"; import Sequelize from "sequelize"; -import auth from "../middlewares/authentication"; -import { Event, User, Collection } from "../models"; -import policy from "../policies"; -import { presentEvent } from "../presenters"; +import auth from "../../middlewares/authentication"; +import { Event, User, Collection } from "../../models"; +import policy from "../../policies"; +import { presentEvent } from "../../presenters"; import pagination from "./middlewares/pagination"; const Op = Sequelize.Op; diff --git a/server/api/events.test.js b/server/routes/api/events.test.js similarity index 97% rename from server/api/events.test.js rename to server/routes/api/events.test.js index 9c44bd24e..34b780809 100644 --- a/server/api/events.test.js +++ b/server/routes/api/events.test.js @@ -1,8 +1,8 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import TestServer from "fetch-test-server"; -import webService from "../services/web"; -import { buildEvent, buildUser } from "../test/factories"; -import { flushdb, seed } from "../test/support"; +import webService from "../../services/web"; +import { buildEvent, buildUser } from "../../test/factories"; +import { flushdb, seed } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/api/fileOperations.js b/server/routes/api/fileOperations.js similarity index 87% rename from server/api/fileOperations.js rename to server/routes/api/fileOperations.js index adda43b40..acc12f2d3 100644 --- a/server/api/fileOperations.js +++ b/server/routes/api/fileOperations.js @@ -1,11 +1,11 @@ // @flow import Router from "koa-router"; -import { NotFoundError, ValidationError } from "../errors"; -import auth from "../middlewares/authentication"; -import { FileOperation, Team } from "../models"; -import policy from "../policies"; -import { presentFileOperation } from "../presenters"; -import { getSignedUrl } from "../utils/s3"; +import { NotFoundError, ValidationError } from "../../errors"; +import auth from "../../middlewares/authentication"; +import { FileOperation, Team } from "../../models"; +import policy from "../../policies"; +import { presentFileOperation } from "../../presenters"; +import { getSignedUrl } from "../../utils/s3"; import pagination from "./middlewares/pagination"; const { authorize } = policy; diff --git a/server/api/fileOperations.test.js b/server/routes/api/fileOperations.test.js similarity index 97% rename from server/api/fileOperations.test.js rename to server/routes/api/fileOperations.test.js index fa81e0989..2bc1a840d 100644 --- a/server/api/fileOperations.test.js +++ b/server/routes/api/fileOperations.test.js @@ -1,16 +1,16 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import TestServer from "fetch-test-server"; -import { Collection, User } from "../models"; -import webService from "../services/web"; +import { Collection, User } from "../../models"; +import webService from "../../services/web"; import { buildAdmin, buildCollection, buildFileOperation, buildTeam, buildUser, -} from "../test/factories"; -import { flushdb } from "../test/support"; +} from "../../test/factories"; +import { flushdb } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/api/groups.js b/server/routes/api/groups.js similarity index 95% rename from server/api/groups.js rename to server/routes/api/groups.js index 78847b3d7..e8e064add 100644 --- a/server/api/groups.js +++ b/server/routes/api/groups.js @@ -1,17 +1,17 @@ // @flow import Router from "koa-router"; -import { MAX_AVATAR_DISPLAY } from "../../shared/constants"; -import auth from "../middlewares/authentication"; +import { MAX_AVATAR_DISPLAY } from "../../../shared/constants"; +import auth from "../../middlewares/authentication"; -import { User, Event, Group, GroupUser } from "../models"; -import policy from "../policies"; +import { User, Event, Group, GroupUser } from "../../models"; +import policy from "../../policies"; import { presentGroup, presentPolicies, presentUser, presentGroupMembership, -} from "../presenters"; -import { Op } from "../sequelize"; +} from "../../presenters"; +import { Op } from "../../sequelize"; import pagination from "./middlewares/pagination"; const { authorize } = policy; diff --git a/server/api/groups.test.js b/server/routes/api/groups.test.js similarity index 98% rename from server/api/groups.test.js rename to server/routes/api/groups.test.js index 57abbc9c3..4902a7eb9 100644 --- a/server/api/groups.test.js +++ b/server/routes/api/groups.test.js @@ -1,9 +1,9 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import TestServer from "fetch-test-server"; -import { Event } from "../models"; -import webService from "../services/web"; -import { buildUser, buildAdmin, buildGroup } from "../test/factories"; -import { flushdb } from "../test/support"; +import { Event } from "../../models"; +import webService from "../../services/web"; +import { buildUser, buildAdmin, buildGroup } from "../../test/factories"; +import { flushdb } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/api/hooks.js b/server/routes/api/hooks.js similarity index 97% rename from server/api/hooks.js rename to server/routes/api/hooks.js index 376e42591..0c36cb168 100644 --- a/server/api/hooks.js +++ b/server/routes/api/hooks.js @@ -1,7 +1,7 @@ // @flow import Router from "koa-router"; import { escapeRegExp } from "lodash"; -import { AuthenticationError, InvalidRequestError } from "../errors"; +import { AuthenticationError, InvalidRequestError } from "../../errors"; import { UserAuthentication, AuthenticationProvider, @@ -11,9 +11,9 @@ import { SearchQuery, Integration, IntegrationAuthentication, -} from "../models"; -import { presentSlackAttachment } from "../presenters"; -import * as Slack from "../slack"; +} from "../../models"; +import { presentSlackAttachment } from "../../presenters"; +import * as Slack from "../../slack"; const router = new Router(); // triggered by a user posting a getoutline.com link in Slack diff --git a/server/api/hooks.test.js b/server/routes/api/hooks.test.js similarity index 97% rename from server/api/hooks.test.js rename to server/routes/api/hooks.test.js index c3fd60bc1..821089776 100644 --- a/server/api/hooks.test.js +++ b/server/routes/api/hooks.test.js @@ -1,10 +1,10 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import TestServer from "fetch-test-server"; -import { IntegrationAuthentication, SearchQuery } from "../models"; -import webService from "../services/web"; -import * as Slack from "../slack"; -import { buildDocument, buildIntegration } from "../test/factories"; -import { flushdb, seed } from "../test/support"; +import { IntegrationAuthentication, SearchQuery } from "../../models"; +import webService from "../../services/web"; +import * as Slack from "../../slack"; +import { buildDocument, buildIntegration } from "../../test/factories"; +import { flushdb, seed } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); @@ -12,7 +12,7 @@ const server = new TestServer(app.callback()); beforeEach(() => flushdb()); afterAll(() => server.close()); -jest.mock("../slack", () => ({ +jest.mock("../../slack", () => ({ post: jest.fn(), })); diff --git a/server/api/index.js b/server/routes/api/index.js similarity index 90% rename from server/api/index.js rename to server/routes/api/index.js index 585d39bf2..dc469fcff 100644 --- a/server/api/index.js +++ b/server/routes/api/index.js @@ -3,10 +3,10 @@ import Koa from "koa"; import bodyParser from "koa-body"; import Router from "koa-router"; -import { NotFoundError } from "../errors"; -import errorHandling from "../middlewares/errorHandling"; -import methodOverride from "../middlewares/methodOverride"; -import validation from "../middlewares/validation"; +import { NotFoundError } from "../../errors"; +import errorHandling from "../../middlewares/errorHandling"; +import methodOverride from "../../middlewares/methodOverride"; +import validation from "../../middlewares/validation"; import apiKeys from "./apiKeys"; import attachments from "./attachments"; import auth from "./auth"; diff --git a/server/api/index.test.js b/server/routes/api/index.test.js similarity index 86% rename from server/api/index.test.js rename to server/routes/api/index.test.js index becef203e..ab7689335 100644 --- a/server/api/index.test.js +++ b/server/routes/api/index.test.js @@ -1,7 +1,7 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import TestServer from "fetch-test-server"; -import webService from "../services/web"; -import { flushdb } from "../test/support"; +import webService from "../../services/web"; +import { flushdb } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/api/integrations.js b/server/routes/api/integrations.js similarity index 84% rename from server/api/integrations.js rename to server/routes/api/integrations.js index 672e7ab03..3abfe9b8c 100644 --- a/server/api/integrations.js +++ b/server/routes/api/integrations.js @@ -1,10 +1,10 @@ // @flow import Router from "koa-router"; -import auth from "../middlewares/authentication"; -import { Event } from "../models"; -import Integration from "../models/Integration"; -import policy from "../policies"; -import { presentIntegration } from "../presenters"; +import auth from "../../middlewares/authentication"; +import { Event } from "../../models"; +import Integration from "../../models/Integration"; +import policy from "../../policies"; +import { presentIntegration } from "../../presenters"; import pagination from "./middlewares/pagination"; const { authorize } = policy; diff --git a/server/api/middlewares/apiWrapper.js b/server/routes/api/middlewares/apiWrapper.js similarity index 100% rename from server/api/middlewares/apiWrapper.js rename to server/routes/api/middlewares/apiWrapper.js diff --git a/server/api/middlewares/editor.js b/server/routes/api/middlewares/editor.js similarity index 94% rename from server/api/middlewares/editor.js rename to server/routes/api/middlewares/editor.js index 9b757d553..5436c8506 100644 --- a/server/api/middlewares/editor.js +++ b/server/routes/api/middlewares/editor.js @@ -2,7 +2,7 @@ import { type Context } from "koa"; import pkg from "rich-markdown-editor/package.json"; import semver from "semver"; -import { EditorUpdateError } from "../../errors"; +import { EditorUpdateError } from "../../../errors"; export default function editor() { return async function editorMiddleware(ctx: Context, next: () => Promise<*>) { diff --git a/server/api/middlewares/pagination.js b/server/routes/api/middlewares/pagination.js similarity index 97% rename from server/api/middlewares/pagination.js rename to server/routes/api/middlewares/pagination.js index d44748e55..b1bdbd0c4 100644 --- a/server/api/middlewares/pagination.js +++ b/server/routes/api/middlewares/pagination.js @@ -1,7 +1,7 @@ // @flow import querystring from "querystring"; import { type Context } from "koa"; -import { InvalidRequestError } from "../../errors"; +import { InvalidRequestError } from "../../../errors"; export default function pagination(options?: Object) { return async function paginationMiddleware( diff --git a/server/api/middlewares/pagination.test.js b/server/routes/api/middlewares/pagination.test.js similarity index 93% rename from server/api/middlewares/pagination.test.js rename to server/routes/api/middlewares/pagination.test.js index 4f700e7eb..2c5d86fad 100644 --- a/server/api/middlewares/pagination.test.js +++ b/server/routes/api/middlewares/pagination.test.js @@ -1,7 +1,7 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import TestServer from "fetch-test-server"; -import webService from "../../services/web"; -import { flushdb, seed } from "../../test/support"; +import webService from "../../../services/web"; +import { flushdb, seed } from "../../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/api/notificationSettings.js b/server/routes/api/notificationSettings.js similarity index 89% rename from server/api/notificationSettings.js rename to server/routes/api/notificationSettings.js index 6d86a9e35..dd457f833 100644 --- a/server/api/notificationSettings.js +++ b/server/routes/api/notificationSettings.js @@ -1,10 +1,10 @@ // @flow import Router from "koa-router"; -import auth from "../middlewares/authentication"; -import { Team, NotificationSetting } from "../models"; -import policy from "../policies"; -import { presentNotificationSetting } from "../presenters"; +import auth from "../../middlewares/authentication"; +import { Team, NotificationSetting } from "../../models"; +import policy from "../../policies"; +import { presentNotificationSetting } from "../../presenters"; const { authorize } = policy; const router = new Router(); diff --git a/server/api/revisions.js b/server/routes/api/revisions.js similarity index 85% rename from server/api/revisions.js rename to server/routes/api/revisions.js index 5c4a2df5d..83a1fbccc 100644 --- a/server/api/revisions.js +++ b/server/routes/api/revisions.js @@ -1,10 +1,10 @@ // @flow import Router from "koa-router"; -import { NotFoundError } from "../errors"; -import auth from "../middlewares/authentication"; -import { Document, Revision } from "../models"; -import policy from "../policies"; -import { presentRevision } from "../presenters"; +import { NotFoundError } from "../../errors"; +import auth from "../../middlewares/authentication"; +import { Document, Revision } from "../../models"; +import policy from "../../policies"; +import { presentRevision } from "../../presenters"; import pagination from "./middlewares/pagination"; const { authorize } = policy; diff --git a/server/api/revisions.test.js b/server/routes/api/revisions.test.js similarity index 92% rename from server/api/revisions.test.js rename to server/routes/api/revisions.test.js index c03139d32..bf44de10f 100644 --- a/server/api/revisions.test.js +++ b/server/routes/api/revisions.test.js @@ -1,9 +1,9 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import TestServer from "fetch-test-server"; -import { Revision } from "../models"; -import webService from "../services/web"; -import { buildDocument, buildUser } from "../test/factories"; -import { flushdb, seed } from "../test/support"; +import { Revision } from "../../models"; +import webService from "../../services/web"; +import { buildDocument, buildUser } from "../../test/factories"; +import { flushdb, seed } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/api/shares.js b/server/routes/api/shares.js similarity index 96% rename from server/api/shares.js rename to server/routes/api/shares.js index fd65f7eb6..2ec30771d 100644 --- a/server/api/shares.js +++ b/server/routes/api/shares.js @@ -1,11 +1,11 @@ // @flow import Router from "koa-router"; import Sequelize from "sequelize"; -import { NotFoundError } from "../errors"; -import auth from "../middlewares/authentication"; -import { Document, User, Event, Share, Team, Collection } from "../models"; -import policy from "../policies"; -import { presentShare, presentPolicies } from "../presenters"; +import { NotFoundError } from "../../errors"; +import auth from "../../middlewares/authentication"; +import { Document, User, Event, Share, Team, Collection } from "../../models"; +import policy from "../../policies"; +import { presentShare, presentPolicies } from "../../presenters"; import pagination from "./middlewares/pagination"; const Op = Sequelize.Op; diff --git a/server/api/shares.test.js b/server/routes/api/shares.test.js similarity index 98% rename from server/api/shares.test.js rename to server/routes/api/shares.test.js index a55e607f8..aedfc3fdb 100644 --- a/server/api/shares.test.js +++ b/server/routes/api/shares.test.js @@ -1,9 +1,9 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import TestServer from "fetch-test-server"; -import { CollectionUser } from "../models"; -import webService from "../services/web"; -import { buildUser, buildDocument, buildShare } from "../test/factories"; -import { flushdb, seed } from "../test/support"; +import { CollectionUser } from "../../models"; +import webService from "../../services/web"; +import { buildUser, buildDocument, buildShare } from "../../test/factories"; +import { flushdb, seed } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/api/team.js b/server/routes/api/team.js similarity index 86% rename from server/api/team.js rename to server/routes/api/team.js index c71f8d829..b7d8a1455 100644 --- a/server/api/team.js +++ b/server/routes/api/team.js @@ -1,10 +1,10 @@ // @flow import Router from "koa-router"; -import auth from "../middlewares/authentication"; -import { Event, Team } from "../models"; +import auth from "../../middlewares/authentication"; +import { Event, Team } from "../../models"; -import policy from "../policies"; -import { presentTeam, presentPolicies } from "../presenters"; +import policy from "../../policies"; +import { presentTeam, presentPolicies } from "../../presenters"; const { authorize } = policy; const router = new Router(); diff --git a/server/api/team.test.js b/server/routes/api/team.test.js similarity index 93% rename from server/api/team.test.js rename to server/routes/api/team.test.js index 2e87db188..6bc70a7c2 100644 --- a/server/api/team.test.js +++ b/server/routes/api/team.test.js @@ -1,8 +1,8 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import TestServer from "fetch-test-server"; -import webService from "../services/web"; +import webService from "../../services/web"; -import { flushdb, seed } from "../test/support"; +import { flushdb, seed } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/api/users.js b/server/routes/api/users.js similarity index 93% rename from server/api/users.js rename to server/routes/api/users.js index 435f13eac..945ddab37 100644 --- a/server/api/users.js +++ b/server/routes/api/users.js @@ -1,13 +1,13 @@ // @flow import Router from "koa-router"; -import userDestroyer from "../commands/userDestroyer"; -import userInviter from "../commands/userInviter"; -import userSuspender from "../commands/userSuspender"; -import auth from "../middlewares/authentication"; -import { Event, User, Team } from "../models"; -import policy from "../policies"; -import { presentUser, presentPolicies } from "../presenters"; -import { Op } from "../sequelize"; +import userDestroyer from "../../commands/userDestroyer"; +import userInviter from "../../commands/userInviter"; +import userSuspender from "../../commands/userSuspender"; +import auth from "../../middlewares/authentication"; +import { Event, User, Team } from "../../models"; +import policy from "../../policies"; +import { presentUser, presentPolicies } from "../../presenters"; +import { Op } from "../../sequelize"; import pagination from "./middlewares/pagination"; const { can, authorize } = policy; diff --git a/server/api/users.test.js b/server/routes/api/users.test.js similarity index 99% rename from server/api/users.test.js rename to server/routes/api/users.test.js index 6734846cf..6e9e1ae28 100644 --- a/server/api/users.test.js +++ b/server/routes/api/users.test.js @@ -1,10 +1,10 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import TestServer from "fetch-test-server"; -import webService from "../services/web"; +import webService from "../../services/web"; -import { buildTeam, buildAdmin, buildUser } from "../test/factories"; +import { buildTeam, buildAdmin, buildUser } from "../../test/factories"; -import { flushdb, seed } from "../test/support"; +import { flushdb, seed } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/api/utils.js b/server/routes/api/utils.js similarity index 84% rename from server/api/utils.js rename to server/routes/api/utils.js index 0c66cbeb5..d5615147a 100644 --- a/server/api/utils.js +++ b/server/routes/api/utils.js @@ -2,10 +2,10 @@ import { subDays } from "date-fns"; import debug from "debug"; import Router from "koa-router"; -import { documentPermanentDeleter } from "../commands/documentPermanentDeleter"; -import { AuthenticationError } from "../errors"; -import { Document, FileOperation } from "../models"; -import { Op } from "../sequelize"; +import { documentPermanentDeleter } from "../../commands/documentPermanentDeleter"; +import { AuthenticationError } from "../../errors"; +import { Document, FileOperation } from "../../models"; +import { Op } from "../../sequelize"; const router = new Router(); const log = debug("utils"); diff --git a/server/api/utils.test.js b/server/routes/api/utils.test.js similarity index 93% rename from server/api/utils.test.js rename to server/routes/api/utils.test.js index aad53c637..fc2f667d3 100644 --- a/server/api/utils.test.js +++ b/server/routes/api/utils.test.js @@ -1,11 +1,11 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import { subDays } from "date-fns"; import TestServer from "fetch-test-server"; -import { Document, FileOperation } from "../models"; -import { Op } from "../sequelize"; -import webService from "../services/web"; -import { buildDocument, buildFileOperation } from "../test/factories"; -import { flushdb } from "../test/support"; +import { Document, FileOperation } from "../../models"; +import { Op } from "../../sequelize"; +import webService from "../../services/web"; +import { buildDocument, buildFileOperation } from "../../test/factories"; +import { flushdb } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/api/views.js b/server/routes/api/views.js similarity index 86% rename from server/api/views.js rename to server/routes/api/views.js index e71a1e0df..4bd18a5d3 100644 --- a/server/api/views.js +++ b/server/routes/api/views.js @@ -1,9 +1,9 @@ // @flow import Router from "koa-router"; -import auth from "../middlewares/authentication"; -import { View, Document, Event } from "../models"; -import policy from "../policies"; -import { presentView } from "../presenters"; +import auth from "../../middlewares/authentication"; +import { View, Document, Event } from "../../models"; +import policy from "../../policies"; +import { presentView } from "../../presenters"; const { authorize } = policy; const router = new Router(); diff --git a/server/api/views.test.js b/server/routes/api/views.test.js similarity index 94% rename from server/api/views.test.js rename to server/routes/api/views.test.js index ba2611661..69e5f595c 100644 --- a/server/api/views.test.js +++ b/server/routes/api/views.test.js @@ -1,9 +1,9 @@ /* eslint-disable flowtype/require-valid-file-annotation */ import TestServer from "fetch-test-server"; -import { View, CollectionUser } from "../models"; -import webService from "../services/web"; -import { buildUser } from "../test/factories"; -import { flushdb, seed } from "../test/support"; +import { View, CollectionUser } from "../../models"; +import webService from "../../services/web"; +import { buildUser } from "../../test/factories"; +import { flushdb, seed } from "../../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/auth/index.js b/server/routes/auth/index.js similarity index 88% rename from server/auth/index.js rename to server/routes/auth/index.js index df8e2bf38..5974340de 100644 --- a/server/auth/index.js +++ b/server/routes/auth/index.js @@ -5,10 +5,10 @@ import debug from "debug"; import Koa from "koa"; import bodyParser from "koa-body"; import Router from "koa-router"; -import { AuthenticationError } from "../errors"; -import auth from "../middlewares/authentication"; -import validation from "../middlewares/validation"; -import { Collection, Team, View } from "../models"; +import { AuthenticationError } from "../../errors"; +import auth from "../../middlewares/authentication"; +import validation from "../../middlewares/validation"; +import { Collection, Team, View } from "../../models"; import providers from "./providers"; const log = debug("server"); diff --git a/server/auth/providers/README.md b/server/routes/auth/providers/README.md similarity index 100% rename from server/auth/providers/README.md rename to server/routes/auth/providers/README.md diff --git a/server/auth/providers/azure.js b/server/routes/auth/providers/azure.js similarity index 93% rename from server/auth/providers/azure.js rename to server/routes/auth/providers/azure.js index 66cb0eeab..9c6068118 100644 --- a/server/auth/providers/azure.js +++ b/server/routes/auth/providers/azure.js @@ -4,11 +4,11 @@ import { Strategy as AzureStrategy } from "@outlinewiki/passport-azure-ad-oauth2 import fetch from "fetch-with-proxy"; import jwt from "jsonwebtoken"; import Router from "koa-router"; -import accountProvisioner from "../../commands/accountProvisioner"; -import env from "../../env"; -import { MicrosoftGraphError } from "../../errors"; -import passportMiddleware from "../../middlewares/passport"; -import { StateStore } from "../../utils/passport"; +import accountProvisioner from "../../../commands/accountProvisioner"; +import env from "../../../env"; +import { MicrosoftGraphError } from "../../../errors"; +import passportMiddleware from "../../../middlewares/passport"; +import { StateStore } from "../../../utils/passport"; const router = new Router(); const providerName = "azure"; diff --git a/server/auth/providers/email.js b/server/routes/auth/providers/email.js similarity index 86% rename from server/auth/providers/email.js rename to server/routes/auth/providers/email.js index c6608bff9..0b1ae19d9 100644 --- a/server/auth/providers/email.js +++ b/server/routes/auth/providers/email.js @@ -2,16 +2,19 @@ import { subMinutes } from "date-fns"; import Router from "koa-router"; import { find } from "lodash"; -import { parseDomain, isCustomSubdomain } from "../../../shared/utils/domains"; -import { AuthorizationError } from "../../errors"; -import mailer from "../../mailer"; -import errorHandling from "../../middlewares/errorHandling"; -import methodOverride from "../../middlewares/methodOverride"; -import validation from "../../middlewares/validation"; -import { User, Team } from "../../models"; -import { signIn } from "../../utils/authentication"; -import { isCustomDomain } from "../../utils/domains"; -import { getUserForEmailSigninToken } from "../../utils/jwt"; +import { + parseDomain, + isCustomSubdomain, +} from "../../../../shared/utils/domains"; +import { AuthorizationError } from "../../../errors"; +import mailer from "../../../mailer"; +import errorHandling from "../../../middlewares/errorHandling"; +import methodOverride from "../../../middlewares/methodOverride"; +import validation from "../../../middlewares/validation"; +import { User, Team } from "../../../models"; +import { signIn } from "../../../utils/authentication"; +import { isCustomDomain } from "../../../utils/domains"; +import { getUserForEmailSigninToken } from "../../../utils/jwt"; const router = new Router(); diff --git a/server/auth/providers/email.test.js b/server/routes/auth/providers/email.test.js similarity index 95% rename from server/auth/providers/email.test.js rename to server/routes/auth/providers/email.test.js index 3c7323e3b..98358d03b 100644 --- a/server/auth/providers/email.test.js +++ b/server/routes/auth/providers/email.test.js @@ -1,14 +1,14 @@ // @flow import TestServer from "fetch-test-server"; -import mailer from "../../mailer"; -import webService from "../../services/web"; -import { buildUser, buildGuestUser, buildTeam } from "../../test/factories"; -import { flushdb } from "../../test/support"; +import mailer from "../../../mailer"; +import webService from "../../../services/web"; +import { buildUser, buildGuestUser, buildTeam } from "../../../test/factories"; +import { flushdb } from "../../../test/support"; const app = webService(); const server = new TestServer(app.callback()); -jest.mock("../../mailer"); +jest.mock("../../../mailer"); beforeEach(async () => { await flushdb(); diff --git a/server/auth/providers/google.js b/server/routes/auth/providers/google.js similarity index 88% rename from server/auth/providers/google.js rename to server/routes/auth/providers/google.js index 334de42b6..885c19c78 100644 --- a/server/auth/providers/google.js +++ b/server/routes/auth/providers/google.js @@ -3,15 +3,15 @@ import passport from "@outlinewiki/koa-passport"; import Router from "koa-router"; import { capitalize } from "lodash"; import { Strategy as GoogleStrategy } from "passport-google-oauth2"; -import accountProvisioner from "../../commands/accountProvisioner"; -import env from "../../env"; +import accountProvisioner from "../../../commands/accountProvisioner"; +import env from "../../../env"; import { GoogleWorkspaceRequiredError, GoogleWorkspaceInvalidError, -} from "../../errors"; -import passportMiddleware from "../../middlewares/passport"; -import { getAllowedDomains } from "../../utils/authentication"; -import { StateStore } from "../../utils/passport"; +} from "../../../errors"; +import passportMiddleware from "../../../middlewares/passport"; +import { getAllowedDomains } from "../../../utils/authentication"; +import { StateStore } from "../../../utils/passport"; const router = new Router(); const providerName = "google"; diff --git a/server/auth/providers/index.js b/server/routes/auth/providers/index.js similarity index 84% rename from server/auth/providers/index.js rename to server/routes/auth/providers/index.js index 75e1c2a58..3bd135cae 100644 --- a/server/auth/providers/index.js +++ b/server/routes/auth/providers/index.js @@ -1,6 +1,6 @@ // @flow -import { signin } from "../../../shared/utils/routeHelpers"; -import { requireDirectory } from "../../utils/fs"; +import { signin } from "../../../../shared/utils/routeHelpers"; +import { requireDirectory } from "../../../utils/fs"; let providers = []; diff --git a/server/auth/providers/slack.js b/server/routes/auth/providers/slack.js similarity index 94% rename from server/auth/providers/slack.js rename to server/routes/auth/providers/slack.js index 104f9202b..ede4e2e7a 100644 --- a/server/auth/providers/slack.js +++ b/server/routes/auth/providers/slack.js @@ -2,18 +2,18 @@ import passport from "@outlinewiki/koa-passport"; import Router from "koa-router"; import { Strategy as SlackStrategy } from "passport-slack-oauth2"; -import accountProvisioner from "../../commands/accountProvisioner"; -import env from "../../env"; -import auth from "../../middlewares/authentication"; -import passportMiddleware from "../../middlewares/passport"; +import accountProvisioner from "../../../commands/accountProvisioner"; +import env from "../../../env"; +import auth from "../../../middlewares/authentication"; +import passportMiddleware from "../../../middlewares/passport"; import { IntegrationAuthentication, Collection, Integration, Team, -} from "../../models"; -import * as Slack from "../../slack"; -import { StateStore } from "../../utils/passport"; +} from "../../../models"; +import * as Slack from "../../../slack"; +import { StateStore } from "../../../utils/passport"; const router = new Router(); const providerName = "slack"; diff --git a/server/routes.js b/server/routes/index.js similarity index 82% rename from server/routes.js rename to server/routes/index.js index c94bc4991..8f7146866 100644 --- a/server/routes.js +++ b/server/routes/index.js @@ -7,14 +7,14 @@ import Router from "koa-router"; import sendfile from "koa-sendfile"; import serve from "koa-static"; import isUUID from "validator/lib/isUUID"; -import { languages } from "../shared/i18n"; -import env from "./env"; -import apexRedirect from "./middlewares/apexRedirect"; -import Share from "./models/Share"; -import presentEnv from "./presenters/env"; -import { opensearchResponse } from "./utils/opensearch"; -import prefetchTags from "./utils/prefetchTags"; -import { robotsResponse } from "./utils/robots"; +import { languages } from "../../shared/i18n"; +import env from "../env"; +import apexRedirect from "../middlewares/apexRedirect"; +import Share from "../models/Share"; +import presentEnv from "../presenters/env"; +import { opensearchResponse } from "../utils/opensearch"; +import prefetchTags from "../utils/prefetchTags"; +import { robotsResponse } from "../utils/robots"; const isProduction = process.env.NODE_ENV === "production"; const isTest = process.env.NODE_ENV === "test"; @@ -24,10 +24,10 @@ const readFile = util.promisify(fs.readFile); const readIndexFile = async (ctx) => { if (isProduction) { - return readFile(path.join(__dirname, "../app/index.html")); + return readFile(path.join(__dirname, "../../app/index.html")); } if (isTest) { - return readFile(path.join(__dirname, "/static/index.html")); + return readFile(path.join(__dirname, "../static/index.html")); } const middleware = ctx.devMiddleware; @@ -88,7 +88,7 @@ const renderShare = async (ctx, next) => { // serve static assets koa.use( - serve(path.resolve(__dirname, "../../public"), { + serve(path.resolve(__dirname, "../../../public"), { maxage: 60 * 60 * 24 * 30 * 1000, }) ); @@ -103,7 +103,10 @@ if (process.env.NODE_ENV === "production") { "Cache-Control": `max-age=${356 * 24 * 60 * 60}`, }); - await sendfile(ctx, path.join(__dirname, "../app/", ctx.path.substring(8))); + await sendfile( + ctx, + path.join(__dirname, "../../app/", ctx.path.substring(8)) + ); }); } @@ -123,7 +126,7 @@ router.get("/locales/:lng.json", async (ctx) => { await sendfile( ctx, - path.join(__dirname, "../shared/i18n/locales", lng, "translation.json") + path.join(__dirname, "../../shared/i18n/locales", lng, "translation.json") ); }); diff --git a/server/routes.test.js b/server/routes/index.test.js similarity index 93% rename from server/routes.test.js rename to server/routes/index.test.js index 7302ab061..a0e501eec 100644 --- a/server/routes.test.js +++ b/server/routes/index.test.js @@ -1,8 +1,8 @@ // @flow import TestServer from "fetch-test-server"; -import webService from "./services/web"; -import { buildShare, buildDocument } from "./test/factories"; -import { flushdb } from "./test/support"; +import webService from "../services/web"; +import { buildShare, buildDocument } from "../test/factories"; +import { flushdb } from "../test/support"; const app = webService(); const server = new TestServer(app.callback()); diff --git a/server/services/web.js b/server/services/web.js index 85fa9150a..a2df0eb5e 100644 --- a/server/services/web.js +++ b/server/services/web.js @@ -9,11 +9,11 @@ import { import mount from "koa-mount"; import onerror from "koa-onerror"; import enforceHttps from "koa-sslify"; -import api from "../api"; -import auth from "../auth"; import emails from "../emails"; import env from "../env"; import routes from "../routes"; +import api from "../routes/api"; +import auth from "../routes/auth"; import Sentry from "../sentry"; const isProduction = env.NODE_ENV === "production";