Portofolio
#feat - Create porto - Edit Porto - Upload gambar background profile - List user - Search user ## No issuue
This commit is contained in:
32
src/app/api/portofolio/logo/[id]/route.ts
Normal file
32
src/app/api/portofolio/logo/[id]/route.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import fs from "fs";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
const get = await prisma.images.findUnique({
|
||||
where: {
|
||||
id: params.id,
|
||||
},
|
||||
select: {
|
||||
url: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!fs.existsSync(`./public/portofolio/logo/${get?.url}`)) {
|
||||
const notFile = fs.readFileSync("./public/aset/global/no_img.png");
|
||||
return new NextResponse(notFile, {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
}
|
||||
const file = fs.readFileSync(`./public/portofolio/logo/${get?.url}`);
|
||||
return new NextResponse(file, {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
}
|
||||
32
src/app/api/profile/background/[id]/route.ts
Normal file
32
src/app/api/profile/background/[id]/route.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import fs from "fs";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
const get = await prisma.imagesBackground.findUnique({
|
||||
where: {
|
||||
id: params.id,
|
||||
},
|
||||
select: {
|
||||
url: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!fs.existsSync(`./public/profile/background/${get?.url}`)) {
|
||||
const notFile = fs.readFileSync("./public/aset/global/no_img.png");
|
||||
return new NextResponse(notFile, {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
}
|
||||
const file = fs.readFileSync(`./public/profile/background/${get?.url}`);
|
||||
return new NextResponse(file, {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
}
|
||||
32
src/app/api/profile/foto/[id]/route.ts
Normal file
32
src/app/api/profile/foto/[id]/route.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import fs from "fs";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
const get = await prisma.images.findUnique({
|
||||
where: {
|
||||
id: params.id,
|
||||
},
|
||||
select: {
|
||||
url: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!fs.existsSync(`./public/profile/foto/${get?.url}`)) {
|
||||
const notFile = fs.readFileSync("./public/aset/global/avatar.png");
|
||||
return new NextResponse(notFile, {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
}
|
||||
const file = fs.readFileSync(`./public/profile/foto/${get?.url}`);
|
||||
return new NextResponse(file, {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import fs from "fs";
|
||||
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { name: string } }
|
||||
) {
|
||||
if (!fs.existsSync(`./public/img/${params.name}`)) {
|
||||
const fl = fs.readFileSync(`./public/aset/avatar.png`);
|
||||
return new NextResponse(fl, {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
}
|
||||
const fl = fs.readFileSync(`./public/img/${params.name}`);
|
||||
return new NextResponse(fl, {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
}
|
||||
23
src/app/api/profile/url_background/[url]/route.ts
Normal file
23
src/app/api/profile/url_background/[url]/route.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import fs from "fs";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { url: string } }
|
||||
) {
|
||||
if (!fs.existsSync(`./public/profile/background/${params.url}`)) {
|
||||
const notFile = fs.readFileSync("./public/aset/global/no_img.png");
|
||||
return new NextResponse(notFile, {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const file = fs.readFileSync(`./public/profile/background/${params.url}`);
|
||||
return new NextResponse(file, {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
}
|
||||
23
src/app/api/profile/url_foto/[url]/route.ts
Normal file
23
src/app/api/profile/url_foto/[url]/route.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import fs from "fs";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { url: string } }
|
||||
) {
|
||||
if (!fs.existsSync(`./public/profile/foto/${params.url}`)) {
|
||||
const notFile = fs.readFileSync("./public/aset/global/avatar.png");
|
||||
return new NextResponse(notFile, {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const file = fs.readFileSync(`./public/profile/foto/${params.url}`);
|
||||
return new NextResponse(file, {
|
||||
headers: {
|
||||
"Content-Type": "image/png",
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user