tz-utils
v1.1.6
Published
A collection of utilities I use for my projects.
Downloads
32
Readme
tzUtils
tzUtils is a utility library I have made for the convinience of myself for the most part, but if you like it then that is cool!
If you see problems with any of my code please tell me in an issue!
You can install it by running npm i tz-utils
Documentation
tzUtils
connect(uri, privKey) ⇒ Void
sets tzUtils.Auth
to and initiallizes the class Auth
, and sets tzUtils.DB
to Mongoose.Connection
Kind: global function
Returns: Void
| Param | Type | Description | | --- | --- | --- | | uri | string | URI for connecting to mongodb. | | privKey | string | Private key or secret for the jsonwebtoken. |
timestampToTime(timestamp, options) ⇒ string
Takes in the unix time and displays a nice time for users.
Kind: global function
Returns: string
| Param | Type | Description |
| --- | --- | --- |
| timestamp | number | Unix timestamp. |
| options | object | Currently the only implemented option is isMDY
, which determines whether or not the date format is DDMMYYYY or MMDDYYYY |
tzUtils.Auth
login(email, password) ⇒ Promise<{success: boolean, code:number, token:string?}>
Registers the user with the provided information.
Kind: global function
Returns: Promise<{success: boolean, code:number, token:string?}> - A promise that resolves to the result of logging in.
| Param | Type | Description | | --- | --- | --- | | email | string | The user's email. | | password | string | the user's password. |
register(username, email, password) ⇒ Promise<{success: boolean, code:number, token:string?}>
Registers the user with the provided information.
Kind: global function
Returns: Promise<{success: boolean, code:number, token:string?}> - A promise that resolves to the result of the registration.
| Param | Type | Description | | --- | --- | --- | | username | string | The user's username. | | email | string | The user's email address. | | password | string | the user's password. |
verifyToken(token) ⇒ Object
Verify user token
Kind: global function
| Param | Type | Description | | --- | --- | --- | | token | string | User token to verify. |