Giter Site home page Giter Site logo

philippebeck / nemjs Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 688 KB

JavaScript Backend Services

License: Apache License 2.0

JavaScript 100.00%
javascript-library bcrypt dotenv grunt jwt nodemailer password-validator remove-accents sharp valid-url

nemjs's Introduction

nemjs

JavaScript Backend Service Library

NPM Version

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 :

  • getName(name) : get kebab-case name
  • getPosterName(name) : get image name for gallery cover
  • 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)) { ... }
    • const 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 : npm test
Yarn : yarn test

nemjs's People

Contributors

philippebeck avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.