Skip to content

Commit

Permalink
refactor: only one return statement
Browse files Browse the repository at this point in the history
  • Loading branch information
casparneumann-cap committed Oct 6, 2023
1 parent 309c57d commit dd41731
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -426,29 +426,31 @@ export class LibraryStorage implements ILibraryStorage {
*/
public async getLibraryFile(ubername: string, file: string) {
const libraryName = LibraryName.fromUberName(ubername);

this.checkFilename(file);

let returnValue: {};
if (file === 'library.json') {
const metadata = await this.getMetadata(libraryName);
const stringifiedMetadata = JSON.stringify(metadata);
const readable = Readable.from(stringifiedMetadata);

return {
returnValue = {
stream: readable,
mimetype: 'application/json',
size: stringifiedMetadata.length,
};
}

const response = await this.s3Client.get(this.getS3Key(libraryName, file));
} else{
const response = await this.s3Client.get(this.getS3Key(libraryName, file));
const mimetype = mime.lookup(file, 'application/octet-stream');

returnValue = {
stream: response.data,
mimetype,
size: response.contentLength,
};

const mimetype = mime.lookup(file, 'application/octet-stream');
}

return {
stream: response.data,
mimetype,
size: response.contentLength,
};
return returnValue;
}
}

0 comments on commit dd41731

Please sign in to comment.