// Import libraries const express = require('express') const dotenv = require('dotenv') const cors = require('cors') // Initialise dotenv to call environment variables dotenv.config() // Initialize an app instance const app = express() // Define port on which server should listen const PORT = 7777 || process.env.PORT // Call Express middlewares to avoid cors error, and enable transfer of json and form data to the server app.use(cors()) app.use(express.json()) app.use(express.urlencoded({extended:true})) // Send a get request app.get('/', (req, res) => { res.status(200).json({message : "Hello from ExpressJS"}) }) // Call listen method on the app instance app.listen(PORT, () => { console.log(`Listening on port ${PORT}`) })