update
This commit is contained in:
parent
bfa9fee43f
commit
f3aa472e7e
1 changed files with 14 additions and 35 deletions
49
src/app.ts
49
src/app.ts
|
|
@ -4,21 +4,15 @@ import cors from "@elysiajs/cors";
|
||||||
import { ENV } from "./config/env";
|
import { ENV } from "./config/env";
|
||||||
import { api } from "./api";
|
import { api } from "./api";
|
||||||
|
|
||||||
const allowedOrigins = [
|
const app = new Elysia()
|
||||||
"http://localhost:5175",
|
|
||||||
"http://localhost:5174",
|
|
||||||
"http://localhost:5173",
|
|
||||||
"https://dashboard.planpostai.com",
|
|
||||||
"https://canvas.planpostai.com",
|
|
||||||
];
|
|
||||||
|
|
||||||
const app = new Elysia({
|
|
||||||
prefix: "",
|
|
||||||
tags: ["Default"],
|
|
||||||
})
|
|
||||||
.use(
|
.use(
|
||||||
cors({
|
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"],
|
methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"],
|
||||||
allowedHeaders: [
|
allowedHeaders: [
|
||||||
"Content-Type",
|
"Content-Type",
|
||||||
|
|
@ -31,37 +25,22 @@ const app = new Elysia({
|
||||||
credentials: true,
|
credentials: true,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
.get("/test", () => "Hello World", {})
|
||||||
|
.use(api)
|
||||||
.use(
|
.use(
|
||||||
swagger({
|
swagger({
|
||||||
path: "/docs",
|
path: "/swagger",
|
||||||
documentation: {
|
documentation: {
|
||||||
|
openapi: "3.1.0",
|
||||||
info: {
|
info: {
|
||||||
title: "Canvas API",
|
title: "Canvas API",
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
description: "Canvas API Documentation",
|
description: "Canvas API Documentation",
|
||||||
},
|
},
|
||||||
tags: [
|
|
||||||
{
|
|
||||||
name: "Projects",
|
|
||||||
description: "All APIs related to Projects",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Uploads",
|
|
||||||
description: "All APIs related to Uploads",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.onError(({ code, error }) => {
|
.listen(ENV.SERVER_PORT);
|
||||||
if (code === "NOT_FOUND") return "Not Found :(";
|
|
||||||
console.log("hello from app.ts under error");
|
|
||||||
console.error(error);
|
|
||||||
});
|
|
||||||
|
|
||||||
// all routes here
|
console.log(`🦊 Elysia is running at ${ENV.SERVER_URL}`);
|
||||||
app.use(api);
|
console.log(`Swagger docs available at ${ENV.SERVER_URL}/swagger`);
|
||||||
|
|
||||||
app.listen(ENV.SERVER_PORT, () => {
|
|
||||||
console.log(`🦊 Elysia is running at ${ENV.SERVER_URL}:${ENV.SERVER_PORT}`);
|
|
||||||
});
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue