diff --git a/src/components/ServeStaticDirectoryComponent.ts b/src/components/ServeStaticDirectoryComponent.ts index ff3429c..4377d31 100644 --- a/src/components/ServeStaticDirectoryComponent.ts +++ b/src/components/ServeStaticDirectoryComponent.ts @@ -12,7 +12,7 @@ export default class ServeStaticDirectoryComponent extends ApplicationComponent< this.path = routePath; } - public async handle(router: Router): Promise { + public async init(router: Router): Promise { if (typeof this.path !== 'undefined') { router.use(this.path, express.static(this.root, {maxAge: 1000 * 3600 * 72})); } else { diff --git a/test/_app.ts b/test/_app.ts index 95c023c..d2caf87 100644 --- a/test/_app.ts +++ b/test/_app.ts @@ -15,6 +15,7 @@ import AuthGuard from "../src/auth/AuthGuard"; import MagicLink from "../src/auth/models/MagicLink"; import FormHelperComponent from "../src/components/FormHelperComponent"; import RedirectBackComponent from "../src/components/RedirectBackComponent"; +import ServeStaticDirectoryComponent from "../src/components/ServeStaticDirectoryComponent"; export default function useApp(appSupplier?: (port: number) => TestApp) { let app: Application; @@ -53,15 +54,19 @@ export class TestApp extends Application { } protected registerComponents() { + const expressAppComponent = new ExpressAppComponent(this.port); const redisComponent = new RedisComponent(); const mysqlComponent = new MysqlComponent(); - const expressAppComponent = new ExpressAppComponent(this.port); - this.use(expressAppComponent); - // Base - this.use(new NunjucksComponent('test/views')); + this.use(expressAppComponent); this.use(new LogRequestsComponent()); + + // Static files + this.use(new ServeStaticDirectoryComponent('public')); + + // Dynamic views and routes + this.use(new NunjucksComponent('test/views')); this.use(new RedirectBackComponent()); // Services