forked from bcgov/supreme-court-viewer
-
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.
Added lookupService and catsAPI service to further wrap bc gov apis
- Loading branch information
Ronaldo Macapobre
committed
Jan 3, 2025
1 parent
9d7b323
commit ebc547a
Showing
3 changed files
with
45 additions
and
12 deletions.
There are no files selected for viewing
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
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
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,35 @@ | ||
import { IHttpService } from "./httpService"; | ||
import SecretsManagerService from "./secretsManagerService"; | ||
|
||
export class LookupService { | ||
constructor( | ||
private httpService: IHttpService, | ||
private smService: SecretsManagerService | ||
) {} | ||
|
||
async init() { | ||
console.log( | ||
`Retrieving credentials for ${process.env.FILE_SERVICES_CLIENT_SECRET_NAME}.` | ||
); | ||
|
||
const secretStringJson = await this.smService.getSecret( | ||
process.env.FILE_SERVICES_CLIENT_SECRET_NAME! | ||
); | ||
|
||
console.log(`Credentials retrieved: ${secretStringJson}`); | ||
|
||
console.log(`Initializing httpService`); | ||
|
||
const { baseUrl, username, password } = JSON.parse(secretStringJson); | ||
|
||
await this.httpService.init(baseUrl, username, password); | ||
|
||
console.log("httpService initialized."); | ||
} | ||
|
||
async get(url: string, queryParams?: Record<string, unknown>) { | ||
console.log(`Sending GET request for ${url}...`); | ||
|
||
return await this.httpService.get(url, queryParams); | ||
} | ||
} |