Skip to content

Commit

Permalink
add server folder with initial index.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
deveshidwivedi committed Jun 18, 2024
1 parent 2e73dfc commit ce12a4f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions server/index.ts
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}`);
});
});

0 comments on commit ce12a4f

Please sign in to comment.