From e6d8f98dd063374f1bd87b542f8dcb09134e9b16 Mon Sep 17 00:00:00 2001 From: smfahim25 Date: Thu, 20 Mar 2025 13:05:50 +0600 Subject: [PATCH] update package --- entrypoint.sh | 2 +- src/app.ts | 95 +++++++++++++++++++++++---------------------------- 2 files changed, 43 insertions(+), 54 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 628bb4d..34eafec 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,4 +6,4 @@ bun run db:migrate # Start the application echo "Starting the application..." -./server \ No newline at end of file +./serverg \ No newline at end of file diff --git a/src/app.ts b/src/app.ts index 4b7955b..5a08f62 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,59 +1,48 @@ import { Elysia } from "elysia"; -import swagger from '@elysiajs/swagger'; - -import { ENV } from "./config/env"; +import swagger from "@elysiajs/swagger"; import cors from "@elysiajs/cors"; +import { ENV } from "./config/env"; import { api } from "./api"; -const allowedOrigins = [ - "http://localhost:5175", - "http://localhost:5173", - // allowed canvas backend (user) origins(for user) - "https://localhost:3001", -]; - -const app = new Elysia({ - prefix: "", - tags: ["Default"], -}) - .use(cors({ - origin: allowedOrigins, - methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"], - allowedHeaders: ["Content-Type", "Authorization", "X-Requested-With", "Accept", "Origin", "Access-Control-Allow-Origin"], - credentials: true, - })) - .use(swagger({ - path: "/api/docs", - documentation: { - info: { - title: "Canvas API", - version: "1.0.0", - description: "Canvas API Documentation", - }, - tags: [ - { - name: "Projects", - description: "All APIs related to Projects", - }, - { - name: "Uploads", - description: "All APIs related to Uploads" - } +const app = new Elysia() + .use( + cors({ + origin: [ + "http://localhost:5175", + "http://localhost:5174", + "https://dashboard.planpostai.com", + "https://dev.dashboard.planpostai.com", + "https://canvas.planpostai.com", + "https://canvasdev.planpostai.com", ], - } - })) - .onError(({ code, error }) => { - if (code === 'NOT_FOUND') - return 'Not Found :('; - console.log("hello from app.ts under error"); - console.error(error) - }); - -// all routes here -app.use(api); - -app.listen(ENV.SERVER_PORT, () => { - console.log(`🦊 Elysia is running at ${ENV.SERVER_URL}:${ENV.SERVER_PORT}`) -}) - + methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"], + allowedHeaders: [ + "Content-Type", + "Authorization", + "X-Requested-With", + "Accept", + "Origin", + "Access-Control-Allow-Origin", + ], + credentials: true, + }) + ) + .get("/test", () => "Hello World", {}) + .use(api) + .use( + swagger({ + path: "/swagger", + documentation: { + openapi: "3.1.0", + info: { + title: "Canvas API", + version: "1.0.0", + description: "Canvas API Documentation", + }, + }, + }) + ) + .listen(ENV.SERVER_PORT); +console.log(`🦊 Elysia is running at ${ENV.SERVER_URL}`); +console.log(`Swagger docs available at ${ENV.SERVER_URL}/swagger`);