Attempting to resolve what I think is out of order issue
All checks were successful
Publish to Private NPM Registry / publish (push) Successful in 25s

This commit is contained in:
Alan Bridgeman 2026-05-13 15:28:11 -05:00
parent fe5b7964d7
commit b965b53668
4 changed files with 17 additions and 12 deletions

View file

@ -41,7 +41,7 @@
"dependencies": { "dependencies": {
"@BridgemanAccessible/ba-auth": "^1.0.52", "@BridgemanAccessible/ba-auth": "^1.0.52",
"@BridgemanAccessible/ba-logging": "^1.0.2", "@BridgemanAccessible/ba-logging": "^1.0.2",
"@BridgemanAccessible/ba-web-components": "^1.0.0", "@BridgemanAccessible/ba-web-components": "^1.0.1",
"express": "^4.19.2", "express": "^4.19.2",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
"jsdom": "^24.1.0", "jsdom": "^24.1.0",

View file

@ -40,13 +40,12 @@ export class App {
this.initializer = new Initializer(); this.initializer = new Initializer();
} }
await this.initializer.init();
if(includeComponentLibrary) { if(includeComponentLibrary) {
const componentsLibraryMiddleware = await useComponentsLibrary({ expressApp: this.getExpressApp() }) as RequestHandler; this.initializer.addMiddleware(async () => await useComponentsLibrary<RequestHandler>({ expressApp: this.getExpressApp() }));
this.getExpressApp().use(componentsLibraryMiddleware);
} }
await this.initializer.init();
// Start the server // Start the server
const port = process.env.PORT || this.DEFAULT_PORT; const port = process.env.PORT || this.DEFAULT_PORT;
this.getExpressApp().listen(port, async () => { this.getExpressApp().listen(port, async () => {

View file

@ -24,7 +24,7 @@ export class Initializer {
private view?: { filesPath: string, engine?: string }; private view?: { filesPath: string, engine?: string };
/** The middlewares to use */ /** The middlewares to use */
private middlewares: ((...args: any[]) => RequestHandler)[]; private middlewares: ((...args: any[]) => RequestHandler | Promise<RequestHandler>)[];
private app?: Application; private app?: Application;
private router?: Router; private router?: Router;
@ -42,7 +42,7 @@ export class Initializer {
* @param inputs.view.filesPath The path to the view files * @param inputs.view.filesPath The path to the view files
* @param middlewares Th middlewares to use * @param middlewares Th middlewares to use
*/ */
constructor(inputs?: { controllersPath?: string, staticFilesPath?: string, view?: { filesPath: string, engine?: string } }, ...middlewares: ((...args: any[]) => RequestHandler)[]) { constructor(inputs?: { controllersPath?: string, staticFilesPath?: string, view?: { filesPath: string, engine?: string } }, ...middlewares: ((...args: any[]) => RequestHandler | Promise<RequestHandler>)[]) {
this.controllersPath = typeof inputs !== 'undefined' && inputs.controllersPath !== 'undefined' ? inputs.controllersPath : undefined; this.controllersPath = typeof inputs !== 'undefined' && inputs.controllersPath !== 'undefined' ? inputs.controllersPath : undefined;
this.staticFilesPath = typeof inputs !== 'undefined' && inputs.staticFilesPath !== 'undefined' ? inputs.staticFilesPath : undefined; this.staticFilesPath = typeof inputs !== 'undefined' && inputs.staticFilesPath !== 'undefined' ? inputs.staticFilesPath : undefined;
this.view = typeof inputs !== 'undefined' && typeof inputs.view !== 'undefined' ? inputs.view : undefined; this.view = typeof inputs !== 'undefined' && typeof inputs.view !== 'undefined' ? inputs.view : undefined;
@ -66,6 +66,10 @@ export class Initializer {
return this.router; return this.router;
} }
addMiddleware(...middlewares: ((...args: any[]) => RequestHandler | Promise<RequestHandler>)[]) {
this.middlewares.push(...middlewares);
}
/** /**
* Create the Express app * Create the Express app
* *
@ -84,7 +88,9 @@ export class Initializer {
* @param app The Express app to setup the middleware on * @param app The Express app to setup the middleware on
*/ */
private async setupMiddleware(app: Application) { private async setupMiddleware(app: Application) {
this.middlewares.forEach(middleware => app.use(middleware())); for (const middleware of this.middlewares) {
app.use(await middleware());
}
} }
/** /**

View file

@ -44,10 +44,10 @@
axios "^1.8.4" axios "^1.8.4"
express "^4.21.2" express "^4.21.2"
"@BridgemanAccessible/ba-web-components@^1.0.0": "@BridgemanAccessible/ba-web-components@^1.0.1":
version "1.0.0" version "1.0.1"
resolved "https://npm.pkg.bridgemanaccessible.ca/@BridgemanAccessible/ba-web-components/-/ba-web-components-1.0.0.tgz#66d7f2ff68983bbdc2ed7d2252c232d768d6c928" resolved "https://npm.pkg.bridgemanaccessible.ca/@BridgemanAccessible/ba-web-components/-/ba-web-components-1.0.1.tgz#d6ca2ea4a77df9c790592815c39d6d805b2db40e"
integrity sha512-wJ/nEh0J+wDQsYZkZFM58D74tmsJ5AYvaqVX4V6hBBPSbPu8mmkLH2fdb2Qn6mQi8lAV1xmuc/olSg0S82tujQ== integrity sha512-KgcdCcNJ70vN2CixFJzx7jdGSoRtW4cEFpJcQrELcjrT4Uxhewwr2nmXKy1QzM4lDfo5njfRSIuDgB/HHropkQ==
dependencies: dependencies:
ejs "^5.0.2" ejs "^5.0.2"
open-props "2.0.0-beta.5" open-props "2.0.0-beta.5"