aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO.md31
-rw-r--r--dist/FileRouter.js47
-rw-r--r--dist/app.js11
-rw-r--r--src/FileRouter.ts57
-rw-r--r--src/app.ts12
5 files changed, 150 insertions, 8 deletions
diff --git a/TODO.md b/TODO.md
index a18f6f9..425cbe3 100644
--- a/TODO.md
+++ b/TODO.md
@@ -65,3 +65,34 @@
- [ ] *Extensive Unit Testing*
## Write Report
+
+## General Notes
+- Records should be in CSV format (UTF8)
+- 1 Record per Line
+- Fields separated by ,
+- Every Record same # of fields
+- First Row has labels
+
+- Requests have the form of "/project/files/directory/file?filters"
+ - "file" is uuid or file-path
+ - "project" is project name
+ - "?" separates path from interface
+ - "filters" are a number of key-value pairs separated by &
+ - view
+ =meta : returns coloumns names and indexes
+ =file ORlack_of : actual data
+ - cols
+ =0,4,3 : specifies cols to filter
+ =* OR lack_of : all coloumns
+ - rowstart
+ =20 : first row to be included in search
+ default 0
+ - rowcount
+ =15 : number of rows to return
+ default all
+ - img_channel : index of colour channel
+ - img_zoomlevel : a number representing the 'zoom level' desired
+ - img_xoffset,img_yoffset: relative to top left corner, UNITS: 'real pixels', i.e. agnostic of zoom levels
+ - img_width : UNITS: 'real pixels', i.e. agnostic of zoom levels
+ - img_height : UNITS: 'real pixels', i.e. agnostic of zoom levels
+ - Post requests upload entire file \ No newline at end of file
diff --git a/dist/FileRouter.js b/dist/FileRouter.js
new file mode 100644
index 0000000..adf87cc
--- /dev/null
+++ b/dist/FileRouter.js
@@ -0,0 +1,47 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const express_1 = require("express");
+const Files = null; //require('../data');
+/*
+ * |->
+ * /project/files/directory/file?filters
+ * |->
+ */
+class FileRouter {
+ /**
+ * Initialize the FileRouter
+ */
+ constructor() {
+ this.router = express_1.Router();
+ this.init();
+ }
+ /**
+ * GET a File.
+ */
+ getFile(req, res, next) {
+ 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);
+ }
+}
+exports.FileRouter = FileRouter;
+// Create the FileRouter, and export its configured Express.Router
+const fileRoutes = new FileRouter();
+fileRoutes.init();
+exports.default = fileRoutes.router;
diff --git a/dist/app.js b/dist/app.js
index e983ca8..5d7bc52 100644
--- a/dist/app.js
+++ b/dist/app.js
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const express = require("express");
const logger = require("morgan");
const bodyParser = require("body-parser");
+const FileRouter_1 = require("./FileRouter");
class App {
constructor() {
this.express = express();
@@ -15,14 +16,16 @@ class App {
this.express.use(bodyParser.json());
this.express.use(bodyParser.urlencoded({ extended: false }));
}
+ // Configure API endpoints.
mountRoutes() {
- const router = express.Router();
- router.get('/', (req, res) => {
+ const defRouter = express.Router();
+ defRouter.get('/', (req, res) => {
res.json({
- message: 'Hello World!'
+ message: 'Welcome to the CS3099 BE4 server!'
});
});
- this.express.use('/', router);
+ this.express.use('/', defRouter);
+ this.express.use('/cs3099group-be-4/files/directory', FileRouter_1.default);
}
}
exports.default = new App().express;
diff --git a/src/FileRouter.ts b/src/FileRouter.ts
new file mode 100644
index 0000000..789a068
--- /dev/null
+++ b/src/FileRouter.ts
@@ -0,0 +1,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;
diff --git a/src/app.ts b/src/app.ts
index 345b73f..01e35fc 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -1,6 +1,8 @@
import * as express from 'express';
import * as logger from 'morgan';
import * as bodyParser from 'body-parser';
+import FileRouter from './FileRouter';
+
class App {
public express
@@ -18,14 +20,16 @@ class App {
this.express.use(bodyParser.urlencoded({ extended: false }));
}
+ // Configure API endpoints.
private mountRoutes (): void {
- const router = express.Router()
- router.get('/', (req, res) => {
+ const defRouter = express.Router()
+ defRouter.get('/', (req, res) => {
res.json({
- message: 'Hello World!'
+ message: 'Welcome to the CS3099 BE4 server!'
})
})
- this.express.use('/', router)
+ this.express.use('/', defRouter)
+ this.express.use('/cs3099group-be-4/files/directory', FileRouter)
}
}