-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add server folder with initial index.ts
- Loading branch information
1 parent
2e73dfc
commit ce12a4f
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { createServer } from "http"; | ||
|
||
import express from "express"; | ||
import next, { NextApiHandler } from "next"; | ||
|
||
const port= parseInt(process.env.PORT || "3000", 10); | ||
const dev = process.env.NODE_ENV !== "production"; | ||
const nextApp= next({ dev }); | ||
const nextHandler= nextApp.getRequestHandler(); | ||
|
||
nextApp.prepare().then(async() =>{ | ||
const app= express(); | ||
const server= createServer(app); | ||
|
||
app.all("*", (req, res) => nextHandler(req, res)); | ||
server.listen(port, () =>{ | ||
console.log(`Server is ready on ${port}`); | ||
}); | ||
}); |