2.0.1 • Published 3 years ago

jgchecker v2.0.1

Weekly downloads
-
License
GPL-3.0 License
Repository
github
Last release
3 years ago

jgChecker

jg-checker is able to check data types and generate valid tokens

What is verified?

You can use jg-checker to check data entry depending on your project, you can check data like

  • Number
  • String
  • Boolean
  • Function
  • Object
  • Array

Quick Start

$ npm i jg-checker
const jgChecker = require("jg-checker");

Available functions

Checking the types of variables

checkTypeOf.string(<string>);
// Responsible for checking if the type is a String
checkTypeOf.number(<number>);
// Responsible for checking if the type is a Number
checkTypeOf.object(<object>);
// Responsible for checking if the type is an Object
checkTypeOf.fun(<fun>);
// Responsible for checking if the type is a Function
checkTypeOf.boolean(<boolean>);
// Responsible for checking if the type is a Boolean
checkTypeOf.array(<array>);
// Responsible for checking if the type is an Array

Token generation

const token = token.sing({payload}, secret, time);

// payload - A valid json
// secret - A string so that your token is unique
// time (optional) - Time for the token to inspire

------------------------------------------------------

// console.log(token) == token -> string
token.verify(token)

/* 
You will be responsible for verifying the token, from its integrity until the expiration time 
*/

// If invalid, it will return an error
token.decode(token, secret)

/* decodes the token, allowing data to be taken, such as the payload used to generate */

Author

License

LICENSE