@nyeduhu/nyedu-login-with-mongoose

**Initializting:** ```js const mlwm = require('@nyeduHu/nyedu-login-with-mongoose');

Usage no npm install needed!

<script type="module">
  import nyeduhuNyeduLoginWithMongoose from 'https://cdn.skypack.dev/@nyeduhu/nyedu-login-with-mongoose';
</script>

README

Register, login with Mongoose

Features:

Initializting:

 const mlwm = require('@nyeduHu/nyedu-login-with-mongoose');

 mlwm.init("localhost:27017", "test");   

Getting all users:

 const mlwm = require('@nyeduHu/nyedu-login-with-mongoose');

 mlwm.init("localhost:27017", "test"); 
 
 mlwm.getAll((result) => {
     console.log(`Current user(s): \n`);
     result.forEach(u => {
         console.log(u.username)
     });
 })

Registering a user:

 const mlwm = require('@nyeduHu/nyedu-login-with-mongoose');

 mlwm.init("localhost:27017", "test");   
 
 mlwm.register("nyedu", "nyedu@country.com", "strongpasswordrighthere", (error, res) => {
     if(error) return console.log(error);
     console.log("aa")
     return console.log(res);
 });

Logging into a user:

 const mlwm = require('@nyeduHu/nyedu-login-with-mongoose');

 mlwm.init("localhost:27017", "test");
 
 mlwm.login("nyedu", "strongpasswordrighthere", (error, res) => {
     if(error) return console.log(error);
 
     return console.log(res);
 }) 

Example code:

const mlwm = require('@nyeduHu/nyedu-login-with-mongoose');

mlwm.init("localhost:27017", "test");

setTimeout(() => {
    mlwm.register("nyedu", "nyedu@country.com", "strongpasswordrighthere", (error, res) => {
        if(error) return console.log(error);
        console.log("aa")
        return console.log(res);
    });
}, 500);

setTimeout(() => {
    mlwm.login("nyedu", "strongpasswordrighthere", (error, res) => {
        if(error) return console.log(error);
    
        return console.log(res);
    }) 
}, 1000);

mlwm.getAll((result) => {
    console.log(`Current user(s): \n`);
    result.forEach(u => {
        console.log(u.username)
    });
})

Check out my other project too!