authelia/test/helpers/context/AutheliaServer.ts

26 lines
709 B
TypeScript

import fs from 'fs';
import AutheliaServerWithHotReload from "./AutheliaServerWithHotReload";
import AutheliaServerInterface from './AutheliaServerInterface';
import AutheliaServerFromDist from './AutheliaServerFromDist';
class AutheliaServer implements AutheliaServerInterface {
private runnerImpl: AutheliaServerInterface;
constructor(configPath: string) {
if (fs.existsSync('.suite')) {
this.runnerImpl = new AutheliaServerWithHotReload(configPath);
} else {
this.runnerImpl = new AutheliaServerFromDist(configPath, true);
}
}
async start() {
await this.runnerImpl.start();
}
async stop() {
await this.runnerImpl.stop();
}
}
export default AutheliaServer;