diff options
Diffstat (limited to '')
-rw-r--r-- | src/index.ts | 2 | ||||
-rw-r--r-- | src/routes/pendulum.ts (renamed from src/routes/api.ts) | 21 | ||||
-rw-r--r-- | src/views/pages/index.ejs | 3 |
3 files changed, 14 insertions, 12 deletions
diff --git a/src/index.ts b/src/index.ts index def7aff..117f0f1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ import rateLimit from 'express-rate-limit'; import helmet from 'helmet'; import path from 'path'; import { env } from 'process'; -import api from './routes/api'; +import api from './routes/pendulum'; const app = express(); diff --git a/src/routes/api.ts b/src/routes/pendulum.ts index 22edd79..66ad594 100644 --- a/src/routes/api.ts +++ b/src/routes/pendulum.ts @@ -6,6 +6,9 @@ import fileUpload, { UploadedFile } from 'express-fileupload'; import { access, stat } from 'fs/promises'; import { quote } from 'shell-quote'; +/** + * The endpoint for the API calls involving file uploads and running the files on the pendulum. + */ const api = express.Router(); // Use JSON parser for API requests and responses @@ -217,16 +220,14 @@ api return res.status(405).json({ error: 'Method not allowed.' }); }); -/* - Verify that the file exists and is a regular file - Parameters: - path: The path to the file on the server - res: The response object to send the unsuccessful response to - Returns: - true: The file exists and is a regular file - false: The file does not exist or is not a regular file - ** AFTER THIS POINT, THE API HAS ALREADY SENT A RESPONSE, SO THE FUNCTION THAT CALLED IT SHOULD NOT RETURN ANOTHER RESPONSE ** -*/ +/** + * Verify that the file exists and is a regular file so it can be sent to the user + * @param file The path to the file + * @param res The Express response object, used if the file is not accessible + * @returns `true` if the file exists and is a regular file,`false` otherwise + * + * `AFTER THIS POINT, THE API HAS ALREADY SENT A RESPONSE, SO THE FUNCTION THAT CALLED IT SHOULD NOT RETURN ANOTHER RESPONSE ` + */ async function verifyFile(file: string, res: Response) { // Make sure the file being requested to run exists try { diff --git a/src/views/pages/index.ejs b/src/views/pages/index.ejs index 7c24e78..f537080 100644 --- a/src/views/pages/index.ejs +++ b/src/views/pages/index.ejs @@ -35,8 +35,9 @@ <input type="submit" id="actuate-but" value="Actuate!" /> </form> <h3> - <span id="download-link"></span> + <span id="download-link"></span> </h3> + <img src="/video" alt="Live video feed of the Pendulum"> </div> |