A package that helps debug in a more readable manner, by logging logged error and success message in the terminal in a well-formatted manner, which aids readability and helps in the separation of different logged responses as well as returning server success and error message in a general format throughout your codebase
This instructions will get you started on how to use this package.
- Nodejs
- npm (node package manager)
npm install v-response to install dependency
const response = require ("v-response");
response.log("this is an error: ", payemnterror);
response.log("payment successful: ", payemntsuccessful);
-------------------------------------------------------------------------------
this is an error: paymenterror
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
payment successful: payemntsuccessful
-------------------------------------------------------------------------------
app.get("/", (req, res) => {
let age = 1;
if (age < 2) {
return res.status(200)
.json(response.ApiResponse(true, 200, "yes age is less than 2", age));
}else {
return res.status(400)
.json(response.ApiResponse(false,400,"no age is not less than 2",undefined,error));
}
})
app.get("/generate_opt",(req,res) => {
//expecting two callback (size,true | false)
//if set to true numbers and letters will be generated
//if set to false only numbers will be generated
let Otp = response.generateOTCode(6,false);
response.log("OneTimePassword: ",Otp);
})
-------------------------------------------------------------------------------
OneTimePassword: 234574
-------------------------------------------------------------------------------
let Generate_jwt = response.signToken(payload,secret);
response.log("Jwt token:",Generate_jwt);
------------------------------------------------------------------------------
Jwt token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVlNTY1NWJlNzJkODVhMDk1MDUyNWFhOCIsImlhdCI6MTU4Mjc5MjQ1NX0.niULywaPIaF01vBNpgNaCeerSJt8xW3vlRWlqkmn0sQ
-------------------------------------------------------------------------------
let _hash_password = response.hashedPassword(req.body.password, 10);
response.log("Hashed password:",_hash_password);
-------------------------------------------------------------------------------
Hashed password: $2a$10$RwaB/O4KUm5tw6VIvVlNMeFblya1fEut4pHeWbvCkw9i/K.cl8iru
-------------------------------------------------------------------------------
- tycodez