Add example route-wise middleware

master
Garrett Mills 3 years ago
parent 2b2799c937
commit c31460c0cc
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246

@ -1,9 +1,10 @@
import {Config, Controllers, HTTPServer, Routing} from '@extollo/lib'
import {Config, Controllers, HTTPServer, Middlewares, Routing} from '@extollo/lib'
import {Database, Models} from "@extollo/orm";
export const Units = [
Config,
Controllers,
Middlewares,
Database,
Models,

@ -0,0 +1,8 @@
import {env} from "@extollo/lib"
import {ORMSession} from "@extollo/orm"
export default {
session: {
driver: ORMSession,
}
}

@ -0,0 +1,12 @@
import {json, Logging, Middleware} from "@extollo/lib";
import {Inject, Injectable} from "@extollo/di";
@Injectable()
export class LogRequest extends Middleware {
@Inject()
protected readonly logging!: Logging
public async apply() {
this.logging.info(`Incoming request: ${this.request.method} @ ${this.request.path}`)
}
}

@ -1,3 +1,3 @@
import {Request, Route} from "@extollo/lib"
Route.get('/', 'main:Home.welcome')
Route.get('/', 'main:Home.welcome').pre('LogRequest')

Loading…
Cancel
Save