Skip to content

Commit 006e4c5

Browse files
committed
feat: add server setup with HTTP handling and Next.js integration
1 parent b4d4f79 commit 006e4c5

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"prettier-plugin-tailwindcss": "^0.6.14",
3535
"prisma": "6.12.0",
3636
"tailwindcss": "^4.1.11",
37-
"typescript": "5.8.3"
37+
"typescript": "5.8.3",
38+
"tsx": "^4.20.3"
3839
}
3940
}

server.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { createServer } from "http";
2+
import next from "next";
3+
import { parse } from "url";
4+
5+
process.env.TURBOPACK = "1";
6+
const nodeEnv = process.env.NODE_ENV || "development";
7+
8+
const port = parseInt(process.env.PORT || "3000", 10);
9+
const dev = nodeEnv !== "production";
10+
const app = next({ dev, turbopack: true });
11+
const handle = app.getRequestHandler();
12+
13+
app.prepare().then(() => {
14+
createServer((req, res) => {
15+
const parsedUrl = parse(req.url!, true);
16+
handle(req, res, parsedUrl);
17+
}).listen(port);
18+
19+
console.log(
20+
`> Server listening at http://localhost:${port} as ${
21+
dev ? "development" : nodeEnv
22+
}`
23+
);
24+
});

tsconfig.server.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"outDir": "dist",
6+
"lib": ["es2019"],
7+
"target": "es2019",
8+
"isolatedModules": false,
9+
"noEmit": false
10+
},
11+
"include": ["server.ts"]
12+
}

0 commit comments

Comments
 (0)