diff --git a/src/practices/config/best-practice/src/utils/config/getQueueUrlForTask.ts b/src/practices/config/best-practice/src/utils/config/getQueueUrlForTask.ts new file mode 100644 index 0000000..65e4752 --- /dev/null +++ b/src/practices/config/best-practice/src/utils/config/getQueueUrlForTask.ts @@ -0,0 +1,19 @@ +import { paramCase } from 'change-case'; +import { DomainObject } from 'domain-objects'; +import { AsyncTask } from 'simple-async-tasks'; + +import { getConfig } from './getConfig'; + +export type ClassOf = new (...args: any[]) => T; + +export const getQueueUrlForTask = async ( + task: ClassOf>, +) => { + const config = await getConfig(); + const taskName = task.name; + return [ + 'https://sqs.us-east-1.amazonaws.com', + `/${config.aws.account}/`, + `${config.project}-${config.environment.access}-${paramCase(taskName)}-llq`, + ].join(''); +};