Skip to content

Commit

Permalink
cleanup + lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rmgraham committed Jun 3, 2020
1 parent cf98c04 commit c7f4dca
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions app/apollo/resolvers/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const channelResolvers = {
throw 'channel_uuid not specified';
}
if(!file && !content){
throw `Please specify either file or content`;
throw 'Please specify either file or content';
}

const channel = await models.Channel.findOne({ uuid: channel_uuid, org_id });
Expand All @@ -195,15 +195,13 @@ const channelResolvers = {
throw new ValidationError(`The version name ${name} already exists`);
}

//console.log(33333, file);
let fileStream = null;
if(file){
fileStream = (await file).createReadStream();
}
else{
fileStream = stream.Readable.from([ content ]);
}
console.log(33334);

const iv = crypto.randomBytes(16);
const ivText = iv.toString('base64');
Expand All @@ -227,22 +225,22 @@ const channelResolvers = {
}
else{
var buf = new WritableStreamBuffer();
await stream.pipeline(
fileStream,
buf,
(err)=>{
if(err){
await new Promise((resolve, reject)=>{
return stream.pipeline(
fileStream,
buf,
(err)=>{
if(err){
reject(err);
}
resolve(err);
}
}
);
);
});
const content = buf.getContents().toString('utf8');
data = await encryptOrgData(orgKey, content);
}

console.log(1111, data);
//return;

const deployableVersionObj = {
_id: UUID(),
org_id,
Expand Down

0 comments on commit c7f4dca

Please sign in to comment.