chore: Move all routes under routes directory (#2513)

closes #2504
This commit is contained in:
Tom Moor
2021-08-29 13:25:06 -07:00
committed by GitHub
parent 9a875920ac
commit 3dfd336f59
58 changed files with 233 additions and 224 deletions

View File

@ -1,6 +1,6 @@
// @flow // @flow
import providers from "../auth/providers";
import { ValidationError } from "../errors"; import { ValidationError } from "../errors";
import providers from "../routes/auth/providers";
import { DataTypes, Op, sequelize } from "../sequelize"; import { DataTypes, Op, sequelize } from "../sequelize";
const AuthenticationProvider = sequelize.define( const AuthenticationProvider = sequelize.define(

View File

@ -1,10 +1,10 @@
// @flow // @flow
import Router from "koa-router"; import Router from "koa-router";
import auth from "../middlewares/authentication"; import auth from "../../middlewares/authentication";
import { ApiKey, Event } from "../models"; import { ApiKey, Event } from "../../models";
import policy from "../policies"; import policy from "../../policies";
import { presentApiKey } from "../presenters"; import { presentApiKey } from "../../presenters";
import pagination from "./middlewares/pagination"; import pagination from "./middlewares/pagination";
const { authorize } = policy; const { authorize } = policy;

View File

@ -2,17 +2,17 @@
import { format } from "date-fns"; import { format } from "date-fns";
import Router from "koa-router"; import Router from "koa-router";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import { NotFoundError } from "../errors"; import { NotFoundError } from "../../errors";
import auth from "../middlewares/authentication"; import auth from "../../middlewares/authentication";
import { Attachment, Document, Event } from "../models"; import { Attachment, Document, Event } from "../../models";
import policy from "../policies"; import policy from "../../policies";
import { import {
makePolicy, makePolicy,
getSignature, getSignature,
publicS3Endpoint, publicS3Endpoint,
makeCredential, makeCredential,
getSignedUrl, getSignedUrl,
} from "../utils/s3"; } from "../../utils/s3";
const { authorize } = policy; const { authorize } = policy;
const router = new Router(); const router = new Router();

View File

@ -1,15 +1,15 @@
/* eslint-disable flowtype/require-valid-file-annotation */ /* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { Attachment } from "../models"; import { Attachment } from "../../models";
import webService from "../services/web"; import webService from "../../services/web";
import { import {
buildUser, buildUser,
buildAdmin, buildAdmin,
buildCollection, buildCollection,
buildAttachment, buildAttachment,
buildDocument, buildDocument,
} from "../test/factories"; } from "../../test/factories";
import { flushdb } from "../test/support"; import { flushdb } from "../../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -1,12 +1,12 @@
// @flow // @flow
import Router from "koa-router"; import Router from "koa-router";
import { find } from "lodash"; 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 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(); const router = new Router();

View File

@ -1,8 +1,8 @@
/* eslint-disable flowtype/require-valid-file-annotation */ /* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import webService from "../services/web"; import webService from "../../services/web";
import { buildUser, buildTeam } from "../test/factories"; import { buildUser, buildTeam } from "../../test/factories";
import { flushdb } from "../test/support"; import { flushdb } from "../../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -1,10 +1,13 @@
// @flow // @flow
import Router from "koa-router"; 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 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 router = new Router();
const { authorize } = policy; const { authorize } = policy;

View File

@ -1,9 +1,9 @@
// @flow // @flow
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import webService from "../services/web"; import webService from "../../services/web";
import { buildUser, buildAdmin, buildTeam } from "../test/factories"; import { buildUser, buildAdmin, buildTeam } from "../../test/factories";
import { flushdb } from "../test/support"; import { flushdb } from "../../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -1,9 +1,9 @@
// @flow // @flow
import fractionalIndex from "fractional-index"; import fractionalIndex from "fractional-index";
import Router from "koa-router"; import Router from "koa-router";
import { ValidationError } from "../errors"; import { ValidationError } from "../../errors";
import { exportCollections } from "../exporter"; import { exportCollections } from "../../exporter";
import auth from "../middlewares/authentication"; import auth from "../../middlewares/authentication";
import { import {
Collection, Collection,
CollectionUser, CollectionUser,
@ -14,8 +14,8 @@ import {
Group, Group,
Attachment, Attachment,
FileOperation, FileOperation,
} from "../models"; } from "../../models";
import policy from "../policies"; import policy from "../../policies";
import { import {
presentCollection, presentCollection,
presentUser, presentUser,
@ -24,12 +24,12 @@ import {
presentGroup, presentGroup,
presentCollectionGroupMembership, presentCollectionGroupMembership,
presentFileOperation, presentFileOperation,
} from "../presenters"; } from "../../presenters";
import { Op, sequelize } from "../sequelize"; import { Op, sequelize } from "../../sequelize";
import collectionIndexing from "../utils/collectionIndexing"; import collectionIndexing from "../../utils/collectionIndexing";
import removeIndexCollision from "../utils/removeIndexCollision"; import removeIndexCollision from "../../utils/removeIndexCollision";
import { getAWSKeyForFileOp } from "../utils/s3"; import { getAWSKeyForFileOp } from "../../utils/s3";
import pagination from "./middlewares/pagination"; import pagination from "./middlewares/pagination";
const { authorize } = policy; const { authorize } = policy;

View File

@ -1,15 +1,15 @@
/* eslint-disable flowtype/require-valid-file-annotation */ /* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { Document, CollectionUser, CollectionGroup } from "../models"; import { Document, CollectionUser, CollectionGroup } from "../../models";
import webService from "../services/web"; import webService from "../../services/web";
import { import {
buildUser, buildUser,
buildAdmin, buildAdmin,
buildGroup, buildGroup,
buildCollection, buildCollection,
buildDocument, buildDocument,
} from "../test/factories"; } from "../../test/factories";
import { flushdb, seed } from "../test/support"; import { flushdb, seed } from "../../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -1,18 +1,18 @@
// @flow // @flow
import Router from "koa-router"; import Router from "koa-router";
import Sequelize from "sequelize"; import Sequelize from "sequelize";
import { subtractDate } from "../../shared/utils/date"; import { subtractDate } from "../../../shared/utils/date";
import documentCreator from "../commands/documentCreator"; import documentCreator from "../../commands/documentCreator";
import documentImporter from "../commands/documentImporter"; import documentImporter from "../../commands/documentImporter";
import documentMover from "../commands/documentMover"; import documentMover from "../../commands/documentMover";
import { documentPermanentDeleter } from "../commands/documentPermanentDeleter"; import { documentPermanentDeleter } from "../../commands/documentPermanentDeleter";
import env from "../env"; import env from "../../env";
import { import {
NotFoundError, NotFoundError,
InvalidRequestError, InvalidRequestError,
AuthorizationError, AuthorizationError,
} from "../errors"; } from "../../errors";
import auth from "../middlewares/authentication"; import auth from "../../middlewares/authentication";
import { import {
Backlink, Backlink,
Collection, Collection,
@ -25,14 +25,14 @@ import {
User, User,
View, View,
Team, Team,
} from "../models"; } from "../../models";
import policy from "../policies"; import policy from "../../policies";
import { import {
presentCollection, presentCollection,
presentDocument, presentDocument,
presentPolicies, presentPolicies,
} from "../presenters"; } from "../../presenters";
import { sequelize } from "../sequelize"; import { sequelize } from "../../sequelize";
import pagination from "./middlewares/pagination"; import pagination from "./middlewares/pagination";
const Op = Sequelize.Op; const Op = Sequelize.Op;

View File

@ -8,15 +8,15 @@ import {
Backlink, Backlink,
CollectionUser, CollectionUser,
SearchQuery, SearchQuery,
} from "../models"; } from "../../models";
import webService from "../services/web"; import webService from "../../services/web";
import { import {
buildShare, buildShare,
buildCollection, buildCollection,
buildUser, buildUser,
buildDocument, buildDocument,
} from "../test/factories"; } from "../../test/factories";
import { flushdb, seed } from "../test/support"; import { flushdb, seed } from "../../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -1,10 +1,10 @@
// @flow // @flow
import Router from "koa-router"; import Router from "koa-router";
import Sequelize from "sequelize"; import Sequelize from "sequelize";
import auth from "../middlewares/authentication"; import auth from "../../middlewares/authentication";
import { Event, User, Collection } from "../models"; import { Event, User, Collection } from "../../models";
import policy from "../policies"; import policy from "../../policies";
import { presentEvent } from "../presenters"; import { presentEvent } from "../../presenters";
import pagination from "./middlewares/pagination"; import pagination from "./middlewares/pagination";
const Op = Sequelize.Op; const Op = Sequelize.Op;

View File

@ -1,8 +1,8 @@
/* eslint-disable flowtype/require-valid-file-annotation */ /* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import webService from "../services/web"; import webService from "../../services/web";
import { buildEvent, buildUser } from "../test/factories"; import { buildEvent, buildUser } from "../../test/factories";
import { flushdb, seed } from "../test/support"; import { flushdb, seed } from "../../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -1,11 +1,11 @@
// @flow // @flow
import Router from "koa-router"; import Router from "koa-router";
import { NotFoundError, ValidationError } from "../errors"; import { NotFoundError, ValidationError } from "../../errors";
import auth from "../middlewares/authentication"; import auth from "../../middlewares/authentication";
import { FileOperation, Team } from "../models"; import { FileOperation, Team } from "../../models";
import policy from "../policies"; import policy from "../../policies";
import { presentFileOperation } from "../presenters"; import { presentFileOperation } from "../../presenters";
import { getSignedUrl } from "../utils/s3"; import { getSignedUrl } from "../../utils/s3";
import pagination from "./middlewares/pagination"; import pagination from "./middlewares/pagination";
const { authorize } = policy; const { authorize } = policy;

View File

@ -1,16 +1,16 @@
/* eslint-disable flowtype/require-valid-file-annotation */ /* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { Collection, User } from "../models"; import { Collection, User } from "../../models";
import webService from "../services/web"; import webService from "../../services/web";
import { import {
buildAdmin, buildAdmin,
buildCollection, buildCollection,
buildFileOperation, buildFileOperation,
buildTeam, buildTeam,
buildUser, buildUser,
} from "../test/factories"; } from "../../test/factories";
import { flushdb } from "../test/support"; import { flushdb } from "../../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -1,17 +1,17 @@
// @flow // @flow
import Router from "koa-router"; import Router from "koa-router";
import { MAX_AVATAR_DISPLAY } from "../../shared/constants"; import { MAX_AVATAR_DISPLAY } from "../../../shared/constants";
import auth from "../middlewares/authentication"; import auth from "../../middlewares/authentication";
import { User, Event, Group, GroupUser } from "../models"; import { User, Event, Group, GroupUser } from "../../models";
import policy from "../policies"; import policy from "../../policies";
import { import {
presentGroup, presentGroup,
presentPolicies, presentPolicies,
presentUser, presentUser,
presentGroupMembership, presentGroupMembership,
} from "../presenters"; } from "../../presenters";
import { Op } from "../sequelize"; import { Op } from "../../sequelize";
import pagination from "./middlewares/pagination"; import pagination from "./middlewares/pagination";
const { authorize } = policy; const { authorize } = policy;

View File

@ -1,9 +1,9 @@
/* eslint-disable flowtype/require-valid-file-annotation */ /* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { Event } from "../models"; import { Event } from "../../models";
import webService from "../services/web"; import webService from "../../services/web";
import { buildUser, buildAdmin, buildGroup } from "../test/factories"; import { buildUser, buildAdmin, buildGroup } from "../../test/factories";
import { flushdb } from "../test/support"; import { flushdb } from "../../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -1,7 +1,7 @@
// @flow // @flow
import Router from "koa-router"; import Router from "koa-router";
import { escapeRegExp } from "lodash"; import { escapeRegExp } from "lodash";
import { AuthenticationError, InvalidRequestError } from "../errors"; import { AuthenticationError, InvalidRequestError } from "../../errors";
import { import {
UserAuthentication, UserAuthentication,
AuthenticationProvider, AuthenticationProvider,
@ -11,9 +11,9 @@ import {
SearchQuery, SearchQuery,
Integration, Integration,
IntegrationAuthentication, IntegrationAuthentication,
} from "../models"; } from "../../models";
import { presentSlackAttachment } from "../presenters"; import { presentSlackAttachment } from "../../presenters";
import * as Slack from "../slack"; import * as Slack from "../../slack";
const router = new Router(); const router = new Router();
// triggered by a user posting a getoutline.com link in Slack // triggered by a user posting a getoutline.com link in Slack

View File

@ -1,10 +1,10 @@
/* eslint-disable flowtype/require-valid-file-annotation */ /* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { IntegrationAuthentication, SearchQuery } from "../models"; import { IntegrationAuthentication, SearchQuery } from "../../models";
import webService from "../services/web"; import webService from "../../services/web";
import * as Slack from "../slack"; import * as Slack from "../../slack";
import { buildDocument, buildIntegration } from "../test/factories"; import { buildDocument, buildIntegration } from "../../test/factories";
import { flushdb, seed } from "../test/support"; import { flushdb, seed } from "../../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());
@ -12,7 +12,7 @@ const server = new TestServer(app.callback());
beforeEach(() => flushdb()); beforeEach(() => flushdb());
afterAll(() => server.close()); afterAll(() => server.close());
jest.mock("../slack", () => ({ jest.mock("../../slack", () => ({
post: jest.fn(), post: jest.fn(),
})); }));

View File

@ -3,10 +3,10 @@ import Koa from "koa";
import bodyParser from "koa-body"; import bodyParser from "koa-body";
import Router from "koa-router"; import Router from "koa-router";
import { NotFoundError } from "../errors"; import { NotFoundError } from "../../errors";
import errorHandling from "../middlewares/errorHandling"; import errorHandling from "../../middlewares/errorHandling";
import methodOverride from "../middlewares/methodOverride"; import methodOverride from "../../middlewares/methodOverride";
import validation from "../middlewares/validation"; import validation from "../../middlewares/validation";
import apiKeys from "./apiKeys"; import apiKeys from "./apiKeys";
import attachments from "./attachments"; import attachments from "./attachments";
import auth from "./auth"; import auth from "./auth";

View File

@ -1,7 +1,7 @@
/* eslint-disable flowtype/require-valid-file-annotation */ /* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import webService from "../services/web"; import webService from "../../services/web";
import { flushdb } from "../test/support"; import { flushdb } from "../../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -1,10 +1,10 @@
// @flow // @flow
import Router from "koa-router"; import Router from "koa-router";
import auth from "../middlewares/authentication"; import auth from "../../middlewares/authentication";
import { Event } from "../models"; import { Event } from "../../models";
import Integration from "../models/Integration"; import Integration from "../../models/Integration";
import policy from "../policies"; import policy from "../../policies";
import { presentIntegration } from "../presenters"; import { presentIntegration } from "../../presenters";
import pagination from "./middlewares/pagination"; import pagination from "./middlewares/pagination";
const { authorize } = policy; const { authorize } = policy;

View File

@ -2,7 +2,7 @@
import { type Context } from "koa"; import { type Context } from "koa";
import pkg from "rich-markdown-editor/package.json"; import pkg from "rich-markdown-editor/package.json";
import semver from "semver"; import semver from "semver";
import { EditorUpdateError } from "../../errors"; import { EditorUpdateError } from "../../../errors";
export default function editor() { export default function editor() {
return async function editorMiddleware(ctx: Context, next: () => Promise<*>) { return async function editorMiddleware(ctx: Context, next: () => Promise<*>) {

View File

@ -1,7 +1,7 @@
// @flow // @flow
import querystring from "querystring"; import querystring from "querystring";
import { type Context } from "koa"; import { type Context } from "koa";
import { InvalidRequestError } from "../../errors"; import { InvalidRequestError } from "../../../errors";
export default function pagination(options?: Object) { export default function pagination(options?: Object) {
return async function paginationMiddleware( return async function paginationMiddleware(

View File

@ -1,7 +1,7 @@
/* eslint-disable flowtype/require-valid-file-annotation */ /* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server"; 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 app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -1,10 +1,10 @@
// @flow // @flow
import Router from "koa-router"; import Router from "koa-router";
import auth from "../middlewares/authentication"; import auth from "../../middlewares/authentication";
import { Team, NotificationSetting } from "../models"; import { Team, NotificationSetting } from "../../models";
import policy from "../policies"; import policy from "../../policies";
import { presentNotificationSetting } from "../presenters"; import { presentNotificationSetting } from "../../presenters";
const { authorize } = policy; const { authorize } = policy;
const router = new Router(); const router = new Router();

View File

@ -1,10 +1,10 @@
// @flow // @flow
import Router from "koa-router"; import Router from "koa-router";
import { NotFoundError } from "../errors"; import { NotFoundError } from "../../errors";
import auth from "../middlewares/authentication"; import auth from "../../middlewares/authentication";
import { Document, Revision } from "../models"; import { Document, Revision } from "../../models";
import policy from "../policies"; import policy from "../../policies";
import { presentRevision } from "../presenters"; import { presentRevision } from "../../presenters";
import pagination from "./middlewares/pagination"; import pagination from "./middlewares/pagination";
const { authorize } = policy; const { authorize } = policy;

View File

@ -1,9 +1,9 @@
/* eslint-disable flowtype/require-valid-file-annotation */ /* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { Revision } from "../models"; import { Revision } from "../../models";
import webService from "../services/web"; import webService from "../../services/web";
import { buildDocument, buildUser } from "../test/factories"; import { buildDocument, buildUser } from "../../test/factories";
import { flushdb, seed } from "../test/support"; import { flushdb, seed } from "../../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -1,11 +1,11 @@
// @flow // @flow
import Router from "koa-router"; import Router from "koa-router";
import Sequelize from "sequelize"; import Sequelize from "sequelize";
import { NotFoundError } from "../errors"; import { NotFoundError } from "../../errors";
import auth from "../middlewares/authentication"; import auth from "../../middlewares/authentication";
import { Document, User, Event, Share, Team, Collection } from "../models"; import { Document, User, Event, Share, Team, Collection } from "../../models";
import policy from "../policies"; import policy from "../../policies";
import { presentShare, presentPolicies } from "../presenters"; import { presentShare, presentPolicies } from "../../presenters";
import pagination from "./middlewares/pagination"; import pagination from "./middlewares/pagination";
const Op = Sequelize.Op; const Op = Sequelize.Op;

View File

@ -1,9 +1,9 @@
/* eslint-disable flowtype/require-valid-file-annotation */ /* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { CollectionUser } from "../models"; import { CollectionUser } from "../../models";
import webService from "../services/web"; import webService from "../../services/web";
import { buildUser, buildDocument, buildShare } from "../test/factories"; import { buildUser, buildDocument, buildShare } from "../../test/factories";
import { flushdb, seed } from "../test/support"; import { flushdb, seed } from "../../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -1,10 +1,10 @@
// @flow // @flow
import Router from "koa-router"; import Router from "koa-router";
import auth from "../middlewares/authentication"; import auth from "../../middlewares/authentication";
import { Event, Team } from "../models"; import { Event, Team } from "../../models";
import policy from "../policies"; import policy from "../../policies";
import { presentTeam, presentPolicies } from "../presenters"; import { presentTeam, presentPolicies } from "../../presenters";
const { authorize } = policy; const { authorize } = policy;
const router = new Router(); const router = new Router();

View File

@ -1,8 +1,8 @@
/* eslint-disable flowtype/require-valid-file-annotation */ /* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server"; 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 app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -1,13 +1,13 @@
// @flow // @flow
import Router from "koa-router"; import Router from "koa-router";
import userDestroyer from "../commands/userDestroyer"; import userDestroyer from "../../commands/userDestroyer";
import userInviter from "../commands/userInviter"; import userInviter from "../../commands/userInviter";
import userSuspender from "../commands/userSuspender"; import userSuspender from "../../commands/userSuspender";
import auth from "../middlewares/authentication"; import auth from "../../middlewares/authentication";
import { Event, User, Team } from "../models"; import { Event, User, Team } from "../../models";
import policy from "../policies"; import policy from "../../policies";
import { presentUser, presentPolicies } from "../presenters"; import { presentUser, presentPolicies } from "../../presenters";
import { Op } from "../sequelize"; import { Op } from "../../sequelize";
import pagination from "./middlewares/pagination"; import pagination from "./middlewares/pagination";
const { can, authorize } = policy; const { can, authorize } = policy;

View File

@ -1,10 +1,10 @@
/* eslint-disable flowtype/require-valid-file-annotation */ /* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server"; 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 app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -2,10 +2,10 @@
import { subDays } from "date-fns"; import { subDays } from "date-fns";
import debug from "debug"; import debug from "debug";
import Router from "koa-router"; import Router from "koa-router";
import { documentPermanentDeleter } from "../commands/documentPermanentDeleter"; import { documentPermanentDeleter } from "../../commands/documentPermanentDeleter";
import { AuthenticationError } from "../errors"; import { AuthenticationError } from "../../errors";
import { Document, FileOperation } from "../models"; import { Document, FileOperation } from "../../models";
import { Op } from "../sequelize"; import { Op } from "../../sequelize";
const router = new Router(); const router = new Router();
const log = debug("utils"); const log = debug("utils");

View File

@ -1,11 +1,11 @@
/* eslint-disable flowtype/require-valid-file-annotation */ /* eslint-disable flowtype/require-valid-file-annotation */
import { subDays } from "date-fns"; import { subDays } from "date-fns";
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { Document, FileOperation } from "../models"; import { Document, FileOperation } from "../../models";
import { Op } from "../sequelize"; import { Op } from "../../sequelize";
import webService from "../services/web"; import webService from "../../services/web";
import { buildDocument, buildFileOperation } from "../test/factories"; import { buildDocument, buildFileOperation } from "../../test/factories";
import { flushdb } from "../test/support"; import { flushdb } from "../../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -1,9 +1,9 @@
// @flow // @flow
import Router from "koa-router"; import Router from "koa-router";
import auth from "../middlewares/authentication"; import auth from "../../middlewares/authentication";
import { View, Document, Event } from "../models"; import { View, Document, Event } from "../../models";
import policy from "../policies"; import policy from "../../policies";
import { presentView } from "../presenters"; import { presentView } from "../../presenters";
const { authorize } = policy; const { authorize } = policy;
const router = new Router(); const router = new Router();

View File

@ -1,9 +1,9 @@
/* eslint-disable flowtype/require-valid-file-annotation */ /* eslint-disable flowtype/require-valid-file-annotation */
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { View, CollectionUser } from "../models"; import { View, CollectionUser } from "../../models";
import webService from "../services/web"; import webService from "../../services/web";
import { buildUser } from "../test/factories"; import { buildUser } from "../../test/factories";
import { flushdb, seed } from "../test/support"; import { flushdb, seed } from "../../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -5,10 +5,10 @@ import debug from "debug";
import Koa from "koa"; import Koa from "koa";
import bodyParser from "koa-body"; import bodyParser from "koa-body";
import Router from "koa-router"; import Router from "koa-router";
import { AuthenticationError } from "../errors"; import { AuthenticationError } from "../../errors";
import auth from "../middlewares/authentication"; import auth from "../../middlewares/authentication";
import validation from "../middlewares/validation"; import validation from "../../middlewares/validation";
import { Collection, Team, View } from "../models"; import { Collection, Team, View } from "../../models";
import providers from "./providers"; import providers from "./providers";
const log = debug("server"); const log = debug("server");

View File

@ -4,11 +4,11 @@ import { Strategy as AzureStrategy } from "@outlinewiki/passport-azure-ad-oauth2
import fetch from "fetch-with-proxy"; import fetch from "fetch-with-proxy";
import jwt from "jsonwebtoken"; import jwt from "jsonwebtoken";
import Router from "koa-router"; import Router from "koa-router";
import accountProvisioner from "../../commands/accountProvisioner"; import accountProvisioner from "../../../commands/accountProvisioner";
import env from "../../env"; import env from "../../../env";
import { MicrosoftGraphError } from "../../errors"; import { MicrosoftGraphError } from "../../../errors";
import passportMiddleware from "../../middlewares/passport"; import passportMiddleware from "../../../middlewares/passport";
import { StateStore } from "../../utils/passport"; import { StateStore } from "../../../utils/passport";
const router = new Router(); const router = new Router();
const providerName = "azure"; const providerName = "azure";

View File

@ -2,16 +2,19 @@
import { subMinutes } from "date-fns"; import { subMinutes } from "date-fns";
import Router from "koa-router"; import Router from "koa-router";
import { find } from "lodash"; import { find } from "lodash";
import { parseDomain, isCustomSubdomain } from "../../../shared/utils/domains"; import {
import { AuthorizationError } from "../../errors"; parseDomain,
import mailer from "../../mailer"; isCustomSubdomain,
import errorHandling from "../../middlewares/errorHandling"; } from "../../../../shared/utils/domains";
import methodOverride from "../../middlewares/methodOverride"; import { AuthorizationError } from "../../../errors";
import validation from "../../middlewares/validation"; import mailer from "../../../mailer";
import { User, Team } from "../../models"; import errorHandling from "../../../middlewares/errorHandling";
import { signIn } from "../../utils/authentication"; import methodOverride from "../../../middlewares/methodOverride";
import { isCustomDomain } from "../../utils/domains"; import validation from "../../../middlewares/validation";
import { getUserForEmailSigninToken } from "../../utils/jwt"; import { User, Team } from "../../../models";
import { signIn } from "../../../utils/authentication";
import { isCustomDomain } from "../../../utils/domains";
import { getUserForEmailSigninToken } from "../../../utils/jwt";
const router = new Router(); const router = new Router();

View File

@ -1,14 +1,14 @@
// @flow // @flow
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import mailer from "../../mailer"; import mailer from "../../../mailer";
import webService from "../../services/web"; import webService from "../../../services/web";
import { buildUser, buildGuestUser, buildTeam } from "../../test/factories"; import { buildUser, buildGuestUser, buildTeam } from "../../../test/factories";
import { flushdb } from "../../test/support"; import { flushdb } from "../../../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());
jest.mock("../../mailer"); jest.mock("../../../mailer");
beforeEach(async () => { beforeEach(async () => {
await flushdb(); await flushdb();

View File

@ -3,15 +3,15 @@ import passport from "@outlinewiki/koa-passport";
import Router from "koa-router"; import Router from "koa-router";
import { capitalize } from "lodash"; import { capitalize } from "lodash";
import { Strategy as GoogleStrategy } from "passport-google-oauth2"; import { Strategy as GoogleStrategy } from "passport-google-oauth2";
import accountProvisioner from "../../commands/accountProvisioner"; import accountProvisioner from "../../../commands/accountProvisioner";
import env from "../../env"; import env from "../../../env";
import { import {
GoogleWorkspaceRequiredError, GoogleWorkspaceRequiredError,
GoogleWorkspaceInvalidError, GoogleWorkspaceInvalidError,
} from "../../errors"; } from "../../../errors";
import passportMiddleware from "../../middlewares/passport"; import passportMiddleware from "../../../middlewares/passport";
import { getAllowedDomains } from "../../utils/authentication"; import { getAllowedDomains } from "../../../utils/authentication";
import { StateStore } from "../../utils/passport"; import { StateStore } from "../../../utils/passport";
const router = new Router(); const router = new Router();
const providerName = "google"; const providerName = "google";

View File

@ -1,6 +1,6 @@
// @flow // @flow
import { signin } from "../../../shared/utils/routeHelpers"; import { signin } from "../../../../shared/utils/routeHelpers";
import { requireDirectory } from "../../utils/fs"; import { requireDirectory } from "../../../utils/fs";
let providers = []; let providers = [];

View File

@ -2,18 +2,18 @@
import passport from "@outlinewiki/koa-passport"; import passport from "@outlinewiki/koa-passport";
import Router from "koa-router"; import Router from "koa-router";
import { Strategy as SlackStrategy } from "passport-slack-oauth2"; import { Strategy as SlackStrategy } from "passport-slack-oauth2";
import accountProvisioner from "../../commands/accountProvisioner"; import accountProvisioner from "../../../commands/accountProvisioner";
import env from "../../env"; import env from "../../../env";
import auth from "../../middlewares/authentication"; import auth from "../../../middlewares/authentication";
import passportMiddleware from "../../middlewares/passport"; import passportMiddleware from "../../../middlewares/passport";
import { import {
IntegrationAuthentication, IntegrationAuthentication,
Collection, Collection,
Integration, Integration,
Team, Team,
} from "../../models"; } from "../../../models";
import * as Slack from "../../slack"; import * as Slack from "../../../slack";
import { StateStore } from "../../utils/passport"; import { StateStore } from "../../../utils/passport";
const router = new Router(); const router = new Router();
const providerName = "slack"; const providerName = "slack";

View File

@ -7,14 +7,14 @@ import Router from "koa-router";
import sendfile from "koa-sendfile"; import sendfile from "koa-sendfile";
import serve from "koa-static"; import serve from "koa-static";
import isUUID from "validator/lib/isUUID"; import isUUID from "validator/lib/isUUID";
import { languages } from "../shared/i18n"; import { languages } from "../../shared/i18n";
import env from "./env"; import env from "../env";
import apexRedirect from "./middlewares/apexRedirect"; import apexRedirect from "../middlewares/apexRedirect";
import Share from "./models/Share"; import Share from "../models/Share";
import presentEnv from "./presenters/env"; import presentEnv from "../presenters/env";
import { opensearchResponse } from "./utils/opensearch"; import { opensearchResponse } from "../utils/opensearch";
import prefetchTags from "./utils/prefetchTags"; import prefetchTags from "../utils/prefetchTags";
import { robotsResponse } from "./utils/robots"; import { robotsResponse } from "../utils/robots";
const isProduction = process.env.NODE_ENV === "production"; const isProduction = process.env.NODE_ENV === "production";
const isTest = process.env.NODE_ENV === "test"; const isTest = process.env.NODE_ENV === "test";
@ -24,10 +24,10 @@ const readFile = util.promisify(fs.readFile);
const readIndexFile = async (ctx) => { const readIndexFile = async (ctx) => {
if (isProduction) { if (isProduction) {
return readFile(path.join(__dirname, "../app/index.html")); return readFile(path.join(__dirname, "../../app/index.html"));
} }
if (isTest) { if (isTest) {
return readFile(path.join(__dirname, "/static/index.html")); return readFile(path.join(__dirname, "../static/index.html"));
} }
const middleware = ctx.devMiddleware; const middleware = ctx.devMiddleware;
@ -88,7 +88,7 @@ const renderShare = async (ctx, next) => {
// serve static assets // serve static assets
koa.use( koa.use(
serve(path.resolve(__dirname, "../../public"), { serve(path.resolve(__dirname, "../../../public"), {
maxage: 60 * 60 * 24 * 30 * 1000, maxage: 60 * 60 * 24 * 30 * 1000,
}) })
); );
@ -103,7 +103,10 @@ if (process.env.NODE_ENV === "production") {
"Cache-Control": `max-age=${356 * 24 * 60 * 60}`, "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( await sendfile(
ctx, ctx,
path.join(__dirname, "../shared/i18n/locales", lng, "translation.json") path.join(__dirname, "../../shared/i18n/locales", lng, "translation.json")
); );
}); });

View File

@ -1,8 +1,8 @@
// @flow // @flow
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import webService from "./services/web"; import webService from "../services/web";
import { buildShare, buildDocument } from "./test/factories"; import { buildShare, buildDocument } from "../test/factories";
import { flushdb } from "./test/support"; import { flushdb } from "../test/support";
const app = webService(); const app = webService();
const server = new TestServer(app.callback()); const server = new TestServer(app.callback());

View File

@ -9,11 +9,11 @@ import {
import mount from "koa-mount"; import mount from "koa-mount";
import onerror from "koa-onerror"; import onerror from "koa-onerror";
import enforceHttps from "koa-sslify"; import enforceHttps from "koa-sslify";
import api from "../api";
import auth from "../auth";
import emails from "../emails"; import emails from "../emails";
import env from "../env"; import env from "../env";
import routes from "../routes"; import routes from "../routes";
import api from "../routes/api";
import auth from "../routes/auth";
import Sentry from "../sentry"; import Sentry from "../sentry";
const isProduction = env.NODE_ENV === "production"; const isProduction = env.NODE_ENV === "production";