chore: added in the router things:
Co-authored-by: Johan Haals <johan.haals@gmail.com> Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -30,18 +30,18 @@ export const httpRouterFactory = createServiceFactory({
|
||||
},
|
||||
factory: async ({ configFactory }) => {
|
||||
const rootRouter = Router();
|
||||
|
||||
const service = createServiceBuilder(module)
|
||||
.loadConfig(await configFactory('root'))
|
||||
.addRouter('', rootRouter);
|
||||
|
||||
await service.start();
|
||||
|
||||
return async (pluginId?: string) => {
|
||||
if (!pluginId) {
|
||||
return rootRouter;
|
||||
}
|
||||
const path = pluginId ? `/api/${pluginId}` : '';
|
||||
return {
|
||||
use(handler: Handler) {
|
||||
rootRouter.use(`/api/${pluginId}`, handler);
|
||||
rootRouter.use(path, handler);
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -79,6 +79,6 @@ export function createServiceFactory<
|
||||
Api,
|
||||
Impl extends Api,
|
||||
Deps extends { [name in string]: unknown },
|
||||
>(factory: ServiceFactory<Api, Impl, Deps>): ServiceFactory<Api, Impl, Deps> {
|
||||
>(factory: ServiceFactory<Api, Impl, Deps>): ServiceFactory<Api, Api, {}> {
|
||||
return factory;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,30 @@ import {
|
||||
// },
|
||||
// });
|
||||
|
||||
// export const appPlugin = createBackendPlugin({
|
||||
// id: 'app',
|
||||
// register(env) {
|
||||
// env.registerInit({
|
||||
// deps: {
|
||||
// httpRouter: httpRouterServiceRef,
|
||||
// database: databaseServiceRef,
|
||||
// logger: loggerServiceRef,
|
||||
// config: configServiceRef,
|
||||
// },
|
||||
// async init({ httpRouter, config, logger, database }) {
|
||||
// console.log('App plugin init');
|
||||
|
||||
// const appBackendRoute = await createAppBackendRouter({
|
||||
// appPackageName: 'example-app',
|
||||
// config,
|
||||
// logger: loggerToWinstonLogger(logger),
|
||||
// database,
|
||||
// });
|
||||
// },
|
||||
// });
|
||||
// },
|
||||
// });
|
||||
|
||||
const backend = createBackend({
|
||||
apis: [],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user