From a7422e8a1fd125a36dbabd9e78ae679af971bff7 Mon Sep 17 00:00:00 2001 From: pranavk1511 Date: Fri, 1 Dec 2023 22:40:25 -0500 Subject: [PATCH] Update app.js --- app.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app.js b/app.js index 8bd7d6d..802fa3d 100644 --- a/app.js +++ b/app.js @@ -117,7 +117,7 @@ app.use(checkDbConnectionMiddleware); // Middleware to check authorization header -app.use('/v1/assignments', async (req, res, next) => { +app.use('/v2/assignments', async (req, res, next) => { logger.info(`Application Middle-Ware Accessed`); if (req.method === 'PATCH'){ @@ -159,9 +159,9 @@ app.use('/v1/assignments', async (req, res, next) => { // }); //All users can see all assignemts -app.get('/v1/assignments', async (req, res) => { - logger.info(`Received ${req.method} request to /v1/assignments`); - console.log('Received GET request to /v1/assignments') +app.get('/v2/assignments', async (req, res) => { + logger.info(`Received ${req.method} request to /v2/assignments`); + console.log('Received GET request to /v2/assignments') if(Object.keys(req.body).length > 0){ return res.status(400).send("Body Not allowed"); } @@ -213,7 +213,7 @@ app.get('/v1/assignments', async (req, res) => { // ... //Get Assignemtn by ID -app.get('/v1/assignments/:id', async (req, res) => { +app.get('/v2/assignments/:id', async (req, res) => { if(Object.keys(req.body).length > 0){ return res.status(400).send("Body Not allowed"); } @@ -252,8 +252,8 @@ app.get('/v1/assignments/:id', async (req, res) => { // create an assignemnt -app.post('/v1/assignments', (req, res) => { - logger.info(`Received ${req.method} request to /v1/assignments`); +app.post('/v2/assignments', (req, res) => { + logger.info(`Received ${req.method} request to /v2/assignments`); try { const { name, @@ -327,7 +327,7 @@ app.post('/v1/assignments', (req, res) => { // Update assignment generated by a particular user -app.put('/v1/assignments/:id', async (req, res) => { +app.put('/v2/assignments/:id', async (req, res) => { if (Object.keys(req.query).length > 0 ) { return res.status(400).send("URL Parameters not allowed "); } @@ -400,7 +400,7 @@ app.put('/v1/assignments/:id', async (req, res) => { }); // Delete assignment generated by a particular user -app.delete('/v1/assignments/:id', async (req, res) => { +app.delete('/v2/assignments/:id', async (req, res) => { console.log(req.body); if (Object.keys(req.body).length > 0) { return res.status(400).send("Body Not allowed"); @@ -477,7 +477,7 @@ function processCSVFile() { } // Add new endpoint for assignment submission -app.use('/v1/assignments/:id/submission', async (req, res) => { +app.use('/v2/assignments/:id/submission', async (req, res) => { try { // Check if the request is a POST request if (req.method !== 'POST') {