diff --git a/lib/service/PiService.ts b/lib/service/PiService.ts index bf0cd79..22f39e0 100644 --- a/lib/service/PiService.ts +++ b/lib/service/PiService.ts @@ -1,11 +1,11 @@ import { Request, Response, Router, IRouterMatcher, Application } from "express"; -import { PiDbPoolFactoryFn, PiServiceOptions, PiExceptionHandlerParams } from "./types"; +import { PiServiceOptions, PiExceptionHandlerParams } from "./types"; import { PiTypeDescriptor } from '@pomgui/rest-lib'; import { PiDatabasePool, PiDatabase } from '@pomgui/database'; var _router: Router = Router(), - _dbPool: PiDatabasePool | null; + _dbPool: PiDatabasePool | undefined; export function PiGET(path: string, options?: PiServiceOptions) { return decorator(path, _router.get, options) } export function PiPOST(path: string, options?: PiServiceOptions) { return decorator(path, _router.post, options) } @@ -77,9 +77,8 @@ function decorator(path: string, defineRoute: IRouterMatcher, options?: Pi } } -export function PiService(config: { services: { new(): any }[], dbPoolFactoryFn?: PiDbPoolFactoryFn }): Router { - config.services.forEach(s => new s()); // Create an instance, just to access to the decorators - if (config.dbPoolFactoryFn) - _dbPool = config.dbPoolFactoryFn(); +export function PiService(config: { servicesList: { new(): any }[], dbPool?: PiDatabasePool }): Router { + config.servicesList.forEach(s => new s()); // Create an instance, just to access to the decorators + _dbPool = config.dbPool; return _router; } diff --git a/lib/service/types.ts b/lib/service/types.ts index 0d78534..5afd4d8 100644 --- a/lib/service/types.ts +++ b/lib/service/types.ts @@ -2,11 +2,6 @@ import { PiDatabase, PiDatabasePool } from "@pomgui/database" import { Request, Response } from "express" import { PiDescriptor } from '@pomgui/rest-lib' -/** - * Signature of the database factory function - */ -export type PiDbPoolFactoryFn = { (): PiDatabasePool | null; } - export type PiServiceOptions = { customSend?: boolean; database?: boolean;