Created
December 8, 2022 15:39
-
-
Save kom50/d8ba5f3b60cdd622d5df8e23b8c41604 to your computer and use it in GitHub Desktop.
How to create server in express JS
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 express, { Express, Request, Response } from 'express'; | |
import dotenv from 'dotenv'; | |
import bodyParser from 'body-parser'; | |
dotenv.config(); | |
const app: Express = express(); | |
const PORT = process.env.PORT || 5000; | |
app.use(express.json({ limit: '50mb' })); | |
app.use(bodyParser.urlencoded({ extended: true, limit: '50mb' })) | |
app.get('/', (req: Request, res: Response) => { | |
res.send('<h1>Express + TypeScript Server</h1>'); | |
}); | |
app.listen(PORT, () => { | |
console.log(`🚀 Server is running at https://localhost:${PORT}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment