import path from 'path' ; import * as fs from 'fs-extra' ; import { ClientOptions } from '@elastic/elasticsearch' ; export type Config = Readonly < { appKey : string ; studentKey : string ; baseUrl : string ; academicYear : string ; apiConcurrency : number ; dataPath : string ; elasticConfig ? : ClientOptions ; } > ; const env = fs . readJSONSync ( path . join ( __dirname , '../env.json' ) ) ; if ( ! env . appKey || ! env . studentKey || ! env . baseUrl ) { throw new Error ( 'env.json is not configured correctly. Please check that appKey, studentKey and baseUrl are provided' ) ; } const addTrailingSlash = ( url ) => ( url . endsWith ( '/' ) ? url : `${ url }/` ) ; const config = { appKey : env . appKey , studentKey : env . studentKey , elasticConfig : env . elasticConfig , baseUrl : addTrailingSlash ( env . baseUrl ) , apiConcurrency : env . apiConcurrency || 5 , academicYear : '2021/2022' , dataPath : path . resolve ( __dirname , '../data' ) , } ; export default config ;