This project is made to be used in Dixeed's projects thus its configuration may not suit every needs.
- Nodejs >= 6.11.4
const utils = require('@dixeed/backend-utils');
utils.init({
algorithm: 'SHA1',
media: {
publicImgFolder: 'public/images',
publicFileFolder: 'public/files',
}
});
// Once initialized, you can use every utility functions within this helper.
utils.crypto.getSecuredHash(3, 'mydata');
// ...
This method initializes the helper. You cannot use it without calling the init() method first.
The config
parameter is as follow:
{
"algorithm": "", // The default algorithm used by the crypto methods.
"media": {
"publicImgFolder": "", // Path to the folder into which save images.
"publicFileFolder": "", // Path to the folder into which save files.
}
}
Generates a cryptographic hash.
seedSize - integer - Size of the seed used for the hash generation. data - string -The data to be added to the hash. algorithm - string - (optional) The algorithm to use for creating the hash. Will override the default algorithm set in the config.
return a Promise containing the generated hash.
Constructor for a Mailer object. The transporterOpts parameter is as follow:
{
"port": 322,
"host": "mail.provider.net",
"secure": false,
"auth": {
"user": "my.email@domain.com",
"pass": "*********"
}
}
The mailer object resulting from the instanciation has a sendMail() method. The sendMail() method return a Promise object. See the nodemailer sendMail documentation for information on the mailer.sendMail(opts)
Creates an image from the provided stream at the path relative to the base path provided in the init() config. options parameter:
{
"addTimestamp": true, // Adds the current timestamp to the filename
"ext": null // Custom extension for the image
}
return a Promise containing the path of the image.
Creates a file from the provided stream at the path relative to the base path provided in the init() config. options parameter:
{
"addTimestamp": true, // Adds the current timestamp to the filename
"ext": null // Custom extension for the file
}
return a Promise containing the path of the file.
Deletes a file located at the provided relative path. The base path is the one set in the init() config.
return a Promise.
Create an archive from a list of path.
archiveName - string - Archive name directoryPath - string - Path to the directory where to create the archive paths - Array - File paths array log - function - logger function
return a Promise containing the path of the archive.
Compile a Handlebar template and inject the provided data in it and generate an HTML output.
return a Promise containing the compiled html.
For more detail on the template, see the Handlebars documentation
It is a simple object containing common Joi validators for request validation. Implementation detail:
{
"id": Joi.number().integer().min(1).required(),
"fileName": Joi.string().required(),
}
This project uses semantic-release to automatically handle semver bumps based on the commits messages.
To simplify commits messages redaction you can use npm run cm
instead of git commit
. To use that command make sure to git add
your changes before.
This repo is configured to forbid commit messages that do not follow the Angular conventional changelog commit message format.