Major clean up and alpha.1 release.
This commit is contained in:
@@ -10,8 +10,8 @@ import { UUID } from 'node:crypto';
|
||||
const ES_USER = process.env.ES_USER || '';
|
||||
const ES_PASSWORD = process.env.ES_PASSWORD || '';
|
||||
const ES_ENDPOINT = process.env.ES_ENDPOINT || '';
|
||||
const HASURA_URL = process.env.HASURA_URL || '';
|
||||
|
||||
const HASURA_URL = process.env.HASURA_URL || 'https://db.es.imex.online/v1/graphql';
|
||||
const HASURA_SECRET = process.env.HASURA_SECRET || '';
|
||||
interface ScrubRequest {
|
||||
esApiKey: string;
|
||||
rawJob: RawJobDataObject;
|
||||
@@ -29,7 +29,19 @@ export const handler = async (event: APIGatewayProxyEvent): Promise<APIGatewayPr
|
||||
rawJob,
|
||||
} = JSON.parse(event.body || '{}') as ScrubRequest;
|
||||
const esApiKey = event.headers['x-api-key'] || '';
|
||||
//await uploadJobToHasura(rawJob, esApiKey);
|
||||
|
||||
if (!esApiKey) {
|
||||
return {
|
||||
statusCode: 401,
|
||||
body: JSON.stringify({
|
||||
message: 'Access invalid.',
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
uploadJobToHasura(rawJob, esApiKey).catch((error) => {
|
||||
console.error('Failed to upload job to Hasura:', error);
|
||||
});
|
||||
// Transform the raw job object to ES format
|
||||
const estimate: ESJobObject = await transformJobForEstimateScrubber(rawJob);
|
||||
|
||||
@@ -56,14 +68,14 @@ export const handler = async (event: APIGatewayProxyEvent): Promise<APIGatewayPr
|
||||
},
|
||||
});
|
||||
|
||||
const resultPDFUrl = result?.data?.report_link;
|
||||
const reportIssueUrl = `https://insurtechtoolkit.com/pcontactUs.aspx?apiKey=${esApiKey}&file=${fileName}.json`;
|
||||
const pdf_url = result?.data?.report_link;
|
||||
const report_issue_url = `https://insurtechtoolkit.com/pcontactUs.aspx?apiKey=${esApiKey}&file=${fileName}.json`;
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
body: JSON.stringify({
|
||||
resultPDFUrl,
|
||||
reportIssueUrl,
|
||||
pdf_url,
|
||||
report_issue_url,
|
||||
identified_item: result.data?.identified_item,
|
||||
}),
|
||||
};
|
||||
@@ -83,7 +95,7 @@ export const handler = async (event: APIGatewayProxyEvent): Promise<APIGatewayPr
|
||||
const uploadJobToHasura = async (rawJob: RawJobDataObject, esApiKey: string): Promise<void> => {
|
||||
const graphQLClient = new GraphQLClient(HASURA_URL, {
|
||||
headers: {
|
||||
'x-hasura-admin-secret': 'UXWqeUlNMc2dd2SD7DTOKgjEQlVkZkaW',
|
||||
'x-hasura-admin-secret': HASURA_SECRET,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user