Add support for view engines, PNPM

This commit is contained in:
2021-03-08 18:07:55 -06:00
parent 4ecada6be8
commit b820b35b70
12 changed files with 814 additions and 3 deletions

View File

@@ -6,4 +6,12 @@ export class Config extends CanonicalRecursive {
protected appPath: string[] = ['configs']
protected suffix: string = '.config.js'
protected canonicalItem: string = 'config'
public async up() {
await super.up()
if ( this.get('server.debug', false) ) {
Error.stackTraceLimit = Infinity
}
}
}

View File

@@ -11,6 +11,7 @@ import {InjectSessionHTTPModule} from "../http/kernel/module/InjectSessionHTTPMo
import {PersistSessionHTTPModule} from "../http/kernel/module/PersistSessionHTTPModule";
import {MountActivatedRouteHTTPModule} from "../http/kernel/module/MountActivatedRouteHTTPModule";
import {ExecuteResolvedRouteHandlerHTTPModule} from "../http/kernel/module/ExecuteResolvedRouteHandlerHTTPModule";
import {error} from "../http/response/ErrorResponseFactory";
@Singleton()
export class HTTPServer extends Unit {
@@ -76,7 +77,12 @@ export class HTTPServer extends Unit {
.run()
.catch(e => this.logging.error(e))
await this.kernel.handle(extolloReq)
try {
await this.kernel.handle(extolloReq)
} catch (e) {
await error(e).write(extolloReq)
}
await extolloReq.response.send()
}
}

View File

@@ -4,6 +4,7 @@ import {Unit} from "../lifecycle/Unit"
import {Logging} from "./Logging"
import {Route} from "../http/routing/Route";
import {HTTPMethod} from "../http/lifecycle/Request";
import {ViewEngineFactory} from "../views/ViewEngineFactory";
@Singleton()
export class Routing extends Unit {
@@ -13,6 +14,8 @@ export class Routing extends Unit {
protected compiledRoutes: Collection<Route> = new Collection<Route>()
public async up() {
this.app().registerFactory(new ViewEngineFactory());
for await ( const entry of this.path.walk() ) {
if ( !entry.endsWith('.routes.js') ) {
this.logging.debug(`Skipping routes file with invalid suffix: ${entry}`)