Make new routing system the default
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-01-19 13:24:59 -06:00
parent 8cf19792a6
commit dc16dfdb81
17 changed files with 298 additions and 535 deletions

View File

@@ -7,7 +7,8 @@ import {HTTPError} from '../HTTPError'
import {view, ViewResponseFactory} from '../response/ViewResponseFactory'
import {redirect} from '../response/RedirectResponseFactory'
import {file} from '../response/FileResponseFactory'
import {RouteHandler} from '../routing/Route'
import {ResponseObject} from '../routing/Route'
import {Logging} from '../../service/Logging'
/**
* Defines the behavior of the static server.
@@ -109,11 +110,12 @@ function getBasePath(appPath: UniversalPath, basePath?: string | string[] | Univ
* Get a route handler that serves a directory as static files.
* @param options
*/
export function staticServer(options: StaticServerOptions = {}): RouteHandler {
export function staticServer(options: StaticServerOptions = {}): (request: Request) => Promise<ResponseObject> {
return async (request: Request) => {
const config = <Config> request.make(Config)
const route = <ActivatedRoute> request.make(ActivatedRoute)
const route = <ActivatedRoute<unknown, unknown[]>> request.make(ActivatedRoute)
const app = <Application> request.make(Application)
const logging = <Logging> request.make(Logging)
const staticConfig = config.get('server.builtIns.static', {})
const mergedOptions = {
@@ -183,6 +185,7 @@ export function staticServer(options: StaticServerOptions = {}): RouteHandler {
}
// Otherwise, just send the file as the response body
logging.verbose(`Sending file: ${filePath}`)
return file(filePath)
}
}