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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user