Skip to content

Commit

Permalink
fix: debug
Browse files Browse the repository at this point in the history
  • Loading branch information
wenxing-wang-ey committed Jan 15, 2025
1 parent d490dd2 commit bb59901
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions merkle-tree/src/middleware/assign-db-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,36 @@ const { admin } = config.get('mongo');
export default async function(req, res, next) {
logger.debug('src/middleware/assign-db-connection');
logger.silly(
`req.path: ${req.path}, req.query: ${JSON.stringify(req.query, null, 2)}, req.body: ${JSON.stringify(
`req.path is: ${req.path}, req.query: ${JSON.stringify(req.query, null, 2)}, req.body: ${JSON.stringify(
req.body,
null,
2,
)}`,
);
if (req.path === '/healthcheck') {
return next();
}
try {
const contractId = req.body.contractId;
let contractName = req.body.contractName || req.query.contractName;
if (contractName === undefined) {
const contractNameTest = req.body[0].contractName;
if (contractNameTest === undefined) {
throw new Error('No contractName key provided in req.body.');
} else {
contractName = contractNameTest;
}
}
const treeId = req.body.treeId || req.query.treeId;
logger.silly(`treeId: ${treeId}`);
req.user = {};
// give all requesters admin privileges:
req.user.connection = adminDbConnection;
// if (req.path === '/healthcheck') {
return next();
// }
// try {
// const contractId = req.body.contractId;
// let contractName = req.body.contractName || req.query.contractName;
// if (contractName === undefined) {
// const contractNameTest = req.body[0].contractName;
// if (contractNameTest === undefined) {
// throw new Error('No contractName key provided in req.body.');
// } else {
// contractName = contractNameTest;
// }
// }
// const treeId = req.body.treeId || req.query.treeId;
// logger.silly(`treeId: ${treeId}`);
// req.user = {};
// // give all requesters admin privileges:
// req.user.connection = adminDbConnection;

req.user.db = new DB(req.user.connection, admin, contractName, treeId, contractId);
// req.user.db = new DB(req.user.connection, admin, contractName, treeId, contractId);

return next();
} catch (err) {
return next(err);
}
// return next();
// } catch (err) {
// return next(err);
// }
}

0 comments on commit bb59901

Please sign in to comment.