🔧 Node JS || Epress js || By Munisekhar Udavalapati
Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to
Express js
- to write simple express js application
npm init
npm install express
const express=require('expreass');
const app=express();
app.use('/',(req,res,next)=>{
rse.send('succuss');
})
app.listen(3000,()=>{
console.log('port 3000 is success');
});
2.write JWT token authentication.
npm install jsonwebtoken
const jwt=require('jsonwebtoken');
const newToken=jwt.sign({name:'sekhar',userId:'sekhar_32'},process.env.sec_jwt_key,{expiresIn:'5m'});
console.log(newToken);
const jwtVerify=jwt.verify(newToken,process.env.sec_jwt_key);
console.log(jwtVerify);
3.password encryption in node js
npm install bcrypt
const bcrypt=require('bcrypt');
const password='ex_password';
const hashPassword=bcrypt.hash(password);
const verifyPassword=bcrypt.compare(password,hashPassword);
console.log(verifyPassword); //true
4.node js status codes
404===>not found
401===>unauthorised
400===>bad requst
200===>ok
201===>create
202===>accepted
5.http methods
GET
PUT
POST
DELETE
6.clinet filse send
const path=require('path');
app.use('/',(req,req,next)=>{
res.sendFile(path.join(__dirname,'public','home.html'));
})
🔧 Node JS || Epress js || By Munisekhar Udavalapati
📈 105.63 Punkte
🔧 Programmierung
🔧 SQL || MySQL || By Munisekhar Udavalapati
📈 60.33 Punkte
🔧 Programmierung
🔧 Replace a Live Mongo Node With a New Node
📈 13.92 Punkte
🔧 Programmierung