You can separate the routes by file. To do this create a new Router
in the new archive and refer to your main route archive:
app js.
const express = require('express');
const app = express.Router();
const notas = require('../api/notas');
app.use('/notas', notas);
js.
const express = require('express');
const router = express.Router();
const get = async (req, res) => {
res.jsonp({ mensagem: 'OK' });
}
router.get('/', get);
module.exports = router;
Router
The router Object is an Isolated instance of middleware and Routes. You can think of it as a "mini-application", capable only of Performing middleware and routing functions. Every Express application has a built-in app router.
In free translation:
A router object is an isolated instance of middleware and routes. You can think of it as a "mini application", capable only of performing middleware function and routing. Every Express app has a built-in app router.