Add mounting for activated routes, route compiling, routing

This commit is contained in:
2021-03-08 09:00:43 -06:00
parent 338b9be506
commit 3acc1bc83e
13 changed files with 314 additions and 12 deletions

View File

@@ -0,0 +1,23 @@
import {ErrorWithContext} from "@extollo/util";
import {Route} from "./Route";
export class ActivatedRoute {
public readonly params: {[key: string]: string}
constructor(
public readonly route: Route,
public readonly path: string
) {
const params = route.extract(path)
if ( !params ) {
const error = new ErrorWithContext('Cannot get params for route. Path does not match.')
error.context = {
matchedRoute: String(route),
requestPath: path,
}
throw error
}
this.params = params
}
}