What is hacken?
Hacken is a node module to help people in hackathons, it has almost all the common features a person needs from database operations to sockets. If you are the one who struglles with MongoDb ObjectId, hacken makes it easier to work with then too.
Contents
- Object Functions
- JWT Functions
- MongoDb Connection
- User Functions
- Create Docker Image
- Socket Function
Object Functions
isObjValid
To Check if ObjectId is valid.
var hacken = ; ifhacken console;else console;
toObjId
To convert a ObjectId string to underlying ObjectId.
var hacken = ; try var objid = hacken;catche console;
arrObjMap
To get some specific values of properties from an array of objects.
var hacken = ; var arr = ele1:"one"ele2:"two"ele1:"1"ele2:"2"; var prop = "ele1"; //specify properties which you want to get from an array. var res = hacken; //res = ["one","1"];
JWT Functions
issueToken
To Issue A Json Web Token.
var hacken = ; var data = "hello hacken"; var secret = "adsasdAFD5454asdasd5Basasdajsdb46555654d656464N15465as4d6546546a"; var time = "5d"; //time can be given in 'd' for days without any suffix means seconds eg: 1100 for 1100 seconds. try hacken;catche console;
verifyToken
To Verify a Json Web Token.
var hacken = ; var token = reqparamstoken; var secret = "adsasdAFD5454asdasd5Basasdajsdb46555654d656464N15465as4d6546546a"; //same as the one provided before. try hackencatche console;
decodeToken
To Decode the token.
var hacken = ; try hacken;catcherr console;
MongoDb Connection
mongoConnect
To Connect To MongoDb.
var hacken = ; var url = "mongodb://localhost:27017/db"; //replace with your url hacken
User Functions
Following Properties Are allowed in User Model:
- username
- password
- phoneno
- name
- age
- address
var object = username:"value"password:"value"phoneno:"value"email:"value"name:"value"age:"value"address:"value"; //These objects can also take subset of the above mentioned properties. //Example: var object = username:"value"password:"value"phoneno:"value";
userCreate
To Create The User.
var hacken = ; hacken;
userRemove
To Remove the user.
var hacken = ; hacken;
userLogin
To Log user in.
var hacken = ; hacken;
userUpdate
To Update The User, Requires the same object with properties as used while creating the user.
var hacken = ; //Do Not Provide Password While updating as passwords are encrypted while storing. hacken;
userFindByUsername
To Find the user by username.
var hacken = ; hacken;
userFindByName
To Find users by name.
var hacken = ; hacken;
userFindById
To Find user by ObjectId.
var hacken = ; hacken
msgFind
To Fetch messages of a room. //For Now roomid = "broadcast".
var hacken = ; hacken;
roomFind
To Find all the chatrooms a user is associated to.
var hacken = ; var username = reqbodyusername; var page = reqbodypagenum; //to paginate the response as there can be many chat rooms for a user. var length = reqbodynumrooms; //to specify the number of chatrooms per page. hacken;
DockerImage
dockerImgCreate
To Create a dockerimage for your project, Dockerimage will be created in your root directory.
var hacken = ; var port = 3000; //port on which your node server will run. var servfile = appjs; //your start file. hacken
Socket Functions
For Now hacken only supports group chat.
socketFunction
To Create socket server, call the below function in your start file.
var hacken = ; var app = ; var http = ; var server = http; hacken; server;