48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
const GraphQLClient = require("graphql-request").GraphQLClient;
|
|
const path = require("path");
|
|
const queries = require("../graphql-client/queries");
|
|
const Dinero = require("dinero.js");
|
|
|
|
require("dotenv").config({
|
|
path: path.resolve(
|
|
process.cwd(),
|
|
`.env.${process.env.NODE_ENV || "development"}`
|
|
),
|
|
});
|
|
|
|
exports.job = async (req, res) => {
|
|
try {
|
|
const BearerToken = req.headers.authorization;
|
|
const { jobId } = req.body;
|
|
console.log("exports.job -> jobId", jobId);
|
|
|
|
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
|
|
headers: {
|
|
Authorization: BearerToken,
|
|
},
|
|
});
|
|
|
|
const result = await client
|
|
.setHeaders({ Authorization: BearerToken })
|
|
.request(queries.QUERY_UPCOMING_APPOINTMENTS, {
|
|
now: new Date(),
|
|
});
|
|
|
|
const possibleDates = [];
|
|
|
|
//Temp
|
|
possibleDates.push(new Date());
|
|
possibleDates.push(new Date());
|
|
possibleDates.push(new Date());
|
|
possibleDates.push(new Date());
|
|
possibleDates.push(new Date());
|
|
//Get a list of upcoming appointments
|
|
//Get the config for each day
|
|
|
|
res.json(possibleDates);
|
|
} catch (error) {
|
|
console.log("error", error);
|
|
res.status(400).send(error);
|
|
}
|
|
};
|