![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
larvituser
Advanced tools
User module for node.js
First fire up the library connections like this:
const userLib = require('larvituser');
userLib.dataWriter.mode = 'master'; // Used for standalone use. If multiple applications connect via rabbitMQ the other should be "slave"
Create a new user in the database, do like this:
const userData = {
'firstname': 'Nisse',
'lastname': 'Nilsson',
'role': [
'user',
'subscriber'
]
}
userLib.create('myUsername', 'myPassword', userData, function (err, user) {
console.log('New user UUID: ' + user.uuid);
});
To fetch a user from database based on username and password, do like this:
userLib.fromUserAndPass('myUsername', 'myPassword', function (err, user) {
if (err) {
throw err;
}
if ( ! user) {
// No match found, or other more serious error
} else {
console.log('Fetched user ID: ' + user.id);
}
});
List multiple users
const users = new userLib.Users();
users.get(function (err, userList) {
if (err) throw err;
console.log(userList); // An array of objects
});
Get distinct values for field from all users
const users = new userLib.Users();
users.getFieldData('fieldName', function (err, result) {
if (err) throw err;
console.log(userList); // An array of strings
});
userLib.addUserDataField(userUuid, fieldName, fieldValue, function (err) {
// Field have been added
});
userLib.checkPassword('passwordToTest', 'theHashToTestAgainst', function (err, result) {
// Result being either true or false
});
userLib.create('username', 'password', {'firstname': 'John', 'lastname': 'Smith'}, function (err, user) {
console.log(user.uuid); // 91f15599-c1fa-4051-9e0e-906cab9819fe (or rather, a random Uuid)
});
Or set an Uuid manually like this:
userLib.create('username', 'password', {'firstname': 'John', 'lastname': 'Smith'}, 'f9684592-b245-42fa-88c6-9f16b9236ac3', function (err, user) {
console.log(user.uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3
});
Will fetch the first occurance in the database with this field name and field value.
userLib.fromField('firstname', 'John', function (err, user) {
console.log(user.uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3
});
Will fetch the first occurance in the database that matches all these field names and field values
userLib.fromFields({'firstname': 'John', 'lastname': 'Smith'}, function (err, user) {
console.log(user.uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3
});
userLib.fromUsername('username', function (err, user) {
console.log(user.uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3 or user will be false if no user is found
});
userLib.fromUuid('f9684592-b245-42fa-88c6-9f16b9236ac3', function (err, user) {
console.log(user.uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3
});
userLib.getFieldData('f9684592-b245-42fa-88c6-9f16b9236ac3', 'firstname', function (err, data) {
console.log(data); // ['John'] - Observe this will always be an array with values, since a field can hold several values
});
IMPORTANT!!! Will clear all data not given in the fields parameter
userLib.replaceUserFields('f9684592-b245-42fa-88c6-9f16b9236ac3', {'lastname': ['Smith', 'Johnsson']}, function (err) {
// The field "lastname" will now be replaced with the two values "Smith" and "Johnsson"
// And all other fields will be removed
userLib.getFieldData('f9684592-b245-42fa-88c6-9f16b9236ac3', 'lastname', function (err, data) {
console.log(data); // ['Smith', 'Johnsson']
});
});
userLib.rmUserField('f9684592-b245-42fa-88c6-9f16b9236ac3', 'lastname', function (err) {
userLib.fromUuid('f9684592-b245-42fa-88c6-9f16b9236ac3', function (err, user) {
console.log(user.fields); // {'firstname': ['John']}
});
});
userLib.setPassword('f9684592-b245-42fa-88c6-9f16b9236ac3', 'newSuperSecretPwd', function (err) {
// Now the users password is updated to "newSuperSecretPwd"
});
To disable a login, use boolean false as the new password:
userLib.setPassword('f9684592-b245-42fa-88c6-9f16b9236ac3', false, function (err) {
// This user can no longer login
});
userLib.setUsername('f9684592-b245-42fa-88c6-9f16b9236ac3', 'theNewUsername', function (err) {
// Now the users username is updated to "theNewUsername"
});
Run tests with mocha, make sure to have an empty database configured for tests to pass correctly!
The default config file will be application path/config/db_test.json
Or a custom one can be used by running
mocha test/test.js /path/to/config/db_another.json
FAQs
User module for node.js
The npm package larvituser receives a total of 0 weekly downloads. As such, larvituser popularity was classified as not popular.
We found that larvituser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.