Major clean up and alpha.1 release.
This commit is contained in:
@@ -12,6 +12,7 @@ stages:
|
||||
domain: es.imex.online
|
||||
es_user: Imex2
|
||||
es_password: Patrick
|
||||
hasura_url: https://es.db.imex.online/v1/graphql
|
||||
beta:
|
||||
# Enables observability in the prod stage
|
||||
observability: false
|
||||
@@ -22,6 +23,7 @@ stages:
|
||||
domain: beta.es.imex.online
|
||||
es_user: Imex2
|
||||
es_password: Patrick
|
||||
hasura_url: https://es.db.imex.online/v1/graphql
|
||||
alpha:
|
||||
# Enables observability in the prod stage
|
||||
observability: false
|
||||
@@ -31,6 +33,7 @@ stages:
|
||||
domain: alpha.es.imex.online
|
||||
es_user: Imex2
|
||||
es_password: Patrick
|
||||
hasura_url: https://es.db.imex.online/v1/graphql
|
||||
dev:
|
||||
# Enables observability in the prod stage
|
||||
observability: false
|
||||
@@ -40,6 +43,7 @@ stages:
|
||||
domain: dev.es.imex.online
|
||||
es_user: Imex2
|
||||
es_password: Patrick
|
||||
hasura_url: https://es.db.imex.online/v1/graphql
|
||||
|
||||
# params:
|
||||
# dev:
|
||||
@@ -82,6 +86,10 @@ functions:
|
||||
ES_ENDPOINT: ${param:es_endpoint}
|
||||
ES_USER: ${param:es_user}
|
||||
ES_PASSWORD: ${param:es_password}
|
||||
HASURA_URL: ${param:hasura_url}
|
||||
# Resolve at deploy-time from AWS Secrets Manager (value is not stored in this file).
|
||||
# This secret is expected to be JSON; we pull the `admin_secret` field.
|
||||
HASURA_SECRET: '{{resolve:secretsmanager:arn:aws:secretsmanager:ca-central-1:714144183158:secret:esdp-hasura-credentials-s81i1u-BDFgPi:SecretString:admin_secret::}}'
|
||||
events:
|
||||
- httpApi:
|
||||
path: /scrub
|
||||
|
||||
@@ -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