sepia-search-motore-di-rice.../server/controllers/api/config.ts

35 lines
1.0 KiB
TypeScript
Raw Normal View History

2022-06-03 10:54:30 +02:00
import express from 'express'
2020-08-27 14:44:21 +02:00
import { ServerConfig } from '../../../shared'
import { CONFIG } from '../../initializers/constants'
2021-06-24 15:18:54 +02:00
import { IndexationScheduler } from '../../lib/schedulers/indexation-scheduler'
2020-08-27 14:44:21 +02:00
const configRouter = express.Router()
configRouter.get('/config',
2022-12-28 10:58:51 +01:00
sendConfig
2020-08-27 14:44:21 +02:00
)
2022-12-28 10:58:51 +01:00
function getConfig () {
return {
2020-08-27 14:44:21 +02:00
searchInstanceName: CONFIG.SEARCH_INSTANCE.NAME,
2020-09-18 16:29:32 +02:00
searchInstanceNameImage: CONFIG.SEARCH_INSTANCE.NAME_IMAGE,
searchInstanceSearchImage: CONFIG.SEARCH_INSTANCE.SEARCH_IMAGE,
2020-09-02 14:07:22 +02:00
legalNoticesUrl: CONFIG.SEARCH_INSTANCE.LEGAL_NOTICES_URL,
2021-06-24 15:18:54 +02:00
indexedHostsCount: IndexationScheduler.Instance.getIndexedHosts().length,
2020-09-02 10:17:50 +02:00
indexedInstancesUrl: CONFIG.INSTANCES_INDEX.PUBLIC_URL
2022-12-28 10:58:51 +01:00
} as ServerConfig
}
// ---------------------------------------------------------------------------
export {
getConfig,
configRouter
}
// ---------------------------------------------------------------------------
async function sendConfig (req: express.Request, res: express.Response) {
return res.json(getConfig())
2020-08-27 14:44:21 +02:00
}