Make new routing system the default
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -26,7 +26,7 @@ export class Routing extends Unit {
|
||||
@Inject()
|
||||
protected readonly bus!: EventBus
|
||||
|
||||
protected compiledRoutes: Collection<Route> = new Collection<Route>()
|
||||
protected compiledRoutes: Collection<Route<unknown, unknown[]>> = new Collection<Route<unknown, unknown[]>>()
|
||||
|
||||
public async up(): Promise<void> {
|
||||
this.app().registerFactory(new ViewEngineFactory())
|
||||
@@ -47,7 +47,7 @@ export class Routing extends Unit {
|
||||
await this.registerBuiltIns()
|
||||
|
||||
this.logging.info('Compiling routes...')
|
||||
this.compiledRoutes = new Collection<Route>(await Route.compile())
|
||||
this.compiledRoutes = new Collection<Route<unknown, unknown[]>>(await Route.compile())
|
||||
|
||||
this.logging.info(`Compiled ${this.compiledRoutes.length} route(s).`)
|
||||
this.compiledRoutes.each(route => {
|
||||
@@ -85,7 +85,7 @@ export class Routing extends Unit {
|
||||
*/
|
||||
public async recompile(): Promise<void> {
|
||||
this.logging.debug('Recompiling routes...')
|
||||
this.compiledRoutes = this.compiledRoutes.concat(new Collection<Route>(await Route.compile()))
|
||||
this.compiledRoutes = this.compiledRoutes.concat(new Collection<Route<unknown, unknown[]>>(await Route.compile()))
|
||||
|
||||
this.logging.debug(`Re-compiled ${this.compiledRoutes.length} route(s).`)
|
||||
this.compiledRoutes.each(route => {
|
||||
@@ -99,7 +99,7 @@ export class Routing extends Unit {
|
||||
* @param method
|
||||
* @param path
|
||||
*/
|
||||
public match(method: HTTPMethod, path: string): Route | undefined {
|
||||
public match(method: HTTPMethod, path: string): Route<unknown, unknown[]> | undefined {
|
||||
return this.compiledRoutes.firstWhere(route => {
|
||||
return route.match(method, path)
|
||||
})
|
||||
@@ -115,7 +115,7 @@ export class Routing extends Unit {
|
||||
/**
|
||||
* Get the collection of compiled routes.
|
||||
*/
|
||||
public getCompiled(): Collection<Route> {
|
||||
public getCompiled(): Collection<Route<unknown, unknown[]>> {
|
||||
return this.compiledRoutes
|
||||
}
|
||||
|
||||
@@ -158,9 +158,9 @@ export class Routing extends Unit {
|
||||
return Boolean(this.getByName(name))
|
||||
}
|
||||
|
||||
public getByName(name: string): Maybe<Route> {
|
||||
public getByName(name: string): Maybe<Route<unknown, unknown[]>> {
|
||||
return this.compiledRoutes
|
||||
.firstWhere(route => route.aliases.includes(name))
|
||||
.firstWhere(route => route.hasAlias(name))
|
||||
}
|
||||
|
||||
public getAppUrl(): UniversalPath {
|
||||
@@ -204,10 +204,12 @@ export class Routing extends Unit {
|
||||
const prefix = this.config.get('server.builtIns.vendor.prefix', '/vendor')
|
||||
Route.group(prefix, () => {
|
||||
Route.group(packageName, () => {
|
||||
Route.get('/**', staticServer({
|
||||
basePath,
|
||||
directoryListing: false,
|
||||
}))
|
||||
Route.get('/**')
|
||||
.passingRequest()
|
||||
.handledBy(staticServer({
|
||||
basePath,
|
||||
directoryListing: false,
|
||||
}))
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -235,10 +237,12 @@ export class Routing extends Unit {
|
||||
this.logging.debug(`Registering built-in assets server with prefix: ${prefix}`)
|
||||
await this.registerRoutes(() => {
|
||||
Route.group(prefix, () => {
|
||||
Route.get('/**', staticServer({
|
||||
directoryListing: false,
|
||||
basePath: ['resources', 'assets'],
|
||||
}))
|
||||
Route.get('/**')
|
||||
.passingRequest()
|
||||
.handledBy(staticServer({
|
||||
directoryListing: false,
|
||||
basePath: ['resources', 'assets'],
|
||||
}))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user