midleware before responding to actual request middleware responds
in below middleware , we wil not pass params, it willl get automaticlly
const logger =(req,res,next)=>{}
const logger =()=>{
const method = req.method
const url = req.url
const time = new Date().getFullYear()
console.log(method,url,time)
next()
}
app.get('/'. logger, ()=>{})
app.get('/',logger, (req,res)=>{
res.send('HOME');
})
app.get('/',[logger,authorize], (req,res)=>{
res.send('HOME');
})
morgan
npm i morgan
it logs for every http request
require('morgan')
app.use(mogan('tiny'));
it brings from public folder
app.use(express.static(''./public));
app.use(express.static(''./methods-public));
if in this folder it has any files taht wil reflect ist
like login page
previously we imported individual pages like script, css, index but now we use one folder directly
so because of this it will will call after page loads
means login must for any page
get data into required file using api
after click submit do axios post
in request data there , if not there