-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): expose util for standard queue url per async task
- Loading branch information
1 parent
ab0f1d8
commit 2b54138
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/practices/config/best-practice/src/utils/config/getQueueUrlForTask.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { paramCase } from 'change-case'; | ||
import { DomainObject } from 'domain-objects'; | ||
import type { AsyncTask } from 'simple-async-tasks'; | ||
|
||
import { getConfig } from './getConfig'; | ||
|
||
export type ClassOf<T> = new (...args: any[]) => T; | ||
|
||
export const getQueueUrlForTask = async ( | ||
task: ClassOf<DomainObject<AsyncTask>>, | ||
) => { | ||
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(''); | ||
}; |