update 00000
This commit is contained in:
parent
b9f369353d
commit
e1be753ce2
1 changed files with 42 additions and 34 deletions
42
src/app.ts
42
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,13 +16,23 @@ const app = new Elysia({
|
|||
prefix: "",
|
||||
tags: ["Default"],
|
||||
})
|
||||
.use(cors({
|
||||
.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"],
|
||||
allowedHeaders: [
|
||||
"Content-Type",
|
||||
"Authorization",
|
||||
"X-Requested-With",
|
||||
"Accept",
|
||||
"Origin",
|
||||
"Access-Control-Allow-Origin",
|
||||
],
|
||||
credentials: true,
|
||||
}))
|
||||
.use(swagger({
|
||||
})
|
||||
)
|
||||
.use(
|
||||
swagger({
|
||||
path: "/api/docs",
|
||||
documentation: {
|
||||
info: {
|
||||
|
|
@ -37,23 +47,21 @@ const app = new Elysia({
|
|||
},
|
||||
{
|
||||
name: "Uploads",
|
||||
description: "All APIs related to 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}`);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue