Skip to content

Commit 4990906

Browse files
committed
add vercel deployment for backend
1 parent 76c0242 commit 4990906

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

backend/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
STANDALONE="true"

backend/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ yarn-error.log*
4141
**/*.log
4242
package-lock.json
4343
**/*.bun
44-
*.exe
44+
*.exe
45+
.env

backend/src/__tests__/routes/hc.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "bun:test";
2-
import { app } from "../..";
2+
import app from "../..";
33

44
describe("/hc", () => {
55
it("returns Server is healthy", async () => {

backend/src/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
33
import { Elysia } from "elysia";
44
import { appRouter } from "./trpc/routers";
55

6-
export const app = new Elysia()
6+
const app = new Elysia()
77
.use(cors())
88
.get("/hc", () => {
99
return {
@@ -19,11 +19,16 @@ export const app = new Elysia()
1919
return {};
2020
},
2121
});
22-
})
23-
.listen(process.env.PORT ?? 1337);
22+
});
23+
24+
if (process.env.STANDALONE === "true") {
25+
app.listen(process.env.PORT ?? 1337);
2426

25-
if (process.env.NODE_ENV === "test") {
26-
console.log(`Backend is running at ${app.server?.hostname}:${app.server?.port}`);
27+
if (process.env.NODE_ENV !== "test") {
28+
console.log(`Backend is running at ${app.server?.hostname}:${app.server?.port}`);
29+
}
2730
}
2831

32+
export default app;
33+
2934
export type AppRouter = typeof appRouter;

backend/vercel.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "https://openapi.vercel.sh/vercel.json",
3+
"rewrites": [
4+
{
5+
"source": "/(.*)",
6+
"destination": "/src"
7+
}
8+
]
9+
}

0 commit comments

Comments
 (0)