From e0dc2a014ede8d20f21a6ef485ae080084949620 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 7 Jul 2024 23:15:31 +0800 Subject: [PATCH] fix: change keys to getter and setter --- src/application.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/application.ts b/src/application.ts index 6c67c197b..d069bdb9b 100644 --- a/src/application.ts +++ b/src/application.ts @@ -40,7 +40,7 @@ export class Application extends Emitter { subdomainOffset: number; proxyIpHeader: string; maxIpsCount: number; - keys?: string[]; + protected _keys?: string[]; middleware: MiddlewareFunc[]; ctxStorage: AsyncLocalStorage; silent: boolean; @@ -78,7 +78,9 @@ export class Application extends Emitter { this.proxyIpHeader = options.proxyIpHeader || 'X-Forwarded-For'; this.maxIpsCount = options.maxIpsCount || 0; this._env = options.env || process.env.NODE_ENV || 'development'; - if (options.keys) this.keys = options.keys; + if (options.keys) { + this._keys = options.keys; + } this.middleware = []; this.ctxStorage = getAsyncLocalStorage(); this.silent = false; @@ -90,6 +92,14 @@ export class Application extends Emitter { this.response = this.ResponseClass.prototype; } + get keys() { + return this._keys; + } + + set keys(value: string[] | undefined) { + this._keys = value; + } + get env() { return this._env; }