Skip to content

Commit 5c9aff2

Browse files
committed
refactor(ts): refactor actions/autoActions into TS
1 parent 333ca27 commit 5c9aff2

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
1-
const db = require('../../db');
1+
import { authorise, reject } from '../../db';
2+
import { Action } from './Action';
23

3-
const attemptAutoApproval = async (action) => {
4+
const attemptAutoApproval = async (action: Action) => {
45
try {
56
const attestation = {
67
timestamp: new Date(),
78
autoApproved: true,
89
};
9-
await db.authorise(action.id, attestation);
10+
await authorise(action.id, attestation);
1011
console.log('Push automatically approved by system.');
1112

1213
return true;
13-
} catch (error) {
14+
} catch (error: any) {
1415
console.error('Error during auto-approval:', error.message);
1516
return false;
1617
}
1718
};
1819

19-
const attemptAutoRejection = async (action) => {
20+
const attemptAutoRejection = async (action: Action) => {
2021
try {
2122
const attestation = {
2223
timestamp: new Date(),
2324
autoApproved: true,
2425
};
25-
await db.reject(action.id, attestation);
26+
await reject(action.id, attestation);
2627
console.log('Push automatically rejected by system.');
2728

2829
return true;
29-
} catch (error) {
30+
} catch (error: any) {
3031
console.error('Error during auto-rejection:', error.message);
3132
return false;
3233
}
3334
};
3435

35-
module.exports = {
36+
export {
3637
attemptAutoApproval,
3738
attemptAutoRejection,
3839
};

0 commit comments

Comments
 (0)