Skip to content

Commit

Permalink
feat: single file Download
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Parodi committed Oct 11, 2022
1 parent fd1a851 commit c61c3a8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/files/files.routes.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ export class FilesRoutes extends CommonRoutesConfig {
.get((req: Request, res: Response) => {
// @TODO: Logic for folders
const fileCID = req.params.fileId;
if (!fileCID) res.status(400).send('File CID must be set!');
if (!fileCID) return res.status(400).send('File CID must be set!');

const userId = req.body.userId;
if (!userId) res.status(400).send('Missing userId');
const userId = req.params.userId;
if (!userId) return res.status(400).send('Missing userId');

filesController
return filesController
.getFile(userId, fileCID)
.then(file => res.status(200).send(file))
.catch(error =>
Expand All @@ -72,7 +72,9 @@ export class FilesRoutes extends CommonRoutesConfig {
})
// @TODO: Define if possible
.patch((req: Request, res: Response) => {
res.status(200).send(`TODO: PATCH file for id ${req.params.fileId}`);
return res
.status(200)
.send(`TODO: PATCH file for id ${req.params.fileId}`);
})
// @TODO: this uses filename and it's not really usable in a multiple-node context.
// @TODO: will make more sense for it to use :fileId BUT you can't delete files with the CID... not really sure why
Expand Down
1 change: 0 additions & 1 deletion src/hyperledger/StorageOperationController.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {HyperledgerController} from './HyperledgerController';
import {StorageOperation} from './contracts/StorageOperation.interface';
import { StorageController } from '../StorageController';

export class StorageOperationController {
//TODO we can use this to show / check history
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
"types": [], /* Specify type package names to be included without being referenced in a source file. */
"types": ["jest"], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "resolveJsonModule": true, /* Enable importing .json files. */
Expand Down

0 comments on commit c61c3a8

Please sign in to comment.