mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
(cherry picked from commit 301c440a58a6f8d26408e46cc6ff568315f5f49f)
This commit is contained in:
parent
0424a1daa4
commit
a27bf1562f
@ -14,42 +14,49 @@
|
||||
* limitations under the License. *
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
const { readdirSync } = require('fs-extra')
|
||||
const { resolve } = require('path')
|
||||
const { messageTerminal } = require('server/utils/general')
|
||||
const { getRouteForOpennebulaCommand } = require('server/utils/opennebula')
|
||||
const { defaultConfigErrorMessage } = require('server/utils/constants/defaults')
|
||||
|
||||
const routes = [
|
||||
'2fa',
|
||||
'auth',
|
||||
'files',
|
||||
'marketapp',
|
||||
'oneflow',
|
||||
'vcenter',
|
||||
'vm',
|
||||
'zendesk',
|
||||
'oneprovision',
|
||||
'sunstone',
|
||||
]
|
||||
|
||||
const filesDataPrivate = []
|
||||
const filesDataPublic = []
|
||||
|
||||
readdirSync(resolve(__dirname), { withFileTypes: true })
|
||||
.filter((dirent) => dirent.isDirectory())
|
||||
.forEach((file) => {
|
||||
try {
|
||||
const { name } = file
|
||||
// eslint-disable-next-line global-require
|
||||
const fileInfo = require(`./${name}`)
|
||||
routes.forEach((file) => {
|
||||
try {
|
||||
// eslint-disable-next-line global-require
|
||||
const fileInfo = require(`./${file}`)
|
||||
|
||||
if (fileInfo.private && fileInfo.private.length) {
|
||||
filesDataPrivate.push(...fileInfo.private)
|
||||
}
|
||||
if (fileInfo.public && fileInfo.public.length) {
|
||||
filesDataPublic.push(...fileInfo.public)
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.code === 'MODULE_NOT_FOUND') {
|
||||
const config = defaultConfigErrorMessage
|
||||
config.error = error.message
|
||||
messageTerminal(config)
|
||||
}
|
||||
if (fileInfo.private && fileInfo.private.length) {
|
||||
filesDataPrivate.push(...fileInfo.private)
|
||||
}
|
||||
})
|
||||
if (fileInfo.public && fileInfo.public.length) {
|
||||
filesDataPublic.push(...fileInfo.public)
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.code === 'MODULE_NOT_FOUND') {
|
||||
const config = defaultConfigErrorMessage
|
||||
config.error = error.message
|
||||
messageTerminal(config)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const opennebulaActions = getRouteForOpennebulaCommand()
|
||||
const routes = {
|
||||
|
||||
module.exports = {
|
||||
private: [...opennebulaActions, ...filesDataPrivate],
|
||||
public: [...filesDataPublic],
|
||||
}
|
||||
|
||||
module.exports = routes
|
||||
|
Loading…
x
Reference in New Issue
Block a user