Модель маршрутизатора Nodejs
const express = require('express');
const router = express.Router();
// Get to home controller req and res function
router.get('/', app.home);
//---- Inside controller.js
const home = (req, res) => {
res.setHeader('Cache-Control', 'no-cache');
res.status(200).json({
status: 'Ok'
});
};
//----
// NOT FOUND Middleware
router.use((req, res) => {
res.status(404).json('not found');
});
module.exports = router;
Kamyab Rouhifar