-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update API controller to work with new tunnel service inter…
…face
- Loading branch information
1 parent
9b1da5d
commit 7030bac
Showing
8 changed files
with
455 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Router } from 'koa-joi-router'; | ||
import { Logger } from '../logger.js'; | ||
import KoaController from "./koa-controller.js"; | ||
|
||
class AdminController extends KoaController { | ||
|
||
public readonly _name: string = 'Admin' | ||
|
||
public appReady: boolean | undefined; | ||
|
||
constructor(opts: any) { | ||
const logger: any = Logger("admin"); | ||
|
||
super({...opts, logger}); | ||
if (!opts.enable) { | ||
logger.info({ | ||
message: `HTTP Admin disabled`, | ||
}); | ||
return; | ||
} | ||
|
||
this.appReady = undefined; | ||
} | ||
|
||
public setReady(ready: boolean) { | ||
ready ??= true; | ||
this.appReady = ready; | ||
} | ||
|
||
protected _initializeRoutes(router: Router): void { | ||
router.route({ | ||
method: 'get', | ||
path: '/ping', | ||
handler: async (ctx, next) => { | ||
ctx.status = this.appReady != undefined ? 200 : 404; | ||
}, | ||
}); | ||
|
||
router.route({ | ||
method: 'get', | ||
path: '/health', | ||
handler: async (ctx, next) => { | ||
ctx.status = this.appReady ? 200 : 404; | ||
}, | ||
}); | ||
} | ||
|
||
protected async _destroy() { | ||
this.appReady = undefined; | ||
} | ||
} | ||
|
||
export default AdminController; |
Oops, something went wrong.