Merge pull request #295 from bipproduction/bagas/10-feb-25
Bagas/10 feb 25
This commit is contained in:
15
eslint.config.mjs
Normal file
15
eslint.config.mjs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { fileURLToPath } from "url";
|
||||||
|
import { FlatCompat } from "@eslint/eslintrc";
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const dirname = dirname(filename);
|
||||||
|
|
||||||
|
const compat = new FlatCompat({
|
||||||
|
baseDirectory: __dirname,
|
||||||
|
});
|
||||||
|
|
||||||
|
const eslintConfig = [
|
||||||
|
...compat.extends("next/core-web-vitals", "next/typescript"),
|
||||||
|
];
|
||||||
|
|
||||||
|
export default eslintConfig;
|
||||||
@@ -102,5 +102,8 @@
|
|||||||
"winston": "^3.17.0",
|
"winston": "^3.17.0",
|
||||||
"winston-daily-rotate-file": "^5.0.0",
|
"winston-daily-rotate-file": "^5.0.0",
|
||||||
"yaml": "^2.3.2"
|
"yaml": "^2.3.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/eslintrc": "^3.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
push-staging.wibu
Normal file
3
push-staging.wibu
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
git add -A
|
||||||
|
git commit -m "data auto"
|
||||||
|
git push origin bagas/10-feb-25
|
||||||
@@ -1,39 +1,25 @@
|
|||||||
import { prisma } from "@/app/lib";
|
import { prisma } from "@/app/lib";
|
||||||
import backendLogger from "@/util/backendLogger";
|
|
||||||
import _ from "lodash";
|
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export async function GET(request: Request) {
|
export async function GET() {
|
||||||
const method = request.method;
|
try {
|
||||||
if (method !== 'GET') {
|
const fixData = await prisma.donasiMaster_Kategori.count({});
|
||||||
return NextResponse.json({
|
return NextResponse.json(
|
||||||
success: false,
|
{
|
||||||
message: 'Method not allowed',
|
success: true,
|
||||||
},
|
message: "Success get data donasi dashboard",
|
||||||
{ status: 405 }
|
data: fixData,
|
||||||
)
|
},
|
||||||
}
|
{ status: 200 }
|
||||||
|
);
|
||||||
try {
|
} catch (error) {
|
||||||
let fixData;
|
return NextResponse.json(
|
||||||
fixData = await prisma.donasiMaster_Kategori.count({});
|
{
|
||||||
return NextResponse.json({
|
success: true,
|
||||||
success: true,
|
message: "gagal mendapatkan data donasi dashboard",
|
||||||
message: 'Success get data donasi dashboard',
|
error: (error as Error).message,
|
||||||
data: fixData
|
},
|
||||||
},
|
{ status: 500 }
|
||||||
{ status: 200 }
|
);
|
||||||
)
|
}
|
||||||
} catch (error) {
|
}
|
||||||
backendLogger.error('Error get data donasi dashboard >>', error);
|
|
||||||
return NextResponse.json({
|
|
||||||
success: false,
|
|
||||||
message: 'Error get data donasi dashboard',
|
|
||||||
reason: (error as Error).message
|
|
||||||
},
|
|
||||||
{ status: 500 }
|
|
||||||
)
|
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,18 +3,9 @@ import backendLogger from "@/util/backendLogger";
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export async function GET(request: Request) {
|
export async function GET() {
|
||||||
const method = request.method;
|
|
||||||
if (method !== "GET") {
|
|
||||||
return NextResponse.json(
|
|
||||||
{ success: false, message: "Method not allowed" },
|
|
||||||
{ status: 405 }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let fixData;
|
const fixData = await prisma.eventMaster_TipeAcara.count({
|
||||||
fixData = await prisma.eventMaster_TipeAcara.count({
|
|
||||||
where: {
|
where: {
|
||||||
active: true,
|
active: true,
|
||||||
},
|
},
|
||||||
@@ -38,7 +29,5 @@ export async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
await prisma.$disconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,43 +2,31 @@ import { prisma } from "@/app/lib";
|
|||||||
import backendLogger from "@/util/backendLogger";
|
import backendLogger from "@/util/backendLogger";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export async function GET(request: Request, { params }: {
|
export async function GET() {
|
||||||
params: { status: string }
|
try {
|
||||||
}) {
|
const fixData = await prisma.forum_Posting.count({
|
||||||
const method = request.method;
|
where: {
|
||||||
if (method !== "GET") {
|
isActive: true,
|
||||||
return NextResponse.json({
|
},
|
||||||
success: false,
|
});
|
||||||
message: "Method not allowed",
|
|
||||||
},
|
|
||||||
{ status: 405 }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
let fixData;
|
|
||||||
fixData = await prisma.forum_Posting.count({
|
|
||||||
where: {
|
|
||||||
isActive: true,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json(
|
||||||
success: true,
|
{
|
||||||
message: "Success get data forum dashboard",
|
success: true,
|
||||||
data: fixData,
|
message: "Success get data forum dashboard",
|
||||||
},
|
data: fixData,
|
||||||
{ status: 200 }
|
},
|
||||||
);
|
{ status: 200 }
|
||||||
} catch (error) {
|
);
|
||||||
backendLogger.error("Error get data forum dashboard", error);
|
} catch (error) {
|
||||||
return NextResponse.json({
|
backendLogger.error("Error get data forum dashboard", error);
|
||||||
success: false,
|
return NextResponse.json(
|
||||||
message: "Error get data forum dashboard",
|
{
|
||||||
reason: (error as Error).message
|
success: false,
|
||||||
},
|
message: "Error get data forum dashboard",
|
||||||
{ status: 500 }
|
reason: (error as Error).message,
|
||||||
)
|
},
|
||||||
} finally {
|
{ status: 500 }
|
||||||
await prisma.$disconnect();
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,44 @@
|
|||||||
import { useDisclosure } from "@mantine/hooks";
|
import { PrismaClient } from '@prisma/client';
|
||||||
import { PrismaClient } from "@prisma/client";
|
|
||||||
|
|
||||||
// Singleton PrismaClient untuk pengembangan
|
let prisma: PrismaClient;
|
||||||
const globalForPrisma = globalThis as unknown as {
|
|
||||||
__prisma__: PrismaClient | undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const prisma =
|
if (process.env.NODE_ENV === 'production') {
|
||||||
globalForPrisma.__prisma__ ??
|
prisma = new PrismaClient();
|
||||||
new PrismaClient({
|
} else {
|
||||||
// log: process.env.NODE_ENV === 'development' ? ['query', 'info', 'warn', 'error'] : [],
|
const globalWithPrisma = global as typeof globalThis & {
|
||||||
});
|
prisma: PrismaClient;
|
||||||
|
};
|
||||||
// Gunakan PrismaClient yang sama jika sudah ada
|
if (!globalWithPrisma.prisma) {
|
||||||
if (process.env.NODE_ENV !== "production") {
|
globalWithPrisma.prisma = new PrismaClient();
|
||||||
if (!globalForPrisma.__prisma__) {
|
}
|
||||||
console.log("PrismaClient initialized in development mode");
|
prisma = globalWithPrisma.prisma;
|
||||||
}
|
|
||||||
globalForPrisma.__prisma__ = prisma;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process.on("SIGINT", async () => {
|
// Handle uncaught errors
|
||||||
// console.log("Start in Disconnecting PrismaClient...");
|
process.on('uncaughtException', async (error) => {
|
||||||
const disconnect = await prisma.$disconnect();
|
console.error('Uncaught Exception:', error);
|
||||||
// console.log("End of Disconnecting PrismaClient...", disconnect);
|
await prisma.$disconnect();
|
||||||
process.exit(0);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default prisma;
|
// Handle unhandled promise rejections
|
||||||
|
process.on('unhandledRejection', async (error) => {
|
||||||
|
console.error('Unhandled Rejection:', error);
|
||||||
|
await prisma.$disconnect();
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle graceful shutdown
|
||||||
|
process.on('SIGINT', async () => {
|
||||||
|
console.log('Received SIGINT signal. Closing database connections...');
|
||||||
|
await prisma.$disconnect();
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('SIGTERM', async () => {
|
||||||
|
console.log('Received SIGTERM signal. Closing database connections...');
|
||||||
|
await prisma.$disconnect();
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
export default prisma;
|
||||||
Reference in New Issue
Block a user