Add query time tracking to IO Events.

This commit is contained in:
Patrick Fic
2021-04-22 10:16:49 -07:00
parent cdf99a16fe
commit 08faff4d8e
11 changed files with 112 additions and 3 deletions

29
server/ioevent/ioevent.js Normal file
View File

@@ -0,0 +1,29 @@
const client = require("../graphql-client/graphql-client").client;
const queries = require("../graphql-client/queries");
const path = require("path");
require("dotenv").config({
path: path.resolve(
process.cwd(),
`.env.${process.env.NODE_ENV || "development"}`
),
});
exports.default = async (req, res) => {
const { operationName, time, dbevent } = req.body;
try {
await client.request(queries.INSERT_IOEVENT, {
event: {
operationname: operationName,
time,
dbevent,
},
});
res.sendStatus(200);
} catch (error) {
console.log("error", error);
res.status(400).send(error);
}
};