Plugin architecture (#4861)
* wip * Refactor, tasks, processors, routes loading * Move Slack settings config to plugin * Fix translations in plugins * Move Slack auth to plugin * test * Move other slack-related files into plugin * Forgot to save * refactor
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import path from "path";
|
||||
import glob from "glob";
|
||||
import Koa, { BaseContext } from "koa";
|
||||
import bodyParser from "koa-body";
|
||||
import Router from "koa-router";
|
||||
import userAgent, { UserAgentContext } from "koa-useragent";
|
||||
import env from "@server/env";
|
||||
import { NotFoundError } from "@server/errors";
|
||||
import Logger from "@server/logging/Logger";
|
||||
import { AppState, AppContext } from "@server/types";
|
||||
import apiKeys from "./apiKeys";
|
||||
import attachments from "./attachments";
|
||||
@@ -16,7 +19,6 @@ import documents from "./documents";
|
||||
import events from "./events";
|
||||
import fileOperationsRoute from "./fileOperations";
|
||||
import groups from "./groups";
|
||||
import hooks from "./hooks";
|
||||
import integrations from "./integrations";
|
||||
import apiWrapper from "./middlewares/apiWrapper";
|
||||
import editor from "./middlewares/editor";
|
||||
@@ -48,6 +50,16 @@ api.use<BaseContext, UserAgentContext>(userAgent);
|
||||
api.use(apiWrapper());
|
||||
api.use(editor());
|
||||
|
||||
// register package API routes before others to allow for overrides
|
||||
glob
|
||||
.sync("build/plugins/*/server/api/!(*.test).js")
|
||||
.forEach((filePath: string) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const pkg: Router = require(path.join(process.cwd(), filePath)).default;
|
||||
router.use("/", pkg.routes());
|
||||
Logger.debug("lifecycle", `Registered API routes for ${filePath}`);
|
||||
});
|
||||
|
||||
// routes
|
||||
router.use("/", auth.routes());
|
||||
router.use("/", authenticationProviders.routes());
|
||||
@@ -58,7 +70,6 @@ router.use("/", documents.routes());
|
||||
router.use("/", pins.routes());
|
||||
router.use("/", revisions.routes());
|
||||
router.use("/", views.routes());
|
||||
router.use("/", hooks.routes());
|
||||
router.use("/", apiKeys.routes());
|
||||
router.use("/", searches.routes());
|
||||
router.use("/", shares.routes());
|
||||
|
||||
Reference in New Issue
Block a user