Skip to content

Commit

Permalink
feat: 🎸 eagleuse 新增API transform参数控制
Browse files Browse the repository at this point in the history
  • Loading branch information
meetqy committed Mar 16, 2023
1 parent 67de171 commit 160c5b9
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions packages/eagleuse/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 160c5b9

Please sign in to comment.