-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
198 additions
and
109 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
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
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 GET( | ||
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(); | ||
|
||
const files = await FileModel.find({teamId:id}).populate("createdBy") | ||
|
||
return NextResponse.json(files,{ 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,31 @@ | ||
import { mongoDB } from "@/lib/MongoDB"; | ||
import { AuthMiddleware } from "@/Middleware/AuthMiddleware"; | ||
import FileModel from "@/models/file"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export async function GET( | ||
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(); | ||
|
||
const files = await FileModel.findById({_id:id}).populate("createdBy") | ||
|
||
return NextResponse.json(files,{ 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
Oops, something went wrong.