mirror of
https://gitlab.rlp.net/proj-wise2526-video2document/video2document.git
synced 2026-06-15 18:01:52 +02:00
Finished the basic "Routers" and tested them.
This commit is contained in:
@@ -2,20 +2,10 @@ const express = require('express');
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.get("/", async(req, res) => {
|
||||
try {
|
||||
res.send("Videos");
|
||||
res.status(200).send("Videos send.");
|
||||
} catch (e) {
|
||||
res.status(500).send("Error trying to get the video files.")
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//Uploading a video file
|
||||
router.post("/", async(req, res) =>{
|
||||
try{
|
||||
res.send("videos send");
|
||||
res.status(201).send("Video file uploaded.");
|
||||
res.status(201).json({video:"VideoID"}); //TODO: return id as json
|
||||
}
|
||||
catch(e){
|
||||
res.status(500).send("Error trying to upload video file.");
|
||||
@@ -23,15 +13,33 @@ router.post("/", async(req, res) =>{
|
||||
|
||||
});
|
||||
|
||||
router.get("/{id}", async(req, res) => {
|
||||
//Requesting a list of all video files
|
||||
router.get("/", async(req, res) => {
|
||||
try {
|
||||
res.send("Video with id");
|
||||
res.status(200).send("Video details acquired.");
|
||||
res.status(200).json({videos:[]}); //TODO: return a json array showing all video files
|
||||
} catch (e) {
|
||||
|
||||
res.status(500).send("Error trying to get the video files.")
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//Getting a video file by id
|
||||
router.get("/:id", async(req, res) => {
|
||||
try {
|
||||
res.status(200).json({video: "id"}); //TODO: return the details regarding a specific video
|
||||
} catch (e) {
|
||||
res.status(401).send("Unknown ID.")
|
||||
}
|
||||
});
|
||||
|
||||
//Deleting a video file
|
||||
router.delete("/:id", async(req, res) =>{
|
||||
try {
|
||||
res.status(200).send("Deleted file."); //TODO: delet the video file
|
||||
} catch (e) {
|
||||
res.status(204).send("No content.");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//To make the router useable in the main.js file
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user