35 lines
1021 B
JavaScript
35 lines
1021 B
JavaScript
const path = require("path");
|
|
require("dotenv").config({
|
|
path: path.resolve(
|
|
process.cwd(),
|
|
`.env.${process.env.NODE_ENV || "development"}`
|
|
),
|
|
});
|
|
const GraphQLClient = require("graphql-request").GraphQLClient;
|
|
const queries = require("../graphql-client/queries");
|
|
|
|
const CdkBase = require("./cdk");
|
|
|
|
exports.default = async function (socket, jobid) {
|
|
CdkBase.createLogEvent(
|
|
socket,
|
|
"DEBUG",
|
|
`Received Job export request for id ${jobid}`
|
|
);
|
|
const JobData = await QueryJobData(socket, jobid);
|
|
};
|
|
|
|
async function QueryJobData(socket, jobid) {
|
|
CdkBase.createLogEvent(socket, "DEBUG", `Querying job data for id ${jobid}`);
|
|
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {});
|
|
const result = await client
|
|
.setHeaders({ Authorization: `Bearer ${socket.handshake.auth.token}` })
|
|
.request(queries.QUERY_JOBS_FOR_CDK_EXPORT, { id: jobid });
|
|
CdkBase.createLogEvent(
|
|
socket,
|
|
"TRACE",
|
|
`Job data query result ${JSON.stringify(result)}`
|
|
);
|
|
return result;
|
|
}
|