Skip to content

Commit

Permalink
feat: home org status endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Nov 30, 2023
1 parent c9af388 commit b9a01fd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cadt",
"version": "1.7",
"version": "1.7.1",
"_comment": "DONT CHANGE MAJOR UNLESS DATAMODEL CHANGES: The major version corresponds to the datamodel version your using, so 2.0.0 means it'll use datamodel v2",
"private": true,
"bin": "build/server.js",
Expand Down
24 changes: 24 additions & 0 deletions src/controllers/organization.controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Sequelize } from 'sequelize';
import { sequelize } from '../database';
import { Organization } from '../models/organizations';
import datalayer from '../datalayer';

import {
assertHomeOrgExists,
Expand All @@ -18,6 +19,29 @@ export const findAll = async (req, res) => {
return res.json(await Organization.getOrgsMap());
};

export const homeOrgSyncStatus = async (req, res) => {
try {
await assertHomeOrgExists();
const walletSynced = await datalayer.walletIsSynced();
const homeOrg = await Organization.getHomeOrg();

return res.json({
status: {
wallet_synced: walletSynced,
home_org_synced: homeOrg?.synced ?? false,
},
message:
'After you detect that wallet is synced, your want to wait about 5 seconds and call this endpoint again to get the home org status. There is a delay between when the wallet is synced and when the proper status for home org is picked up.',
success: true,
});
} catch (error) {
res.status(400).json({
message: error.message,
success: false,
});
}
};

export const editHomeOrg = async (req, res) => {
try {
await assertIfReadOnlyMode();
Expand Down
4 changes: 4 additions & 0 deletions src/routes/v1/resources/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,8 @@ OrganizationRouter.post('/metadata', (req, res) => {
return OrganizationController.addMetadata(req, res);
});

OrganizationRouter.get('/status', (req, res) => {
return OrganizationController.homeOrgSyncStatus(req, res);
});

export { OrganizationRouter };

0 comments on commit b9a01fd

Please sign in to comment.