How to make a simple Express.js app
Making an Express.js app is very easy, and only requires the code below. We also recommend securing your application with various headers which can be found in our articles.
Basic code:
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
You can run your app with:
node index.js
And that's it!