nemjs

2.0.0 • Public • Published

nemjs

NPM Version

JavaScript Backend Service Library

NPM Downloads GitHub Last Commit

Codacy Badge Maintainability

GitHub Top Language Code Size

Overview

nemjs is a JavaScript Backend Service Library.
You will find some Services about Checkers, Getters & Setters
Auth services are using JWT & bcrypt
Mail services are using nodemailer
Image services are using sharp

Summary


Package

NPM : npm i nemjs
Yarn : yarn add nemjs


Download

Latest Release
or
git clone https://github.com/philippebeck/nemjs.git
or
Master ZIP


Content

Checkers part :

  • checkAuth(req, res, next) : check JWT auth to routes
  • checkEmail(email) : check email validity
  • checkPass(pass) : check password validity
  • checkRange(value, min, max) : check number|string range with min/max
  • checkUrl(url) : check url validity

Getters part :

  • getArrayFromString(string) : get array from string
  • getName(name) : get kebab-case name
  • getPosterName(name) : get image name for gallery cover
  • getUniqueName(name) : get unique name with timestamp
  • getMailer() : get mailer with nodemailer
  • getMessage(message) : get message
  • getPassword() : get generated password

Setters part :

  • setAuth(pass, user, res) : set JWT
  • setImage(inputImg, outputImg, width, height) : set image
  • setThumbnail(inputImg, outputImg, width, height) : set thumbnail

Usage

  1. Copy the .env.example file to your project root, rename it .env & replace values with your own values
  2. Add const nem = require("nemjs") where you need (file or function top level)
  3. Then use it like in these examples :
    • router.get("/", nem.checkAuth, UserCtrl.list)
    • nem.setAuth(guest.password, user, res)
    • if (nem.checkEmail(guest.email)) { ... }
    • if (nem.checkRange(guest.name)) { ... }
    • if (nem.checkPass(guest.password)) { ... }
    • let pass = nem.getPassword();
    • if (nem.checkUrl(item.url)) { ... }
    • nem.setImage(uploadImage, newImage);
    • nem.setThumbnail(uploadImage, newImage);
    • const mailer = nem.getMailer()
    • let message = nem.getMessage(req)

Tests

You can run unit tests with Jest : npm test -- --coverage

Package Sidebar

Install

npm i nemjs

Weekly Downloads

67

Version

2.0.0

License

Apache-2.0 License

Unpacked Size

51.3 kB

Total Files

13

Last publish

Collaborators

  • philippebeck