sipp
Version:
An Opinionated, High-Productivity MVC Web Framework in TypeScript
30 lines • 989 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Controller = void 0;
const Responder_1 = require("../response/Responder");
const standardize = (path) => path
.replace(/([A-Z])/g, ' $1')
.replace(/[^A-Za-z0-9]/g, ' ')
.replace(/\s{1,}/g, '-')
.replace(/^\-|[\-]$/g, '')
.toLowerCase();
class Controller extends Responder_1.HTTPResponder {
constructor() {
super(...arguments);
this.basePath = null;
}
getBasePath() {
if (this.basePath !== null) {
if (/[^\w\/-]/.test(this.basePath)) {
throw new Error(`${this.constructor.name}'s basePath contains illegal characters: ${this.basePath}.`);
}
return this.basePath.toLowerCase();
}
return standardize(this.constructor.name.replace('Controller', ''));
}
onException(e, req, res) {
return false;
}
}
exports.Controller = Controller;
//# sourceMappingURL=index.js.map