From e1be753ce265a7a40a906897bab00c447d8174f1 Mon Sep 17 00:00:00 2001 From: smfahim25 Date: Wed, 19 Mar 2025 09:45:05 +0600 Subject: [PATCH] update 00000 --- src/app.ts | 76 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/src/app.ts b/src/app.ts index fda8f87..98e2661 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,5 +1,5 @@ import { Elysia } from "elysia"; -import swagger from '@elysiajs/swagger'; +import swagger from "@elysiajs/swagger"; import { ENV } from "./config/env"; import cors from "@elysiajs/cors"; @@ -16,44 +16,52 @@ 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" - } + .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", + }, + ], + }, + }) + ) .onError(({ code, error }) => { - if (code === 'NOT_FOUND') - return 'Not Found :('; + if (code === "NOT_FOUND") return "Not Found :("; console.log("hello from app.ts under error"); - console.error(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}`) -}) - - +app.listen(ENV.SERVER_PORT, "0.0.0.0", () => { + console.log(`🦊 Elysia is running at ${ENV.SERVER_URL}:${ENV.SERVER_PORT}`); +});