update package

This commit is contained in:
smfahim25 2025-03-20 13:05:50 +06:00
parent 77fed46909
commit e6d8f98dd0
2 changed files with 43 additions and 54 deletions

View file

@ -6,4 +6,4 @@ bun run db:migrate
# Start the application # Start the application
echo "Starting the application..." echo "Starting the application..."
./server ./serverg

View file

@ -1,59 +1,48 @@
import { Elysia } from "elysia"; import { Elysia } from "elysia";
import swagger from '@elysiajs/swagger'; import swagger from "@elysiajs/swagger";
import { ENV } from "./config/env";
import cors from "@elysiajs/cors"; import cors from "@elysiajs/cors";
import { ENV } from "./config/env";
import { api } from "./api"; import { api } from "./api";
const allowedOrigins = [ const app = new Elysia()
"http://localhost:5175", .use(
"http://localhost:5173", cors({
// allowed canvas backend (user) origins(for user) origin: [
"https://localhost:3001", "http://localhost:5175",
]; "http://localhost:5174",
"https://dashboard.planpostai.com",
const app = new Elysia({ "https://dev.dashboard.planpostai.com",
prefix: "", "https://canvas.planpostai.com",
tags: ["Default"], "https://canvasdev.planpostai.com",
})
.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"
}
], ],
} methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"],
})) allowedHeaders: [
.onError(({ code, error }) => { "Content-Type",
if (code === 'NOT_FOUND') "Authorization",
return 'Not Found :('; "X-Requested-With",
console.log("hello from app.ts under error"); "Accept",
console.error(error) "Origin",
}); "Access-Control-Allow-Origin",
],
// all routes here credentials: true,
app.use(api); })
)
app.listen(ENV.SERVER_PORT, () => { .get("/test", () => "Hello World", {})
console.log(`🦊 Elysia is running at ${ENV.SERVER_URL}:${ENV.SERVER_PORT}`) .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`);