-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #470 from Sid-80/feat/468
Feat/468
- Loading branch information
Showing
5 changed files
with
80 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { mongoDB } from "@/lib/MongoDB"; | ||
import { AuthMiddleware } from "@/Middleware/AuthMiddleware"; | ||
import FileModel from "@/models/file"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export async function DELETE( | ||
request: Request, | ||
{ params }: { params: { id: string } } | ||
) { | ||
|
||
const result = await AuthMiddleware(request); | ||
|
||
if (result instanceof NextResponse) { | ||
|
||
try { | ||
|
||
const { id } = params; | ||
|
||
if (!id) return new Response("Parameters missing!!", { status: 401 }); | ||
|
||
await mongoDB(); | ||
|
||
await FileModel.deleteOne({_id:id}) | ||
|
||
return NextResponse.json('Deleted SuccessFully!!',{ status: 200 }); | ||
} catch (err) { | ||
return NextResponse.json(`Err : ${err}`, {status:500}); | ||
} | ||
} else { | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { mongoDB } from "@/lib/MongoDB"; | ||
import { AuthMiddleware } from "@/Middleware/AuthMiddleware"; | ||
import TeamModel from "@/models/team"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export async function DELETE( | ||
request: Request, | ||
{ params }: { params: { id: string } } | ||
) { | ||
|
||
const result = await AuthMiddleware(request); | ||
|
||
if (result instanceof NextResponse) { | ||
|
||
try { | ||
|
||
const { id } = params; | ||
|
||
if (!id) return new Response("Parameters missing!!", { status: 401 }); | ||
|
||
await mongoDB(); | ||
|
||
await TeamModel.deleteOne({_id:id}) | ||
|
||
return NextResponse.json('Deleted SuccessFully!!',{ status: 200 }); | ||
} catch (err) { | ||
return NextResponse.json(`Err : ${err}`, {status:500}); | ||
} | ||
} else { | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters