Node useful libraries
This post contain useful libraries that I got recommended in courser/post/videos.
This is a library to manage all crypto for passwords. wiki
To install with npm:
npm i bcrypt
a basic use with node 12.xx could be:
const bcrypt = require('bcrypt');
const saltRounds = 10;
const myPlaintextPassword = 'bla1234!D';
const otherPlaintextPassword = 'not_bacon';
async function savePassword(saltRounds, plaintextPassword) {
const salt = await bcrypt.genSalt(saltRounds);
const hashPassword = await bcrypt.hash(myPlaintextPassword, salt);
// await saveInDataBase(hashPassword)
}
savePassword(saltRounds, myPlaintextPassword);
Moment.js it's a library to manege date in easy way.
To install moment.js
npm install moment
moment.js give us a unique object to manipulate/show/parser dates, for example:
const moment = require('moment');
const today = moment();
console.log(today.format('Do - MMMM'));
sharp.js is a optimize library to manipulate with images (png/jpeg).
npm i sharp
const sharp = require('sharp');
sharp(inputBuffer)
.resize(320, 240)
.toFile('output.webp', (err, info) => { ... });