diff --git a/src/helper/factory/index.test.ts b/src/helper/factory/index.test.ts index aef251472..2b5de222e 100644 --- a/src/helper/factory/index.test.ts +++ b/src/helper/factory/index.test.ts @@ -273,16 +273,16 @@ describe('createApp', () => { expect(await res.text()).toBe('bar') }) - it('Should use the default options', async () => { - const app = createFactory({ defaultOptions: { strict: false } }).createApp() + it('Should use the default app options', async () => { + const app = createFactory({ defaultAppOptions: { strict: false } }).createApp() app.get('/hello', (c) => c.text('hello')) const res = await app.request('/hello/') expect(res.status).toBe(200) expect(await res.text()).toBe('hello') }) - it('Should override the default options when creating', async () => { - const app = createFactory({ defaultOptions: { strict: true } }).createApp({ strict: false }) + it('Should override the default app options when creating', async () => { + const app = createFactory({ defaultAppOptions: { strict: true } }).createApp({ strict: false }) app.get('/hello', (c) => c.text('hello')) const res = await app.request('/hello/') expect(res.status).toBe(200) diff --git a/src/helper/factory/index.ts b/src/helper/factory/index.ts index 4cf6d1448..afbad7f82 100644 --- a/src/helper/factory/index.ts +++ b/src/helper/factory/index.ts @@ -286,18 +286,18 @@ export interface CreateHandlersInterface { export class Factory { private initApp?: InitApp - #defaultOptions?: HonoOptions + #defaultAppOptions?: HonoOptions - constructor(init?: { initApp?: InitApp; defaultOptions?: HonoOptions }) { + constructor(init?: { initApp?: InitApp; defaultAppOptions?: HonoOptions }) { this.initApp = init?.initApp - this.#defaultOptions = init?.defaultOptions + this.#defaultAppOptions = init?.defaultAppOptions } createApp = (options?: HonoOptions): Hono => { const app = new Hono( - options && this.#defaultOptions - ? { ...this.#defaultOptions, ...options } - : options ?? this.#defaultOptions + options && this.#defaultAppOptions + ? { ...this.#defaultAppOptions, ...options } + : options ?? this.#defaultAppOptions ) if (this.initApp) { this.initApp(app) @@ -315,7 +315,7 @@ export class Factory { export const createFactory = (init?: { initApp?: InitApp - defaultOptions?: HonoOptions + defaultAppOptions?: HonoOptions }): Factory => new Factory(init) export const createMiddleware = <