2021-10-05 10:18:16 +02:00

19 lines
481 B
JavaScript
Executable File

class Controller {
constructor(payload) {
this.payload = {...payload}
return this
}
exec = async (req, res, next) => {
if (typeof this.payload.exec === "function") {
try {
await this.payload.exec (req, res, next)
} catch (error) {
return res.status(500).json({ error: error.message, endpoint: this.payload.route })
}
}
}
}
module.exports = { Controller }