mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 08:33:11 +00:00
refactor: include latest changes from core#145
This commit is contained in:
@@ -30,6 +30,7 @@ export const indexRouter = createRoute<unknown, SCIndexResponse>(
|
||||
async (): Promise<SCIndexResponse> => {
|
||||
return {
|
||||
app: configFile.app,
|
||||
auth: configFile.auth,
|
||||
backend: configFile.backend,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
} from '@openstapps/core';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {deepStrictEqual} from 'assert';
|
||||
import {isTestEnvironment, plugins} from '../common';
|
||||
import {configFile, isTestEnvironment, plugins} from '../common';
|
||||
import {createRoute} from './route';
|
||||
|
||||
/**
|
||||
@@ -76,6 +76,11 @@ function addPlugin(plugin: SCPluginMetaData): SCPluginRegisterResponse {
|
||||
}
|
||||
// it's a new plugin so it can be added to the map of plugins
|
||||
plugins.set(plugin.route, plugin);
|
||||
// add plugin info to app config
|
||||
if (typeof configFile.app.features.plugins === 'undefined') {
|
||||
configFile.app.features.plugins = {};
|
||||
}
|
||||
configFile.app.features.plugins[plugin.name] = {urlPath : plugin.route};
|
||||
Logger.log(`Registered plugin (name: ${plugin.name}, address: ${plugin.address}) on the route "${plugin.route}".`);
|
||||
|
||||
return {success: true};
|
||||
@@ -92,6 +97,10 @@ function removePlugin(route: string): SCPluginRegisterResponse {
|
||||
isTestEnvironment,
|
||||
);
|
||||
}
|
||||
if (plugins.has(route)) {
|
||||
const plugin = plugins.get(route)!;
|
||||
delete configFile.app.features.plugins?.[plugin.name];
|
||||
}
|
||||
// remove the plugin information using its route as a key
|
||||
plugins.delete(route);
|
||||
Logger.log(`Removed plugin that used the route "${route}".`);
|
||||
|
||||
@@ -47,7 +47,7 @@ export function createRoute<REQUESTTYPE, RETURNTYPE>(
|
||||
|
||||
// create route
|
||||
// the given type has no index signature so we have to cast to get the IRouteHandler when a HTTP method is given
|
||||
const route = router.route(routeClass.urlFragment);
|
||||
const route = router.route(routeClass.urlPath);
|
||||
|
||||
const verb = routeClass.method.toLowerCase();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user