Compare commits
No commits in common. "363edc548a65b959072dbf69f32b3b72b5007896" and "f91ff472d05f88e3bce6bf4c64b71f8b30a9f79f" have entirely different histories.
363edc548a
...
f91ff472d0
9 changed files with 6 additions and 79 deletions
5
.env
5
.env
|
|
@ -1,5 +1,5 @@
|
||||||
SERVER_URL=http://localhost
|
SERVER_URL=http://localhost
|
||||||
SERVER_PORT=3001
|
SERVER_PORT=3000
|
||||||
|
|
||||||
DATABASE_URL=postgres://postgres:saimon%40567@localhost:5432/planpost_canvas
|
DATABASE_URL=postgres://postgres:saimon%40567@localhost:5432/planpost_canvas
|
||||||
|
|
||||||
|
|
@ -14,9 +14,6 @@ JWT_ACCESS_TOKEN_SECRET=planpostai%^$_%43%65576canvas%%$$
|
||||||
|
|
||||||
JWT_REFRESH_TOKEN_SECRET=planpostai!@43223_canvas$%^$349332$$
|
JWT_REFRESH_TOKEN_SECRET=planpostai!@43223_canvas$%^$349332$$
|
||||||
|
|
||||||
# developer canvas server url
|
|
||||||
CANVAS_SERVER_URL_DEV=http://localhost:3000/api
|
|
||||||
|
|
||||||
PEXELS_URL=https://api.pexels.com/v1
|
PEXELS_URL=https://api.pexels.com/v1
|
||||||
PEXELS_ACCESS_KEY=6PK7hLvOuG6nFsmC8c9EV0P8hGkyHeIhYpiRxhkEfh2ePK0GhiQypBhI
|
PEXELS_ACCESS_KEY=6PK7hLvOuG6nFsmC8c9EV0P8hGkyHeIhYpiRxhkEfh2ePK0GhiQypBhI
|
||||||
|
|
||||||
|
|
|
||||||
21
env.example
21
env.example
|
|
@ -1,21 +0,0 @@
|
||||||
SERVER_URL=
|
|
||||||
SERVER_PORT=
|
|
||||||
|
|
||||||
DATABASE_URL=
|
|
||||||
|
|
||||||
MINIO_ACCESS_KEY=
|
|
||||||
MINIO_SECRET_KEY=
|
|
||||||
MINIO_ENDPOINT=
|
|
||||||
MINIO_PORT=
|
|
||||||
|
|
||||||
CLERK_SECRET_KEY=
|
|
||||||
|
|
||||||
JWT_ACCESS_TOKEN_SECRET=
|
|
||||||
|
|
||||||
JWT_REFRESH_TOKEN_SECRET=
|
|
||||||
|
|
||||||
# developer canvas server url
|
|
||||||
CANVAS_SERVER_URL_DEV=
|
|
||||||
|
|
||||||
PEXELS_URL=
|
|
||||||
PEXELS_ACCESS_KEY=
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
import { ENV } from "../../config/env";
|
|
||||||
|
|
||||||
export const getAllDesign = async (token: string) => {
|
|
||||||
try {
|
|
||||||
const response = await fetch(`${ENV.CANVAS_SERVER_URL_DEV}/design`, {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const data = await response.json();
|
|
||||||
return data;
|
|
||||||
} catch (error: any) {
|
|
||||||
console.log(error);
|
|
||||||
return { status: 500, message: error.message, token };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
import Elysia from "elysia";
|
|
||||||
import { verifyAuth } from "../../middlewares/auth.middlewares";
|
|
||||||
import { getAllDesign } from "./design.controller";
|
|
||||||
|
|
||||||
export const designRoute = new Elysia({
|
|
||||||
prefix: "/design",
|
|
||||||
tags: ["Design"],
|
|
||||||
detail: {
|
|
||||||
description: "Routes for managing designs",
|
|
||||||
}
|
|
||||||
}).derive(async ({ cookie }) => {
|
|
||||||
const authData = await verifyAuth(cookie);
|
|
||||||
return { authData }; // Inject into context
|
|
||||||
})
|
|
||||||
|
|
||||||
designRoute.get("/", async ({ authData }) => {
|
|
||||||
if (authData.status !== 200)
|
|
||||||
return authData;
|
|
||||||
else {
|
|
||||||
const token = authData.token;
|
|
||||||
const response = await getAllDesign(token);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
@ -4,7 +4,6 @@ import { uploadRoutes } from "./upload/upload.route";
|
||||||
import { authRoute } from "./auth/auth.route";
|
import { authRoute } from "./auth/auth.route";
|
||||||
import { downloadRoute } from "./downloadCount/download.count.route";
|
import { downloadRoute } from "./downloadCount/download.count.route";
|
||||||
import { photoLibraryRoutes } from "./photoLibrary/photo.library.route";
|
import { photoLibraryRoutes } from "./photoLibrary/photo.library.route";
|
||||||
import { designRoute } from "./design/design.route";
|
|
||||||
|
|
||||||
export const api = new Elysia({
|
export const api = new Elysia({
|
||||||
prefix: "/api",
|
prefix: "/api",
|
||||||
|
|
@ -18,5 +17,4 @@ api.use(authRoute);
|
||||||
api.use(projectRoutes);
|
api.use(projectRoutes);
|
||||||
api.use(uploadRoutes);
|
api.use(uploadRoutes);
|
||||||
api.use(downloadRoute);
|
api.use(downloadRoute);
|
||||||
api.use(photoLibraryRoutes);
|
api.use(photoLibraryRoutes);
|
||||||
api.use(designRoute);
|
|
||||||
|
|
@ -86,10 +86,10 @@ export const createProject = async (userId: string, token: string) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateProject = async (id: string, body: any, token: string, user_id: string) => {
|
export const updateProject = async (id: string, body: any, token: string) => {
|
||||||
try {
|
try {
|
||||||
// 1. Validate if project exists
|
// 1. Validate if project exists
|
||||||
const existingProject = await db.select().from(projects).where(eq(projects.id, id));
|
const existingProject = await db.select().from(projects).where(eq(projects.id, id)).limit(1);
|
||||||
if (existingProject.length === 0) {
|
if (existingProject.length === 0) {
|
||||||
return { status: 404, message: "Project not found", token };
|
return { status: 404, message: "Project not found", token };
|
||||||
}
|
}
|
||||||
|
|
@ -101,8 +101,7 @@ export const updateProject = async (id: string, body: any, token: string, user_i
|
||||||
object,
|
object,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
preview_url,
|
preview_url
|
||||||
userId: user_id,
|
|
||||||
}).where(eq(projects.id, id)).returning({
|
}).where(eq(projects.id, id)).returning({
|
||||||
id: projects.id,
|
id: projects.id,
|
||||||
object: projects.object,
|
object: projects.object,
|
||||||
|
|
|
||||||
|
|
@ -54,9 +54,7 @@ projectRoutes.put("/update/:project_id", async ({ body, params: { project_id },
|
||||||
return authData;
|
return authData;
|
||||||
else {
|
else {
|
||||||
const token = authData.token;
|
const token = authData.token;
|
||||||
const user_id = authData?.userId;
|
const response = await updateProject(project_id, body, token);
|
||||||
// sending user_id to the controller to update the project with the user_id, when user tried to design a existing project from the design project panel
|
|
||||||
const response = await updateProject(project_id, body, token, user_id as string);
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import { api } from "./api";
|
||||||
|
|
||||||
const allowedOrigins = [
|
const allowedOrigins = [
|
||||||
"http://localhost:5175",
|
"http://localhost:5175",
|
||||||
"http://localhost:5174",
|
|
||||||
"http://localhost:5173",
|
"http://localhost:5173",
|
||||||
"https://dashboard.planpostai.com",
|
"https://dashboard.planpostai.com",
|
||||||
"https://canvas.planpostai.com",
|
"https://canvas.planpostai.com",
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import 'dotenv/config'
|
||||||
export const ENV = {
|
export const ENV = {
|
||||||
SERVER_URL: process.env.SERVER_URL,
|
SERVER_URL: process.env.SERVER_URL,
|
||||||
SERVER_PORT: process.env.SERVER_PORT || 5000,
|
SERVER_PORT: process.env.SERVER_PORT || 5000,
|
||||||
CANVAS_SERVER_URL_DEV: process.env.CANVAS_SERVER_URL_DEV,
|
|
||||||
DATABASE_URL: process.env.DATABASE_URL,
|
DATABASE_URL: process.env.DATABASE_URL,
|
||||||
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
|
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
|
||||||
MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
|
MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue