Created
October 28, 2022 14:54
-
-
Save WoolDoughnut310/0168138d3b01f35b52ddf7705acde44e 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
import dotenv from "dotenv"; | |
dotenv.config(); | |
import express, { Request, Response } from "express"; | |
import { connectToServer } from "./db"; | |
const app = express(); | |
const port = 3000; | |
app.use(express.json()); | |
app.use(express.urlencoded({ extended: true })); | |
app.get("/", (req, res) => { | |
res.send("Hello World!"); | |
}); | |
app.use((err: Error, req: Request, res: Response) => { | |
res.status(500).json({ message: err.message }); | |
}); | |
connectToServer().then(async () => { | |
app.listen(port, () => { | |
return console.log(`Express is listening at http://localhost:${port}`); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment