1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/lib/routes/controller.js

27 lines
480 B
JavaScript
Raw Normal View History

'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;