This commit is contained in:
smfahim25 2025-03-19 14:07:46 +06:00
parent bfa9fee43f
commit f3aa472e7e

View file

@ -4,21 +4,15 @@ import cors from "@elysiajs/cors";
import { ENV } from "./config/env";
import { api } from "./api";
const allowedOrigins = [
"http://localhost:5175",
"http://localhost:5174",
"http://localhost:5173",
"https://dashboard.planpostai.com",
"https://canvas.planpostai.com",
];
const app = new Elysia({
prefix: "",
tags: ["Default"],
})
const app = new Elysia()
.use(
cors({
origin: allowedOrigins,
origin: [
"http://localhost:5175",
"http://localhost:5174",
"https://dashboard.planpostai.com",
"https://canvas.planpostai.com",
],
methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"],
allowedHeaders: [
"Content-Type",
@ -31,37 +25,22 @@ const app = new Elysia({
credentials: true,
})
)
.get("/test", () => "Hello World", {})
.use(api)
.use(
swagger({
path: "/docs",
path: "/swagger",
documentation: {
openapi: "3.1.0",
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",
},
],
},
})
)
.onError(({ code, error }) => {
if (code === "NOT_FOUND") return "Not Found :(";
console.log("hello from app.ts under error");
console.error(error);
});
.listen(ENV.SERVER_PORT);
// all routes here
app.use(api);
app.listen(ENV.SERVER_PORT, () => {
console.log(`🦊 Elysia is running at ${ENV.SERVER_URL}:${ENV.SERVER_PORT}`);
});
console.log(`🦊 Elysia is running at ${ENV.SERVER_URL}`);
console.log(`Swagger docs available at ${ENV.SERVER_URL}/swagger`);