Route parser
It a simple route parser accepting a list of YML files and return a list of resolved routes like :
home: pattern: '/home' post: controller: 'ControllerMock:add' middlewares: [ controller: 'Auth:isAuth' ]
And creates a new instance of :
/** * The route definition class */ /** * Create a new route * @param * @param * @param * @param * @param */ { /** * The pattern URL * @type */ thispattern = pattern /** * The HTTP method * @type */ thismethod = method /** * The controller object * @type */ thiscontroller = controller /** * The controller method * @type */ thiscontrollerMethod = controllerMethod /** * The middleware list to start before the route is resolved * @type */ thismiddlewares = middlewares }
Usage
You can simply call this :
/** * Create a new route parser */const routeParser = /** * Get a list of YML files to parse * Returns the route parsed with the above model */const routes = routeParser