|
|
@ -10,15 +10,15 @@ import ServeStaticDirectoryComponent from "swaf/components/ServeStaticDirectoryC |
|
|
|
import MaintenanceComponent from "swaf/components/MaintenanceComponent"; |
|
|
|
import MailComponent from "swaf/components/MailComponent"; |
|
|
|
import SessionComponent from "swaf/components/SessionComponent"; |
|
|
|
import RedirectBackComponent from "swaf/components/RedirectBackComponent"; |
|
|
|
import FormHelperComponent from "swaf/components/FormHelperComponent"; |
|
|
|
import CsrfProtectionComponent from "swaf/components/CsrfProtectionComponent"; |
|
|
|
import WebSocketServerComponent from "swaf/components/WebSocketServerComponent"; |
|
|
|
import HomeController from "./controllers/HomeController"; |
|
|
|
import AutoUpdateComponent from "swaf/components/AutoUpdateComponent"; |
|
|
|
import packageJson = require('../package.json'); |
|
|
|
import DummyMigration from "swaf/migrations/DummyMigration"; |
|
|
|
import DropLegacyLogsTable from "swaf/migrations/DropLegacyLogsTable"; |
|
|
|
import PreviousUrlComponent from "swaf/components/PreviousUrlComponent"; |
|
|
|
import packageJson = require('./package.json'); |
|
|
|
|
|
|
|
export default class App extends Application { |
|
|
|
public constructor( |
|
|
@ -43,41 +43,40 @@ export default class App extends Application { |
|
|
|
} |
|
|
|
|
|
|
|
private registerComponents() { |
|
|
|
const redisComponent = new RedisComponent(); |
|
|
|
const mysqlComponent = new MysqlComponent(); |
|
|
|
|
|
|
|
const expressAppComponent = new ExpressAppComponent(this.addr, this.port); |
|
|
|
this.use(expressAppComponent); |
|
|
|
this.use(new NunjucksComponent()); |
|
|
|
// Base
|
|
|
|
this.use(new ExpressAppComponent(this.addr, this.port)); |
|
|
|
this.use(new LogRequestsComponent()); |
|
|
|
|
|
|
|
// Static files
|
|
|
|
this.use(new ServeStaticDirectoryComponent('public')); |
|
|
|
this.use(new ServeStaticDirectoryComponent('node_modules/feather-icons/dist', '/icons')); |
|
|
|
|
|
|
|
// Dynamic views and routes
|
|
|
|
this.use(new NunjucksComponent()); |
|
|
|
this.use(new PreviousUrlComponent()); |
|
|
|
|
|
|
|
// Maintenance
|
|
|
|
this.use(new MaintenanceComponent(this, () => { |
|
|
|
return redisComponent.canServe() && mysqlComponent.canServe(); |
|
|
|
return this.as(RedisComponent).canServe() && this.as(MysqlComponent).canServe(); |
|
|
|
})); |
|
|
|
this.use(new AutoUpdateComponent()); |
|
|
|
|
|
|
|
// Services
|
|
|
|
this.use(mysqlComponent); |
|
|
|
this.use(new MysqlComponent()); |
|
|
|
this.use(new MailComponent()); |
|
|
|
|
|
|
|
// Session
|
|
|
|
this.use(redisComponent); |
|
|
|
this.use(new SessionComponent(redisComponent)); |
|
|
|
this.use(new RedisComponent()); |
|
|
|
this.use(new SessionComponent(this.as(RedisComponent))); |
|
|
|
|
|
|
|
// Utils
|
|
|
|
this.use(new RedirectBackComponent()); |
|
|
|
this.use(new FormHelperComponent()); |
|
|
|
|
|
|
|
// Middlewares
|
|
|
|
this.use(new CsrfProtectionComponent()); |
|
|
|
|
|
|
|
// WebSocket server
|
|
|
|
this.use(new WebSocketServerComponent(this, expressAppComponent, redisComponent)); |
|
|
|
this.use(new WebSocketServerComponent(this, this.as(ExpressAppComponent), this.as(RedisComponent))); |
|
|
|
} |
|
|
|
|
|
|
|
private registerWebSocketListeners() { |
|
|
|