From 160c5b902c36449887c450592277afcc1e09440a Mon Sep 17 00:00:00 2001 From: meetqy Date: Thu, 16 Mar 2023 14:39:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20eagleuse=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9EAPI=20transform=E5=8F=82=E6=95=B0=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/eagleuse/lib/index.ts | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/eagleuse/lib/index.ts b/packages/eagleuse/lib/index.ts index 9da20eb9..f27d0962 100644 --- a/packages/eagleuse/lib/index.ts +++ b/packages/eagleuse/lib/index.ts @@ -2,23 +2,35 @@ import PLUGIN_API from "@eagleuse/plugin-api"; import dotenv from "dotenv-flow"; import TransformEagle from "@eagleuse/transform-eagle"; -const EagleUse = () => { +interface Args { + // 开启转换 eagle,默认 true + transform_eagle: boolean; + // 开启sqlite api访问, 默认 true + plugin_api: boolean; +} + +const EagleUse = (args: Args) => { const { LIBRARY, DATABASE_URL, NSFW = "false", PORT = 3002 } = process.env; + const { transform_eagle = true, plugin_api = true } = args; if (!LIBRARY) throw Error("LIBRARY is null!"); if (!DATABASE_URL) throw Error("DATABASE_URL is null!"); dotenv.config(); - TransformEagle({ - library: LIBRARY, - plugin_nsfw: NSFW === "true", - }); + if (transform_eagle) { + TransformEagle({ + library: LIBRARY, + plugin_nsfw: NSFW === "true", + }); + } - PLUGIN_API({ - library: LIBRARY, - port: +PORT, - }); + if (plugin_api) { + PLUGIN_API({ + library: LIBRARY, + port: +PORT, + }); + } }; export default EagleUse;