1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/lib/routes/controller.js

39 lines
717 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));
}
put(path, handler) {
this.app.put(path, handler.bind(this));
}
delete(path, handler) {
this.app.delete(path, handler.bind(this));
}
use(path, router) {
this.app.use(path, router);
}
get router() {
return this.app;
}
}
module.exports = Controller;