sepia-search-motore-di-rice.../server/initializers/constants.ts

111 lines
3.1 KiB
TypeScript
Raw Normal View History

2022-06-03 10:54:30 +02:00
import config from 'config'
2020-02-13 11:49:03 +01:00
import { isTestInstance } from '../helpers/core-utils'
const API_VERSION = 'v1'
const CONFIG = {
LISTEN: {
PORT: config.get<number>('listen.port')
},
2020-06-05 11:19:50 +02:00
WEBSERVER: {
SCHEME: config.get<boolean>('webserver.https') === true ? 'https' : 'http',
HOSTNAME: config.get<string>('webserver.hostname'),
PORT: config.get<number>('webserver.port')
},
MEILISEARCH: {
HOST: config.get<string>('meilisearch.host'),
API_KEY: config.get<string>('meilisearch.api_key'),
2020-02-13 11:49:03 +01:00
INDEXES: {
VIDEOS: config.get<string>('meilisearch.indexes.videos'),
CHANNELS: config.get<string>('meilisearch.indexes.channels'),
PLAYLISTS: config.get<string>('meilisearch.indexes.playlists')
},
FORCE_SETTINGS_UPDATE_AT_STARTUP: config.get<boolean>('meilisearch.force_settings_update_at_startup')
2020-02-13 11:49:03 +01:00
},
LOG: {
LEVEL: config.get<string>('log.level')
},
2020-08-27 14:44:21 +02:00
SEARCH_INSTANCE: {
2020-09-02 14:07:22 +02:00
NAME: config.get<string>('search-instance.name'),
2020-09-18 16:29:32 +02:00
NAME_IMAGE: config.get<string>('search-instance.name_image'),
SEARCH_IMAGE: config.get<string>('search-instance.search_image'),
2020-09-02 14:07:22 +02:00
DESCRIPTION: config.get<string>('search-instance.description'),
2020-09-18 16:29:32 +02:00
LEGAL_NOTICES_URL: config.get<string>('search-instance.legal_notices_url'),
THEME: config.get<string>('search-instance.theme')
2020-08-27 14:44:21 +02:00
},
2020-02-14 14:09:31 +01:00
INSTANCES_INDEX: {
2020-06-11 11:04:00 +02:00
URL: config.get<string>('instances-index.url'),
2020-09-02 10:17:50 +02:00
PUBLIC_URL: config.get<string>('instances-index.public_url'),
2020-06-11 11:04:00 +02:00
WHITELIST: {
ENABLED: config.get<boolean>('instances-index.whitelist.enabled'),
HOSTS: config.get<string[]>('instances-index.whitelist.hosts')
}
2020-05-28 15:00:37 +02:00
},
2020-06-11 11:04:00 +02:00
API: {
BLACKLIST: {
ENABLED: config.get<boolean>('api.blacklist.enabled'),
HOSTS: config.get<string[]>('api.blacklist.hosts')
}
2024-01-04 16:50:17 +01:00
},
INDEXER: {
HOST_CONCURRENCY: config.get<number>('indexer.host_concurrency'),
BULK_INDEXATION_INTERVAL_MS: config.get<number>('indexer.bulk_indexation_interval_ms')
2020-02-13 11:49:03 +01:00
}
}
const SORTABLE_COLUMNS = {
VIDEOS_SEARCH: [ '_rankingScore', 'match', 'name', 'duration', 'createdAt', 'publishedAt', 'originallyPublishedAt', 'views', 'likes' ],
CHANNELS_SEARCH: [ '_rankingScore', 'match', 'displayName', 'createdAt' ],
PLAYLISTS_SEARCH: [ '_rankingScore', 'match', 'displayName', 'createdAt' ]
2020-02-13 11:49:03 +01:00
}
2021-08-02 16:16:27 +02:00
const PAGINATION_START = {
MAX: 9000
}
2021-08-02 15:54:29 +02:00
const PAGINATION_COUNT = {
DEFAULT: 20,
MAX: 500
}
2020-02-13 11:49:03 +01:00
2020-02-13 16:06:52 +01:00
const SCHEDULER_INTERVALS_MS = {
2021-06-24 16:53:43 +02:00
indexation: 60000 * 60 * 24 // 24 hours
2020-02-13 16:06:52 +01:00
}
const INDEXER_COUNT = 20
2021-06-24 15:18:54 +02:00
const INDEXER_LIMIT = 500000
2020-02-13 11:49:03 +01:00
2020-03-04 15:32:39 +01:00
const INDEXER_QUEUE_CONCURRENCY = 3
const REQUESTS = {
MAX_RETRIES: 10,
WAIT: 10000 // 10 seconds
}
2020-09-02 16:24:25 +02:00
function getWebserverUrl () {
if (CONFIG.WEBSERVER.PORT === 80 || CONFIG.WEBSERVER.PORT === 443) {
return CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME
}
return CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT
}
2020-02-13 11:49:03 +01:00
if (isTestInstance()) {
2021-06-24 16:53:43 +02:00
SCHEDULER_INTERVALS_MS.indexation = 1000 * 60 * 5 // 5 minutes
2020-02-13 11:49:03 +01:00
}
export {
2020-09-02 16:24:25 +02:00
getWebserverUrl,
2020-02-13 11:49:03 +01:00
CONFIG,
API_VERSION,
2021-08-02 15:54:29 +02:00
PAGINATION_COUNT,
2021-08-02 16:16:27 +02:00
PAGINATION_START,
2020-02-13 11:49:03 +01:00
SORTABLE_COLUMNS,
2020-03-04 15:32:39 +01:00
INDEXER_QUEUE_CONCURRENCY,
2020-02-13 16:06:52 +01:00
SCHEDULER_INTERVALS_MS,
2020-03-04 15:32:39 +01:00
INDEXER_COUNT,
2021-06-24 15:18:54 +02:00
INDEXER_LIMIT,
REQUESTS
2020-02-13 11:49:03 +01:00
}