47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
const client = require("../graphql-client/graphql-client").client;
|
|
const queries = require("../graphql-client/queries");
|
|
const path = require("path");
|
|
const logger = require("../utils/logger");
|
|
|
|
require("dotenv").config({
|
|
path: path.resolve(process.cwd(), `.env.${process.env.NODE_ENV || "development"}`)
|
|
});
|
|
|
|
// Emit this to bodyshop room
|
|
|
|
exports.default = async (req, res) => {
|
|
const { useremail, bodyshopid, operationName, variables, env, time, dbevent, user } = req.body;
|
|
const { ioRedis } = req;
|
|
try {
|
|
await client.request(queries.INSERT_IOEVENT, {
|
|
event: {
|
|
operationname: operationName,
|
|
time,
|
|
dbevent,
|
|
env,
|
|
variables,
|
|
bodyshopid,
|
|
useremail
|
|
}
|
|
});
|
|
|
|
ioRedis.to(bodyshopid).emit("bodyshop-message", {
|
|
operationName,
|
|
useremail
|
|
});
|
|
|
|
res.sendStatus(200);
|
|
} catch (error) {
|
|
logger.log("ioevent-error", "trace", user, null, {
|
|
operationname: operationName,
|
|
time,
|
|
dbevent,
|
|
env,
|
|
variables,
|
|
bodyshopid,
|
|
useremail
|
|
});
|
|
res.sendStatus(200);
|
|
}
|
|
};
|