node-simple-utilities
v1.3.55
Published
A nice boilerplate with unit tests, linting and code coverage.
Downloads
98
Readme
A Node.js collection model for mongoose stuff
TL;DR
Installation
npm install node-simple-utilities --save
Usage
It's easy. Import and use the utilities.
const { util } = require('node-simple-utilities');
const formatted = util.format(12345.6789, 2);
// 12 345,68
const { util } = require('node-simple-utilities');
const config = {
jwt: {
secret: 'I am a very secret secret!',
}
};
const jwtToken = util.makeJwtToken({ email: '[email protected]' }, config);
List of some useful functions
util
- format
- formatDate
- epoch
- cleanObject
- indexOf
- length
- makeJwtToken
- decodeJwtToken
- getApiObject
- getApiObjects
- mongoSanitize
- makeSearchObject
- oneline
- uc
utilHtml
- fixImageLinksWhiteSpace
- replaceMarked
- inlineImageSize
- replaceDataTags
- replaceAt
- dropFirstLetter
- dropFirstLetterAfterHr
- runPlugins
- cleanHtml
- mapNorwegianLetter
- stripTags
- asUrlSafe
- asHtmlIdSafe
- asLinkPart
- substring
- fixFilename
- removeLineBreaks
- match
utilExpress
- isDevelopment
- printIfDev
- restrict
- renderApi
- restrictAPI
- getConsoleColors
- lynxSafe
- logFunctionTimer
- getCommonTemplateValues
- resolveTemplate
- sendResultResponse
- renderPage
- renderError
- loadFile
I promise to add some more documentation, or if you want to help, please follow the instructions below.
Helper modules in use:
Jest A browser JavaScript testing toolkit. Jest is used by Facebook to test all JavaScript code including React applications. One of Jest's philosophies is to provide an integrated "zero-configuration" experience.
ESLint ESLint is a code style linter for programmatically enforcing your style guide.
Travis Travis CI is a hosted continuous integration service. It is integrated with GitHub and offers first class support for many languages.
Coveralls.io Coveralls is a web service to help you track your code coverage over time, and ensure that all your new code is fully covered.
Retire Scanner detecting the use of JavaScript libraries with known vulnerabilities.
Howto to get started with contributions
$ git clone [email protected]:5orenso/node-simple-utilities.git
$ cd node-simple-utilities/
$ npm install
Start developing. Remember to start watching your files:
$ npm run test:watch
HOWTO fix eslint issues
$ eslint --fix lib/utilities.js
Howto contribute
$ git clone [email protected]:5orenso/node-simple-utilities.git
Do your magic and create a pull request.
Howto report issues
Use the Issue tracker
Howto update CHANGELOG.md
$ bash ./changelog.sh
Howto update NPM module
- Bump version inside
package.json
- Push all changes to Github.
- Push all changes to npmjs.com:
$ bash ./npm-release.sh
.
Howto check for vulnerabilities in modules
# Install Node Security Platform CLI
$ npm install nsp --global
# From inside your project directory
$ nsp check
Howto upgrade modules
$ sudo npm install -g npm-check-updates
$ ncu -u -a
$ npm install --no-optional
Versioning
For transparency and insight into the release cycle, releases will be numbered with the follow format:
<major>.<minor>.<patch>
And constructed with the following guidelines:
- Breaking backwards compatibility bumps the major
- New additions without breaking backwards compatibility bumps the minor
- Bug fixes and misc changes bump the patch
For more information on semantic versioning, please visit http://semver.org/.
Contributions and feedback:
We ❤️ contributions and feedback.
If you want to contribute, please check out the CONTRIBUTING.md file.
If you have any question or suggestion create an issue.
Bug reports should always be done with a new issue.
Other Resources
- Node.js utilities
- Node.js Preact utilities
- Node.js Preact Mobx storemodel
- Node.js boilerplate for Express
- Node.js boilerplate for modules
- Node.js boilerplate for Preact