yahoi
Version:
Yet Another Highly Opinionated Isomorphic Framework
50 lines (36 loc) • 6.41 kB
JavaScript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = undefined;
var _yahoi = require('yahoi');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /*
*
* Example Router
* ###################################################################
*
* Yahoi uses the following route-parser for 'path':
* https://www.npmjs.com/package/route-parser
*
*/
var DefaultRouter = function (_Router) {
_inherits(DefaultRouter, _Router);
function DefaultRouter(props) {
_classCallCheck(this, DefaultRouter);
var _this = _possibleConstructorReturn(this, (DefaultRouter.__proto__ || Object.getPrototypeOf(DefaultRouter)).call(this, props));
_this.addRoute({ path: '', controller: 'Example', action: 'Index' });
_this.addRoute({ path: '/render-string-1', controller: 'Example', action: 'RenderString1' });
_this.addRoute({ path: '/render-string-2', controller: 'Example', action: 'RenderString2' });
_this.addRoute({ path: '/render-json-1', controller: 'Example', action: 'RenderJson1' });
_this.addRoute({ path: '/render-json-2', controller: 'Example', action: 'RenderJson2' });
_this.addRoute({ path: '/render-view-1/:name', controller: 'Example', action: 'RenderView1' });
_this.addRoute({ path: '/render-view-2/:name', controller: 'Example', action: 'RenderView2' });
_this.addRoute({ path: '/redirect', controller: 'Example', action: 'Redirect' });
_this.addRoute({ path: '/client', controller: 'Example', action: 'Client' });
return _this;
}
return DefaultRouter;
}(_yahoi.Router);
exports.default = DefaultRouter;