`我需要将 hapi.js 应用程序从 v16.4.3 迁移到 ^20.0.1。 由于 v17.0.0 进行了重大更改,包括reply()接口升级。有什么最佳的替代方法吗
return reply()
到
return reply.reponse()
在所有处理程序中?
节点版本:v16.20.2 Hapi版本:v20.0.1
//working code with version v16.4.3(Hapi)
const addFoo = {
description: 'add foo data',
notes: 'add foo data',
tags: ['api', 'FooCondition'],
validate: {
payload: {
id: joi.number().required(),
},
},
handler: (req, reply) => {
return maindb.subcategorymaster.findAll({
where: {'id': req.payload.id}
}).then((result) => {
reply(result);
}).catch((DBException) => {
reply(DBException.message);
});
}
};
// Wanted to migrate to below code without making manual change at each and every handler.
//working code with version v20.0.1(Hapi)
const addFoo = {
description: 'add foo data',
notes: 'add foo data',
tags: ['api', 'FooCondition'],
validate: {
payload: {
id: joi.number().required(),
},
},
handler: (req, reply) => {
return maindb.subcategorymaster.findAll({
where: {'id': req.payload.id}
}).then((result) => {
return reply.response(result);
}).catch((DBException) => {
return reply.response(DBException.message);
});
}
};
`