DEV Community

Cover image for Node JS || Epress js || By Munisekhar Udavalapati
Munisekhar Udavalapati
Munisekhar Udavalapati

Posted on

1

Node JS || Epress js || By Munisekhar Udavalapati

Express js

  1. 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');
});
Enter fullscreen mode Exit fullscreen mode

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);
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

4.node js status codes

404===>not found
401===>unauthorised
400===>bad requst
200===>ok
201===>create
202===>accepted
Enter fullscreen mode Exit fullscreen mode

5.http methods

GET
PUT
POST
DELETE
Enter fullscreen mode Exit fullscreen mode

6.clinet filse send

const path=require('path');
app.use('/',(req,req,next)=>{
 res.sendFile(path.join(__dirname,'public','home.html'));
})
Enter fullscreen mode Exit fullscreen mode

SurveyJS custom survey software

Build Your Own Forms without Manual Coding

SurveyJS UI libraries let you build a JSON-based form management system that integrates with any backend, giving you full control over your data with no user limits. Includes support for custom question types, skip logic, an integrated CSS editor, PDF export, real-time analytics, and more.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs