Skip to content

Commit

Permalink
feat: api to check if there are pending transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Oct 18, 2022
1 parent 5fdea5b commit 4787ef3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/controllers/staging.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ import {
assertStagingTableNotEmpty,
} from '../utils/data-assertions';

export const hasPendingTransactions = async (req, res) => {
try {
await assertNoPendingCommits();
res.json({
confirmed: true,
message: 'There are no pending transactions',
});
} catch (error) {
res.json({
confirmed: false,
message: 'There are currently pending transactions',
});
}
};

export const findAll = async (req, res) => {
try {
let { page, limit, type, table } = req.query;
Expand Down
4 changes: 4 additions & 0 deletions src/routes/v1/resources/staging.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ StagingRouter.post(
// Empty entire stagin table
StagingRouter.delete('/clean', StagingController.clean);

StagingRouter.get('/hasPendingTransactions', (req, res) => {
return StagingController.hasPendingTransactions(req, res);
});

export { StagingRouter };

0 comments on commit 4787ef3

Please sign in to comment.