Answer the question
In order to leave comments, you need to log in
How to import one module and immediately export all methods from it?
The bottom line is this
There is a file, let's say module.js
module.exports = {
async method1(req, res) { // code }
method2(req, res) { // code }
}
const module = require('module')
module.exports = {
// вот здесь хочу экспортировать всё из модуля
}
const controller = require('controller')
router.get('/', controller.method1)
const { method1, method 2 } = require('module')
module.exports = {
method1,
method2
}
Answer the question
In order to leave comments, you need to log in
const m = require('module')
module.exports = {
...m,
// ...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question