Skip to content

Instantly share code, notes, and snippets.

@N-Hidaya
Created July 20, 2023 07:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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