From d621437a4d3ade5645ed3982f3a861aa2e669fe8 Mon Sep 17 00:00:00 2001 From: jhpin2 Date: Sat, 22 Feb 2025 08:26:26 +0000 Subject: [PATCH] revert ac5e68536fe1e4d7fafb3e29640828e8a58895e7 revert Merge branch 'canvas_be_v1' --- .gitignore | 2 +- package.json | 2 +- src/api/index.ts | 8 ++--- .../photoLibrary/photo.library.controller.ts | 21 ------------- src/api/photoLibrary/photo.library.route.ts | 31 ------------------- src/config/env.ts | 2 -- 6 files changed, 4 insertions(+), 62 deletions(-) delete mode 100644 src/api/photoLibrary/photo.library.controller.ts delete mode 100644 src/api/photoLibrary/photo.library.route.ts diff --git a/.gitignore b/.gitignore index 996fc0e..90edc0c 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,7 @@ yarn-debug.log* yarn-error.log* # local env files -.env +.env .env.local .env.development.local .env.test.local diff --git a/package.json b/package.json index 98fa195..3d937cf 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.50", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "db:studio": "drizzle-kit studio --port=3000", + "db:studio": "drizzle-kit studio", "db:generate": "drizzle-kit generate", "db:migrate": "drizzle-kit migrate", "db:push": "drizzle-kit push:pg", diff --git a/src/api/index.ts b/src/api/index.ts index 5a7444f..467471b 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -3,18 +3,14 @@ import { projectRoutes } from "./project/project.route"; import { uploadRoutes } from "./upload/upload.route"; import { authRoute } from "./auth/auth.route"; import { downloadRoute } from "./downloadCount/download.count.route"; -import { photoLibraryRoutes } from "./photoLibrary/photo.library.route"; export const api = new Elysia({ prefix: "/api", }); - api.get("/", () => { - return "Hello from PlanPostAI Canvas API"; + return "Hello from PlanPostAI Canvas API"; }); - api.use(authRoute); api.use(projectRoutes); api.use(uploadRoutes); -api.use(downloadRoute); -api.use(photoLibraryRoutes); \ No newline at end of file +api.use(downloadRoute); \ No newline at end of file diff --git a/src/api/photoLibrary/photo.library.controller.ts b/src/api/photoLibrary/photo.library.controller.ts deleted file mode 100644 index 82f9b0c..0000000 --- a/src/api/photoLibrary/photo.library.controller.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ENV } from "../../config/env"; - -export const getPhotos = async (keyword: string, pre_page: number, token: string) => { - try { - const url = `${ENV.PEXELS_URL}/search?query=${keyword}&per_page=${pre_page}`; - const response = await fetch(url, { - headers: { - Authorization: process.env.PEXELS_ACCESS_KEY as string, - }, - }) - - if (!response.ok) { - return { status: 500, message: "An error occurred while getting the photos", token } - } - const data = await response.json(); - return { data, token } - } catch (error: any) { - console.log("Error in getting photos:", error.message || error.toString()); - return { status: 500, message: "An error occurred while getting the photos", token }; - } -} \ No newline at end of file diff --git a/src/api/photoLibrary/photo.library.route.ts b/src/api/photoLibrary/photo.library.route.ts deleted file mode 100644 index 7381c4c..0000000 --- a/src/api/photoLibrary/photo.library.route.ts +++ /dev/null @@ -1,31 +0,0 @@ -import Elysia, { t } from "elysia"; -import { getPhotos } from "./photo.library.controller"; -import { verifyAuth } from "../../middlewares/auth.middlewares"; - -export const photoLibraryRoutes = new Elysia({ - prefix: "/photos", - tags: ["Photos"], - detail: { - description: "Routes for managing photo library", - } -}).derive(async ({ cookie }) => { - const authData = await verifyAuth(cookie); - return { authData }; // Inject into context -}); - -photoLibraryRoutes.get("/", async ({ query, authData -}) => { - if (authData.status !== 200) - return authData; - else { - const { keyword, per_page } = query; - const token = authData.token; - const data = await getPhotos(keyword, per_page, token); - return { data }; - } -}, { - query: t.Object({ - keyword: t.String(), - per_page: t.Number(), - }) -}) \ No newline at end of file diff --git a/src/config/env.ts b/src/config/env.ts index a1888e1..8bd4ea4 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -11,6 +11,4 @@ export const ENV = { CLERK_SECRET_KEY: process.env.CLERK_SECRET_KEY, JWT_ACCESS_TOKEN_SECRET: process.env.JWT_ACCESS_TOKEN_SECRET, JWT_REFRESH_TOKEN_SECRET: process.env.JWT_REFRESH_TOKEN_SECRET, - PEXELS_URL: process.env.PEXELS_URL, - PEXELS_ACCESS_KEY: process.env.PEXELS_ACCESS_KEY, } \ No newline at end of file