'server only'
import Gens from "./gens";
// import Auth from "./Auth";


function getAPIEnv(){
    return {
        'schema':   process.env.API_SCHEMA,
        'host':     process.env.API_HOST,
        'port':     process.env.API_PORT,
        'basepath': process.env.API_BASEPATH
    };
}
function constructAPIUrl(endpoint:string){
    const { schema, host, port, basepath } = getAPIEnv();
    return `${schema}://${host}:${port}/${basepath}/${endpoint}`
}
function constructUrl(endpoint:string){
    const { schema, host, port, basepath } = getAPIEnv();
    return `${schema}://${host}:${port}/${endpoint}`
}
function truncateString(str:string = '', num:number = 255) {
    if (str.length > num) {
      return str.slice(0, num) + "...";
    } else {
      return str;
    }
}


export { Gens, constructAPIUrl, constructUrl, truncateString }