update 00000

This commit is contained in:
smfahim25 2025-03-19 09:45:05 +06:00
parent b9f369353d
commit e1be753ce2

View file

@ -1,5 +1,5 @@
import { Elysia } from "elysia"; import { Elysia } from "elysia";
import swagger from '@elysiajs/swagger'; import swagger from "@elysiajs/swagger";
import { ENV } from "./config/env"; import { ENV } from "./config/env";
import cors from "@elysiajs/cors"; import cors from "@elysiajs/cors";
@ -16,44 +16,52 @@ const app = new Elysia({
prefix: "", prefix: "",
tags: ["Default"], tags: ["Default"],
}) })
.use(cors({ .use(
origin: allowedOrigins, cors({
methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"], origin: allowedOrigins,
allowedHeaders: ["Content-Type", "Authorization", "X-Requested-With", "Accept", "Origin", "Access-Control-Allow-Origin"], methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"],
credentials: true, allowedHeaders: [
})) "Content-Type",
.use(swagger({ "Authorization",
path: "/api/docs", "X-Requested-With",
documentation: { "Accept",
info: { "Origin",
title: "Canvas API", "Access-Control-Allow-Origin",
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"
}
], ],
} 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",
},
],
},
})
)
.onError(({ code, error }) => { .onError(({ code, error }) => {
if (code === 'NOT_FOUND') if (code === "NOT_FOUND") return "Not Found :(";
return 'Not Found :(';
console.log("hello from app.ts under error"); console.log("hello from app.ts under error");
console.error(error) console.error(error);
}); });
// all routes here // all routes here
app.use(api); app.use(api);
app.listen(ENV.SERVER_PORT, () => { app.listen(ENV.SERVER_PORT, "0.0.0.0", () => {
console.log(`🦊 Elysia is running at ${ENV.SERVER_URL}:${ENV.SERVER_PORT}`) console.log(`🦊 Elysia is running at ${ENV.SERVER_URL}:${ENV.SERVER_PORT}`);
}) });