import { registerAs } from '@nestjs/config';

function addLeadingSlash(url: string): string {
  if (!url) return url;
  return url[url.length - 1] === '/' ? url : `${url}/`;
}

export default registerAs('integration', () => ({
  notifierService: process.env.NOTIFIER_URL_GRPC,
  authApiHost: addLeadingSlash(process.env.AUTH_API_HOST ?? ''),
  authApiKey: process.env.AUTH_API_KEY ?? '',
}));
