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

65 lines
1.3 KiB
TypeScript
Raw Normal View History

2020-02-13 11:49:03 +01:00
import * as config from 'config'
import { isTestInstance } from '../helpers/core-utils'
const API_VERSION = 'v1'
const CONFIG = {
LISTEN: {
PORT: config.get<number>('listen.port')
},
ELASTIC_SEARCH: {
HOSTNAME: config.get<string>('elastic_search.hostname'),
PORT: config.get<number>('elastic_search.port'),
INDEXES: {
2020-02-19 15:39:35 +01:00
VIDEOS: config.get<string>('elastic_search.indexes.videos'),
CHANNELS: config.get<string>('elastic_search.indexes.channels')
2020-02-13 11:49:03 +01:00
}
},
LOG: {
LEVEL: config.get<string>('log.level')
},
2020-02-14 14:09:31 +01:00
INSTANCES_INDEX: {
2020-02-13 11:49:03 +01:00
URL: config.get<string>('instances-index.url')
}
}
const SORTABLE_COLUMNS = {
2020-02-19 15:39:35 +01:00
VIDEOS_SEARCH: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'match' ],
CHANNELS_SEARCH: [ 'match', 'displayName', 'createdAt' ]
2020-02-13 11:49:03 +01:00
}
const PAGINATION_COUNT_DEFAULT = 20
2020-02-13 16:06:52 +01:00
const SCHEDULER_INTERVALS_MS = {
2020-02-20 14:17:55 +01:00
videosIndexer: 60000 * 60 * 24 // 24 hours
2020-02-13 16:06:52 +01:00
}
const INDEXER_COUNT = {
2020-02-14 14:09:31 +01:00
VIDEOS: 10
2020-02-13 16:06:52 +01:00
}
2020-02-13 11:49:03 +01:00
2020-03-04 15:32:39 +01:00
const INDEXER_CONCURRENCY = 3
const INDEXER_QUEUE_CONCURRENCY = 3
const REQUESTS = {
MAX_RETRIES: 10,
WAIT: 10000 // 10 seconds
}
2020-02-13 11:49:03 +01:00
if (isTestInstance()) {
2020-03-04 15:32:39 +01:00
SCHEDULER_INTERVALS_MS.videosIndexer = 30000
2020-02-13 11:49:03 +01:00
}
export {
CONFIG,
API_VERSION,
PAGINATION_COUNT_DEFAULT,
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_CONCURRENCY,
INDEXER_COUNT,
REQUESTS
2020-02-13 11:49:03 +01:00
}