fix function transformation

This commit is contained in:
srgooglo 2023-01-26 20:55:01 +01:00
parent 344179e5c6
commit e37684760a
2 changed files with 13 additions and 4 deletions

View File

@ -0,0 +1,9 @@
export default {
method: "get",
route: "/withoutClass",
fn: async (req, res) => {
return res.json({
message: "Im an object endpoint",
})
}
}

View File

@ -60,10 +60,8 @@ module.exports = class Controller {
this.customHandler = objEndpoint.customHandler
}
}
}
// Handle endpoint transformation as a function
if (typeof endpoint === "function") {
} else if (typeof endpoint === "function") {
// Handle endpoint transformation as a function
const endpointFn = endpoint
endpoint = class extends Endpoint {
@ -122,6 +120,8 @@ module.exports = class Controller {
return (...args) => new Promise(async (resolve, reject) => {
try {
console.log(fn)
const result = await fn(...args)
return resolve(result)