How does nodejs separate the interface to another JS file to write?

clipboard.png
index.jsabout:

clipboard.png
JS express
:localhost:3000/about:

clipboard.png

Mar.13,2021

//
app.use('/about',require('./test.js'));
 app.use('/run',require('./run.js'));
 .....
 
//test.js
//
router=express.Router();
router.get('/',function(){..})///about/
router.get('/one',function(){..})///about/one

text.js

export default function(req,res){
    res.send('about');
}

in the main file

app.get('/about',require('./test.js'));

1. How to introduce
2 without require. The router of express understands


encapsulates the route into the router.js as an object export
app.js introduces router and use


you have no idea what the landlord is talking about. What the landlord means is that he does not want to put the interface code in server.js and wants to extract a file to store the interface code separately.
the landlord can declare an interface file of interface.js on the outside, then export the contents in the server.js, require ('interface') in the server.js, and then pass the app as a parameter

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a6a0-4079b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a6a0-4079b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?