Serve static files extra early to avoid useless middlewares execution
This commit is contained in:
parent
272688da26
commit
31f974c0a6
@ -12,7 +12,7 @@ export default class ServeStaticDirectoryComponent extends ApplicationComponent<
|
||||
this.path = routePath;
|
||||
}
|
||||
|
||||
public async handle(router: Router): Promise<void> {
|
||||
public async init(router: Router): Promise<void> {
|
||||
if (typeof this.path !== 'undefined') {
|
||||
router.use(this.path, express.static(this.root, {maxAge: 1000 * 3600 * 72}));
|
||||
} else {
|
||||
|
13
test/_app.ts
13
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
|
||||
|
Loading…
Reference in New Issue
Block a user