mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(api): ♻️ Move /api/v1/sso to OpenID plugin
This commit is contained in:
parent
c7ec678a3e
commit
96d1805925
12 changed files with 710 additions and 249 deletions
|
|
@ -194,10 +194,10 @@ describe("PluginLoader", () => {
|
|||
success: true,
|
||||
data: manifestContent,
|
||||
});
|
||||
mock.module("/some/path/plugin1/index.ts", () => ({
|
||||
mock.module("/some/path/plugin1/index", () => ({
|
||||
default: mockPlugin,
|
||||
}));
|
||||
mock.module("/some/path/plugin2/index.ts", () => ({
|
||||
mock.module("/some/path/plugin2/index", () => ({
|
||||
default: mockPlugin,
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -34,13 +34,13 @@ export class PluginLoader {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if a directory has an entrypoint file (index.ts).
|
||||
* Check if a directory has an entrypoint file (index.{ts,js}).
|
||||
* @param {string} dir - The directory to search.
|
||||
* @returns {Promise<boolean>} - True if the entrypoint file is found, otherwise false.
|
||||
*/
|
||||
private async hasEntrypoint(dir: string): Promise<boolean> {
|
||||
const files = await readdir(dir);
|
||||
return files.includes("index.ts");
|
||||
return files.includes("index.ts") || files.includes("index.js");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -74,7 +74,7 @@ export class PluginLoader {
|
|||
}
|
||||
|
||||
/**
|
||||
* Find all direct subdirectories with a valid manifest file and entrypoint (index.ts).
|
||||
* Find all direct subdirectories with a valid manifest file and entrypoint (index.{ts,js}).
|
||||
* @param {string} dir - The directory to search.
|
||||
* @returns {Promise<string[]>} - An array of plugin directories.
|
||||
*/
|
||||
|
|
@ -166,7 +166,7 @@ export class PluginLoader {
|
|||
const manifest = await this.parseManifest(dir, plugin);
|
||||
const pluginInstance = await this.loadPlugin(
|
||||
dir,
|
||||
`${plugin}/index.ts`,
|
||||
`${plugin}/index`,
|
||||
);
|
||||
|
||||
return { manifest, plugin: pluginInstance };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue