New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cng-node-js-utils

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cng-node-js-utils

for nodejs utils in server

  • 0.0.3
  • npm
  • Socket score

Version published
Weekly downloads
13
decreased by-27.78%
Maintainers
1
Weekly downloads
 
Created
Source

lib utils for nodejs include post, get, ip, ldap, token, waiting, validators

install

npm i cng-node-js-utils

index.js of this libs

const {
  expHandlers,
  validators,
  arrObj,
  dateUtil,
  excelUtils,
  expUtil,
  htmlUtil,
  ipInfo,
  jsEncrypt,
  ldapLogin,
  myDevice,
  pdfUtil,
  postHandler,
  qrCodeUtil,
  rsaService,
  Router,
  secretUtil,
  sendGmail,
  uniqueid,
  vnHandler,
  waiting,
  webService,
} = require("cng-node-js-utils")

console.log("This time:", arrObj.getTimestamp());

Send Gmail by API very easy:

  const { sendGmail } = require("cng-node-js-utils");
  sendGmail((receiver, subject, content, senderGmail, passGmail, fromEmail, host = 'smtp.gmail.com', port = 465, secure = true)
  .then(ok=>console.log(ok))
  .catch(err=>console.log(err))

Use LDAP following:

// define your config to your ldap server
const ldapCfg = {
    ldapServerUrl: 'ldap://<host ip or host name>:389'
    , domainNameEmail: '@<your domain name>'
    , connectTimeout: `<timeout when ldap server not response>`
};
// init your connection
const ldapLogin = new LDAPLogin(ldapCfg.ldapServerUrl, ldapCfg.domainNameEmail, ldapCfg.connectTimeout);
// for verify LDAP
let user = await ldapLogin.login(user.username, passHash);
// if error no user return;

Use Router following:

// in this library:
const { postHandler, Router } = require("cng-node-js-utils");

// user custom class or functions:
const { serverHandler } = require("../../handlers/server")

const functionPaths = {
   // for POST method
    POST: {
        "/test": [
            postHandler.jsonProcess        
            , serverHandler.getUserDevice   
        ],
        //...
    },
    // for GET method:
    GET: {
        "/test": [
            postHandler.getToken              // return reg.token
            , serverHandler.verifyToken       // return req.user or req.error
            , serverHandler.getResource       // web response
        ],
        //...
    },
}
// export router of Express the same old version
module.exports = (new Router(functionPaths)).getExpressRouter();

Keywords

FAQs

Package last updated on 13 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc