Skip to content

Commit

Permalink
Update app.js
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavk1511 committed Dec 2, 2023
1 parent 3acaf92 commit a7422e8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'){
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 ");
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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') {
Expand Down

0 comments on commit a7422e8

Please sign in to comment.