From 358fbfcc76bf0e77320126d2478f20aeb4a42d4d Mon Sep 17 00:00:00 2001 From: Alan Bridgeman Date: Thu, 8 Jan 2026 13:45:41 -0600 Subject: [PATCH] Further work to move from CJS to ESM as well as better use of import type ... rather than generic import ... --- package.json | 2 +- src/App.ts | 2 +- src/BaseTemplateCreator.ts | 7 +++++-- src/Initializer.ts | 3 ++- src/OAuthApp.ts | 5 +++-- src/Renderer.ts | 5 +++-- src/Router.ts | 2 +- src/StaticFileResolver.ts | 3 ++- src/controllers/BaseController.ts | 2 +- src/controllers/ErrorController.ts | 2 +- src/decorators/Controller.ts | 2 +- src/decorators/DELETE.ts | 4 ++-- src/decorators/ErrorHandler.ts | 2 +- src/decorators/POST.ts | 4 ++-- src/decorators/PUT.ts | 4 ++-- src/decorators/Page.ts | 2 +- src/middlewares/GlobalTemplateValuesMiddleware.ts | 2 +- src/middlewares/HealthCheckMiddleware.ts | 2 +- yarn.lock | 8 ++++---- 19 files changed, 35 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 3026fb3..9d85e5e 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "create-ba-web-app": "node ./bin/create-project.js" }, "dependencies": { - "@BridgemanAccessible/ba-auth": "^1.0.10", + "@BridgemanAccessible/ba-auth": "^1.0.11", "@BridgemanAccessible/ba-logging": "^1.0.1", "express": "^4.19.2", "fs-extra": "^11.2.0", diff --git a/src/App.ts b/src/App.ts index 9af3c5f..2b0db1f 100644 --- a/src/App.ts +++ b/src/App.ts @@ -1,5 +1,5 @@ import 'reflect-metadata'; -import { Application } from 'express'; +import type { Application } from 'express'; import { logMessage, LogLevel } from '@BridgemanAccessible/ba-logging'; diff --git a/src/BaseTemplateCreator.ts b/src/BaseTemplateCreator.ts index 5090a1b..ab95ae2 100644 --- a/src/BaseTemplateCreator.ts +++ b/src/BaseTemplateCreator.ts @@ -1,6 +1,9 @@ import path from 'path'; import fse from 'fs-extra'; -import { JSDOM } from 'jsdom'; +import jsdom from 'jsdom'; +import type { JSDOM as JSDocument } from 'jsdom'; + +const { JSDOM } = jsdom; /** The inputs for setting up the meta tags */ type SetupMetaTagInputs = { @@ -33,7 +36,7 @@ export class BaseTemplateCreator { private output: string; /** The DOM of the template */ - private dom: JSDOM; + private dom: JSDocument; /** The document of the template */ private document: Document; diff --git a/src/Initializer.ts b/src/Initializer.ts index 3c479e3..a7cb04b 100644 --- a/src/Initializer.ts +++ b/src/Initializer.ts @@ -1,4 +1,5 @@ -import express, { Application, RequestHandler } from 'express'; +import express from 'express'; +import type { Application, RequestHandler } from 'express'; import { Router } from './Router.js'; import { StaticFileResolver } from './StaticFileResolver.js'; diff --git a/src/OAuthApp.ts b/src/OAuthApp.ts index c978a24..ca081b4 100644 --- a/src/OAuthApp.ts +++ b/src/OAuthApp.ts @@ -1,6 +1,7 @@ -import { Application } from 'express'; +import type { Application } from 'express'; import { Scopes } from '@BridgemanAccessible/ba-auth'; -import Client, { OnAuthCallback } from '@BridgemanAccessible/ba-auth/client'; +import Client from '@BridgemanAccessible/ba-auth/client'; +import type { OnAuthCallback } from '@BridgemanAccessible/ba-auth/client'; import { logMessage, LogLevel } from '@BridgemanAccessible/ba-logging'; import { App } from './App.js'; diff --git a/src/Renderer.ts b/src/Renderer.ts index 665fcab..367f6c3 100644 --- a/src/Renderer.ts +++ b/src/Renderer.ts @@ -1,8 +1,9 @@ import { existsSync, statSync } from 'fs'; import path from 'path'; -import { Application } from 'express'; +import type { Application } from 'express'; -import { BaseTemplateInputs, BaseTemplateCreator } from './BaseTemplateCreator.js'; +import { BaseTemplateCreator } from './BaseTemplateCreator.js'; +import type { BaseTemplateInputs } from './BaseTemplateCreator.js'; export class Renderer { /** The default folder name for the views */ diff --git a/src/Router.ts b/src/Router.ts index 2335fec..4ea5ad6 100644 --- a/src/Router.ts +++ b/src/Router.ts @@ -1,5 +1,5 @@ import path from 'path'; -import { Application } from 'express'; +import type { Application } from 'express'; import fse from 'fs-extra'; import { logMessage, LogLevel } from '@BridgemanAccessible/ba-logging'; diff --git a/src/StaticFileResolver.ts b/src/StaticFileResolver.ts index eef2932..322cadf 100644 --- a/src/StaticFileResolver.ts +++ b/src/StaticFileResolver.ts @@ -1,6 +1,7 @@ import { existsSync, statSync } from 'fs'; import path from 'path'; -import express, { Application } from 'express'; +import express from 'express'; +import type { Application } from 'express'; /** * A class that wraps around Express's static file serving functionality. diff --git a/src/controllers/BaseController.ts b/src/controllers/BaseController.ts index 10831d5..a716408 100644 --- a/src/controllers/BaseController.ts +++ b/src/controllers/BaseController.ts @@ -1,4 +1,4 @@ -import { Application } from 'express'; +import type { Application } from 'express'; export abstract class BaseController { static setup(app: Application) {} diff --git a/src/controllers/ErrorController.ts b/src/controllers/ErrorController.ts index 40f559b..68b778d 100644 --- a/src/controllers/ErrorController.ts +++ b/src/controllers/ErrorController.ts @@ -1,4 +1,4 @@ -import { Request, Response, NextFunction } from 'express'; +import type { Request, Response, NextFunction } from 'express'; export abstract class ErrorController { /** A human readable string to describe the error this controller handles. */ diff --git a/src/decorators/Controller.ts b/src/decorators/Controller.ts index 72597f7..12685d3 100644 --- a/src/decorators/Controller.ts +++ b/src/decorators/Controller.ts @@ -1,4 +1,4 @@ -import { Application, Request, Response, NextFunction } from 'express'; +import type { Application, Request, Response, NextFunction } from 'express'; import { BaseController } from '../controllers/BaseController.js'; diff --git a/src/decorators/DELETE.ts b/src/decorators/DELETE.ts index 4e1004e..d9c5a30 100644 --- a/src/decorators/DELETE.ts +++ b/src/decorators/DELETE.ts @@ -1,5 +1,5 @@ -import { NextFunction } from 'express'; -import { NextHandleFunction } from 'connect'; +import type { NextFunction } from 'express'; +import type { NextHandleFunction } from 'connect'; export const DELETE_METADATA_KEY = 'Delete'; diff --git a/src/decorators/ErrorHandler.ts b/src/decorators/ErrorHandler.ts index e2de45d..94b13f2 100644 --- a/src/decorators/ErrorHandler.ts +++ b/src/decorators/ErrorHandler.ts @@ -1,4 +1,4 @@ -import { Request, Response, NextFunction } from 'express'; +import type { Request, Response, NextFunction } from 'express'; import { ErrorController } from '../controllers/ErrorController.js'; diff --git a/src/decorators/POST.ts b/src/decorators/POST.ts index ec8ab95..fb8fa6a 100644 --- a/src/decorators/POST.ts +++ b/src/decorators/POST.ts @@ -1,5 +1,5 @@ -import { NextFunction } from 'express'; -import { NextHandleFunction } from 'connect'; +import type { NextFunction } from 'express'; +import type { NextHandleFunction } from 'connect'; export const POST_METADATA_KEY = 'Put'; diff --git a/src/decorators/PUT.ts b/src/decorators/PUT.ts index 0cc9370..439d7cc 100644 --- a/src/decorators/PUT.ts +++ b/src/decorators/PUT.ts @@ -1,5 +1,5 @@ -import { NextFunction } from 'express'; -import { NextHandleFunction } from 'connect'; +import type { NextFunction } from 'express'; +import type { NextHandleFunction } from 'connect'; export const PUT_METADATA_KEY = 'Put'; diff --git a/src/decorators/Page.ts b/src/decorators/Page.ts index 61714ac..aed57ad 100644 --- a/src/decorators/Page.ts +++ b/src/decorators/Page.ts @@ -1,4 +1,4 @@ -import { Request, Response, NextFunction } from 'express'; +import type { Request, Response, NextFunction } from 'express'; // Response type guard function isResponse(obj) { diff --git a/src/middlewares/GlobalTemplateValuesMiddleware.ts b/src/middlewares/GlobalTemplateValuesMiddleware.ts index 96fff97..e518f7a 100644 --- a/src/middlewares/GlobalTemplateValuesMiddleware.ts +++ b/src/middlewares/GlobalTemplateValuesMiddleware.ts @@ -1,4 +1,4 @@ -import { Request, Response, NextFunction, RequestHandler } from 'express'; +import type { Request, Response, NextFunction, RequestHandler } from 'express'; /** * Class that creates middleware to set global template values for all pages. diff --git a/src/middlewares/HealthCheckMiddleware.ts b/src/middlewares/HealthCheckMiddleware.ts index 3e82d85..7b4134e 100644 --- a/src/middlewares/HealthCheckMiddleware.ts +++ b/src/middlewares/HealthCheckMiddleware.ts @@ -1,4 +1,4 @@ -import { Request, Response, NextFunction, RequestHandler } from 'express'; +import type { Request, Response, NextFunction, RequestHandler } from 'express'; export enum HealthCheckStatus { OK = 'ok', diff --git a/yarn.lock b/yarn.lock index 3fd8306..f7fec4e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,10 @@ # yarn lockfile v1 -"@BridgemanAccessible/ba-auth@^1.0.10": - version "1.0.10" - resolved "https://npm.pkg.bridgemanaccessible.ca/@BridgemanAccessible/ba-auth/-/ba-auth-1.0.10.tgz#423b14799c8b34d22e39ac36b46f945d31ac3690" - integrity sha512-pvQ79lo+9vHL9Um4FDWnRZIX+uVkFhCeZqwYhYLb6ixNZ+RTYhmuIrcMV6VfRI6S1ozSkgIK4S6htHspExoylQ== +"@BridgemanAccessible/ba-auth@^1.0.11": + version "1.0.11" + resolved "https://npm.pkg.bridgemanaccessible.ca/@BridgemanAccessible/ba-auth/-/ba-auth-1.0.11.tgz#fd32e23bacef1985a2eac017e8aabe9a0b8a4d0d" + integrity sha512-GctJaXhWthvn6UZCq8Ymc9IQbUy1Ew9fj4XoVdh6vGDlum4H399SdM2arBkv6t8QBHyVBe1Y+LuABb8nWOoNPw== dependencies: "@BridgemanAccessible/ba-logging" "^1.0.1" "@azure/identity" "^4.0.1"