Librairies disponibles
Les librairies suivantes sont disponibles dans les nœuds Code via l'objet libs.
adm-zip
Une bibliothèque pour manipuler les fichiers ZIP.
const zip = new libs.admZip();
zip.addFile('file.txt', Buffer.from('content'));
const zipBuffer = zip.toBuffer();
ajv
Validateur de schéma JSON (JSON Schema Validator).
const schema = {
type: 'object',
properties: {
name: { type: 'string' }
}
};
const validate = libs.ajv.compile(schema);
const valid = validate({ name: 'test' });
axios
Un client HTTP basé sur les Promises.
const response = await libs.axios.get('https://api.example.com/data');
base64
Encodeur/Décodeur Base64.
const encoded = libs.base64.encode('Hello World');
const decoded = libs.base64.decode(encoded);
cheerio
Une implémentation du cœur de jQuery pour le serveur.
const $ = libs.cheerio.load('<html>...</html>');
const title = $('title').text();
convertUnits
Une bibliothèque pour la conversion et la manipulation d'unités.
const converted = libs.convertUnits(100).from('kg').to('lb');
crypto
Le module cryptographique natif de Node.js.
const hash = libs.crypto.createHash('sha256').update('data').digest('hex');
dayjs
Une bibliothèque pour la manipulation des dates.
const now = libs.dayjs();
const formatted = libs.dayjs().format('YYYY-MM-DD');
const tomorrow = libs.dayjs().add(1, 'day');
escapeHtml
Échappe les caractères HTML dans une chaîne de caractères.
const escaped = libs.escapeHtml('<script>alert("xss")</script>');
fastcsv
Un module pour l'analyse (parsing) de fichiers CSV.
const csv = libs.fastcsv.parse(csvString, { headers: true });
file
Retourne un "FILE_TOKEN+key".
const fileToken = libs.file('my-key');
google.authLibrary.JWT
Client JWT pour Google OAuth2.
const jwt = new libs.google.authLibrary.JWT({
email: 'service-account@project.iam.gserviceaccount.com',
key: privateKey,
scopes: ['https://www.googleapis.com/auth/cloud-platform']
});
google.PubSub
Client pour Google Cloud Pub/Sub.
const pubsub = new libs.google.PubSub();
const topic = pubsub.topic('my-topic');
await topic.publishMessage({ data: Buffer.from('message') });
google.sheetsV4
API Google Sheets v4.
const sheets = libs.google.sheetsV4({ auth: jwtClient });
const response = await sheets.spreadsheets.values.get({
spreadsheetId: 'spreadsheet-id',
range: 'Sheet1!A1:B2'
});
js2xml
Conversion de JavaScript (JS) en XML.
const xml = libs.js2xml({ root: { item: 'value' } });
json2xml
Conversion de JSON en XML.
const xml = libs.json2xml({ root: { item: 'value' } });
JSONWebToken
Crée et vérifie des JSON Web Tokens (JWT).
const token = libs.JSONWebToken.sign({ userId: 123 }, 'secret', { expiresIn: '1h' });
const decoded = libs.JSONWebToken.verify(token, 'secret');
lodash
Une bibliothèque d'utilitaires JavaScript.
const result = libs.lodash.map([1, 2, 3], n => n * 2);
const grouped = libs.lodash.groupBy(users, 'department');
md5
Calcule le hash MD5 d'une chaîne de caractères.
const hash = libs.md5('my-string');
oauth1
Autorisation de requêtes avec OAuth 1.0a.
const oauth = libs.oauth1({
consumer: { key: 'consumer-key', secret: 'consumer-secret' },
signature_method: 'HMAC-SHA1'
});
turndown
Une bibliothèque pour transformer du HTML en Markdown.
const markdown = libs.turndown.turndown('<h1>Hello</h1>');
utf8
Encodeur/Décodeur UTF-8.
const encoded = libs.utf8.encode('Hello World');
const decoded = libs.utf8.decode(encoded);
uuid
Génère un UUID v4 aléatoire.
const id = libs.uuid();