Created
February 15, 2023 09:23
-
-
Save WoolDoughnut310/d453b199fd9485c6f9ba7a0f8fbac1b9 to your computer and use it in GitHub Desktop.
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
require("dotenv").config(); | |
import { createServer } from "http"; | |
import next from "next"; | |
import express from "express"; | |
import { method2 } from "./lib/upload"; | |
const port = parseInt(process.env.PORT || "3000", 10); | |
const dev = process.env.NODE_ENV !== "production"; | |
const nextApp = next({ dev }); | |
const handle = nextApp.getRequestHandler(); | |
const app = express(); | |
const server = createServer(app); | |
app.use(express.json()); | |
(async () => { | |
await nextApp.prepare(); | |
app.post("/api/upload", (req, res) => { | |
method2(req, res); | |
}); | |
app.all("*", (req, res) => { | |
return handle(req, res); | |
}); | |
server.listen(port, () => { | |
console.log(`> Ready on http://localhost:${port}`); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment