mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
27 lines
480 B
JavaScript
27 lines
480 B
JavaScript
|
'use strict';
|
||
|
|
||
|
const { Router } = require('express');
|
||
|
/**
|
||
|
* Base class for Controllers to standardize binding to express Router.
|
||
|
*/
|
||
|
class Controller {
|
||
|
constructor() {
|
||
|
const router = Router();
|
||
|
this.app = router;
|
||
|
}
|
||
|
|
||
|
get(path, handler) {
|
||
|
this.app.get(path, handler.bind(this));
|
||
|
}
|
||
|
|
||
|
post(path, handler) {
|
||
|
this.app.post(path, handler.bind(this));
|
||
|
}
|
||
|
|
||
|
router() {
|
||
|
return this.app;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = Controller;
|