Skip to content

Commit

Permalink
feat: make png optional for organization creation
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed May 24, 2022
1 parent 6d69ad8 commit 1603379
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/controllers/organization.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ export const createV2 = async (req, res) => {
}

const { name } = req.body;
const buffer = req.files.file.data;
const icon = `data:image/png;base64, ${buffer.toString('base64')}`;
let icon;

if (_.get(req, 'files.file.data')) {
const buffer = req.files.file.data;
icon = `data:image/png;base64, ${buffer.toString('base64')}`;
} else {
icon = '';
}

const dataModelVersion = getDataModelVersion();

return res.json({
Expand Down
2 changes: 1 addition & 1 deletion src/validations/organizations.validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Joi from 'joi';

export const newOrganizationSchema = Joi.object({
name: Joi.string().required(),
icon: Joi.string().required(),
icon: Joi.string().optional(),
});

export const importOrganizationSchema = Joi.object({
Expand Down

0 comments on commit 1603379

Please sign in to comment.