From afdcf8b96eacb009132b738d990168f63379be08 Mon Sep 17 00:00:00 2001 From: Austin Lee Date: Sun, 4 Aug 2024 17:18:23 +0800 Subject: [PATCH] fix: fix #2649 (#2650) --- packages/server/index.js | 3 ++- packages/server/src/extend/controller.js | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/server/index.js b/packages/server/index.js index 1c7ac33d7f7..4374629316e 100644 --- a/packages/server/index.js +++ b/packages/server/index.js @@ -22,7 +22,8 @@ module.exports = function (configParams = {}) { return function (req, res) { for (const k in config) { - think.config(k, config[k]); + // fix https://github.com/walinejs/waline/issues/2649 with alias model config name + think.config(k === 'model' ? 'customModel' : k, config[k]); } return think diff --git a/packages/server/src/extend/controller.js b/packages/server/src/extend/controller.js index df0b71afa10..3d8ec9a0996 100644 --- a/packages/server/src/extend/controller.js +++ b/packages/server/src/extend/controller.js @@ -38,10 +38,10 @@ module.exports = { return nunjucks.renderString(message, variables); }, getModel(modelName) { - const { storage, model } = this.config(); + const { storage, customModel } = this.config(); - if (typeof model === 'function') { - const modelInstance = model(modelName, this); + if (typeof customModel === 'function') { + const modelInstance = customModel(modelName, this); if (modelInstance) { return modelInstance;