Skip to content

Instantly share code, notes, and snippets.

@N-Hidaya
Created July 20, 2023 07:52
Show Gist options
  • Save N-Hidaya/1a8c0ff2a7d1f45787415ec548581680 to your computer and use it in GitHub Desktop.
Save N-Hidaya/1a8c0ff2a7d1f45787415ec548581680 to your computer and use it in GitHub Desktop.
final code
const express = require('express')
const cors = require('cors')
const app = express();
const about = require('./routes/about')
//middleware for server
app.use(express.json());
//to make API publicly accessible
app.use(cors());
//Register router from about
app.use('/about', about)
app.get('/', (req, res) => {
res.json('Welcome to the API')
})
//Listen for a connection
const port = process.env.PORT || 5500;
app.listen(port, () => console.log(`Listening to Port: ${port}`))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment