aboutsummaryrefslogtreecommitdiff
path: root/src/FileRouter.ts
blob: 789a068db30741a56a085f21f1231c0a6c6f76ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import {Router, Request, Response, NextFunction} from 'express';
const Files = null;//require('../data');


/*
 *                         |->
 * /project/files/directory/file?filters
 *                         |->
 */
export class FileRouter {
  router: Router

  /**
   * Initialize the FileRouter
   */
  constructor() {
    this.router = Router();
    this.init();
  }

  /**
   * GET a File.
   */
  public getFile(req: Request, res: Response, next: NextFunction) {
    let fileID = req.params.file;
    // check if fileID is number or path
    // find file in data

    // check if only metadata was requested and return appropriate info
    // otherwise:

    // if image:
    // convert if necessary
    // zoom if necessary

    // if csv/xls
    // send data in appropriate csv format
    // limit cols if necessary

    res.send("File");
  }

  /**
   * Take each handler, and attach to one of the Express.Router's
   * endpoints.
   */
  init() {
    this.router.get('/:file', this.getFile);
  }

}

// Create the FileRouter, and export its configured Express.Router
const fileRoutes = new FileRouter();
fileRoutes.init();

export default fileRoutes.router;