Skip to content

Commit

Permalink
feat: upload svg icon
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Mar 7, 2022
1 parent 4ac7995 commit 99b2262
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/controllers/organization.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,51 @@ import {
assertHomeOrgExists,
assertWalletIsSynced,
assertDataLayerAvailable,
assertWalletIsAvailable,
assertIfReadOnlyMode,
} from '../utils/data-assertions';

export const findAll = async (req, res) => {
return res.json(await Organization.getOrgsMap());
};

export const createV2 = async (req, res) => {
try {
await assertIfReadOnlyMode();
await assertDataLayerAvailable();
await assertWalletIsAvailable();
await assertWalletIsSynced();

const myOrganization = await Organization.getHomeOrg();

if (!myOrganization) {
return res.json({
message: 'Your organization already exists.',
orgId: myOrganization.orgUid,
});
} else {
const { name } = req.body;
const buffer = req.files.svg.data;
const svgIcon = buffer.toString('utf8');

return res.json({
message: 'New organization created successfully.',
orgId: await Organization.createHomeOrganization(name, svgIcon, 'v1'),
});
}
} catch (error) {
res.status(400).json({
message: 'Error initiating your organization',
error: error.message,
});
}
};

export const create = async (req, res) => {
try {
await assertIfReadOnlyMode();
await assertDataLayerAvailable();
await assertWalletIsAvailable();
await assertWalletIsSynced();

const myOrganization = await Organization.getHomeOrg();
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 @@ -21,6 +21,10 @@ OrganizationRouter.post(
},
);

OrganizationRouter.post('/create', (req, res) => {
return OrganizationController.createV2(req, res);
});

OrganizationRouter.put('/', (req, res) => {
return OrganizationController.importOrg(req, res);
});
Expand Down

0 comments on commit 99b2262

Please sign in to comment.