-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #862 from US-Trustee-Program/CAMS-356-functions-v4…
…-upgrade CAMS-356 functions v4 upgrade
- Loading branch information
Showing
188 changed files
with
3,489 additions
and
4,093 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 |
---|---|---|
@@ -1,43 +1,37 @@ | ||
import { AzureFunction, Context, HttpRequest } from '@azure/functions'; | ||
import { httpError, httpSuccess } from '../lib/adapters/utils/http-response'; | ||
import { AttorneysController } from '../lib/controllers/attorneys/attorneys.controller'; | ||
import ContextCreator from '../lib/adapters/utils/application-context-creator'; | ||
import * as dotenv from 'dotenv'; | ||
import { isCamsError } from '../lib/common-errors/cams-error'; | ||
import { UnknownError } from '../lib/common-errors/unknown-error'; | ||
import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions'; | ||
import { AttorneysController } from '../lib/controllers/attorneys/attorneys.controller'; | ||
import { initializeApplicationInsights } from '../azure/app-insights'; | ||
import { httpRequestToCamsHttpRequest } from '../azure/functions'; | ||
import { toAzureError, toAzureSuccess } from '../azure/functions'; | ||
import ContextCreator from '../azure/application-context-creator'; | ||
|
||
dotenv.config(); | ||
|
||
initializeApplicationInsights(); | ||
|
||
const MODULE_NAME = 'ATTORNEYS-FUNCTION'; | ||
|
||
const httpTrigger: AzureFunction = async function ( | ||
functionContext: Context, | ||
export default async function handler( | ||
request: HttpRequest, | ||
): Promise<void> { | ||
const applicationContext = await ContextCreator.applicationContextCreator( | ||
functionContext, | ||
request, | ||
); | ||
const attorneysController = new AttorneysController(applicationContext); | ||
|
||
invocationContext: InvocationContext, | ||
): Promise<HttpResponseInit> { | ||
const logger = ContextCreator.getLogger(invocationContext); | ||
try { | ||
applicationContext.session = | ||
await ContextCreator.getApplicationContextSession(applicationContext); | ||
|
||
const camsRequest = httpRequestToCamsHttpRequest(request); | ||
const attorneysList = await attorneysController.getAttorneyList(camsRequest); | ||
functionContext.res = httpSuccess(attorneysList); | ||
} catch (originalError) { | ||
const error = isCamsError(originalError) | ||
? originalError | ||
: new UnknownError(MODULE_NAME, { originalError }); | ||
applicationContext.logger.camsError(error); | ||
functionContext.res = httpError(error); | ||
const applicationContext = await ContextCreator.applicationContextCreator( | ||
invocationContext, | ||
logger, | ||
request, | ||
); | ||
const attorneysList = await AttorneysController.getAttorneyList(applicationContext); | ||
return toAzureSuccess(attorneysList); | ||
} catch (error) { | ||
return toAzureError(logger, MODULE_NAME, error); | ||
} | ||
}; | ||
} | ||
|
||
export default httpTrigger; | ||
app.http('attorneys', { | ||
methods: ['GET'], | ||
authLevel: 'anonymous', | ||
handler, | ||
route: 'attorneys/{id:int?}', | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.