Skip to content

Commit

Permalink
feat: governance getters
Browse files Browse the repository at this point in the history
  • Loading branch information
frantzarty committed Apr 21, 2022
1 parent bb6e2e2 commit 4c63081
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/controllers/governance.controller.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import _ from 'lodash';

import { Governance } from '../models';

import {
Expand All @@ -21,6 +23,32 @@ export const findAll = async (req, res) => {
}
};

export const findOrgList = async (req, res) => {
try {
const results = await Governance.findOne({ where: { metaKey: 'orgList' } });
return res.json(JSON.parse(_.get(results, 'metaValue', {})));
} catch (error) {
res.status(400).json({
message: 'Can not retreive Governance Data',
error: error.message,
});
}
};

export const findPickList = async (req, res) => {
try {
const results = await Governance.findOne({
where: { metaKey: 'pickList' },
});
return res.json(JSON.parse(_.get(results, 'metaValue', {})));
} catch (error) {
res.status(400).json({
message: 'Can not retreive Governance Data',
error: error.message,
});
}
};

// eslint-disable-next-line
export const createGoveranceBody = async (req, res) => {
try {
Expand Down
8 changes: 8 additions & 0 deletions src/routes/v1/resources/governance.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ GovernanceRouter.get('/', (req, res) => {
return GovernanceController.findAll(req, res);
});

GovernanceRouter.get('/meta/orgList', (req, res) => {
return GovernanceController.findOrgList(req, res);
});

GovernanceRouter.get('/meta/pickList', (req, res) => {
return GovernanceController.findPickList(req, res);
});

GovernanceRouter.post('/', (req, res) => {
return GovernanceController.createGoveranceBody(req, res);
});
Expand Down

0 comments on commit 4c63081

Please sign in to comment.