mirror of
https://github.com/hackku21/loc-chain-backend.git
synced 2024-09-29 22:50:51 +00:00
21 lines
566 B
TypeScript
21 lines
566 B
TypeScript
|
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)
|
||
|
}
|
||
|
}
|
||
|
}
|