You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
566 B
21 lines
566 B
import {Config, error, Middleware} from "@extollo/lib"
|
|
import {Inject, Injectable} from "@extollo/di"
|
|
import {HTTPStatus} from "@extollo/util"
|
|
|
|
/**
|
|
* DebugOnly Middleware
|
|
* --------------------------------------------
|
|
* Only allows the request to proceed if the app is in debug mode.
|
|
*/
|
|
@Injectable()
|
|
export class DebugOnly extends Middleware {
|
|
@Inject()
|
|
protected readonly config!: Config
|
|
|
|
public async apply() {
|
|
if ( !this.config.get('server.debug', false) ) {
|
|
return error('Not found.', HTTPStatus.NOT_FOUND)
|
|
}
|
|
}
|
|
}
|