From 587ad149c92fcdb433fb51c8b6d0d85c95dcab38 Mon Sep 17 00:00:00 2001 From: Aurelius Ivan Wijaya Date: Mon, 8 Apr 2024 08:35:58 +0700 Subject: [PATCH] fix build issue --- client/src/app/login/page.tsx | 16 +--------------- client/src/app/page.tsx | 2 +- client/src/services/post.service.ts | 8 ++++---- src/config/aws-s3.config.ts | 6 +++--- src/middleware/file.middleware.ts | 1 + 5 files changed, 10 insertions(+), 23 deletions(-) diff --git a/client/src/app/login/page.tsx b/client/src/app/login/page.tsx index f8ff2e5..32cae95 100644 --- a/client/src/app/login/page.tsx +++ b/client/src/app/login/page.tsx @@ -1,4 +1,4 @@ -'use client' +'use server' import { BellRing, Check } from "lucide-react" import { Button } from "@/components/ui/button" import { @@ -17,18 +17,7 @@ import { LoginButton } from './part/login.button' import React, { useState } from 'react' -// Login ge export default async function LoginPage() { - // submit - async function submit(e: React.FormEvent) { - e.preventDefault() - const data = { - email: 'aureliusivanwijaya@gmail.com', - password: '12345678' - } - const response = await AuthService.login(data.email, data.password) as any - // console.log(response) - } return (
@@ -36,9 +25,6 @@ export default async function LoginPage() { className='flex flex-col items-center justify-center h-screen gap-4' >
diff --git a/client/src/app/page.tsx b/client/src/app/page.tsx index ac4374e..3760578 100644 --- a/client/src/app/page.tsx +++ b/client/src/app/page.tsx @@ -12,7 +12,7 @@ async function Post() {
- {data.data.map((post: any) => ( + {data?.data?.map((post: any) => ( { - // const response = await axios.get('/api/post/get'); - const response = await fetch(`${END_POINT}/api/post/get`, { + const response = await fetch(END_POINT + `/api/post/get`, { method: 'GET', headers: { 'Content-Type': 'application/json', }, next: { - revalidate: 3600 + revalidate: 1, } }) .then(response => response.json()) .then(data => data) - .catch(error => console.error(error)) + // .catch(error => console.error(error)) + // console.log(response) return response; }, get: async (id: string) => { diff --git a/src/config/aws-s3.config.ts b/src/config/aws-s3.config.ts index 0b3a691..d6867c5 100644 --- a/src/config/aws-s3.config.ts +++ b/src/config/aws-s3.config.ts @@ -4,10 +4,10 @@ dotenv.config() const S3Config = new S3Client({ region: "apac", // this is the region that you select in AWS account - endpoint: process.env.R2_ENDPOINT, + endpoint: process.env.S3_ENDPOINT, credentials: { - accessKeyId: process.env.R2_ACCESS_KEY, // store it in .env file to keep it safe - secretAccessKey: process.env.R2_SECRET_KEY + accessKeyId: process.env.S3_ACCESS_KEY, // store it in .env file to keep it safe + secretAccessKey: process.env.S3_SECRET_KEY } }) diff --git a/src/middleware/file.middleware.ts b/src/middleware/file.middleware.ts index 6076c4e..95f9b36 100644 --- a/src/middleware/file.middleware.ts +++ b/src/middleware/file.middleware.ts @@ -66,6 +66,7 @@ const uploadFileMiddlwareS3 = (fieldname: string) => (req: Request, res: Respons // Validate file types and sizes files.forEach((file: any) => { + // log file const allowedTypes = ['image/jpeg', 'image/png', 'image/svg', 'image/webp']; const maxSize = 5 * 1024 * 1024; // 5MB