npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@less-is-more/less-js

v1.4.41

Published

Fast develop kit for nodejs

Downloads

461

Readme

lim-js

Introduction

A quick utility library for Node.js and JavaScript, designed to simplify tasks with minimal code. Contact: [email protected]

Installation

npm install @less-is-more/less-js

Getting Started

  1. Generate database mapping objects using sequelize-automatic. Please refer to its official npm documentation for details.
  2. Create an index.js file under the src directory. You can refer to the following example:
    const { Router, Db, Redis } = require("@less-is-more/less-js");
    const ApiController = require("./api/api-controller");
    const process = require("process");
    
    exports.init = (context, callback) => {
      Db.init(
        process.env.dbHost,
        process.env.dbDatabase,
        process.env.dbUser,
        process.env.dbPassword
      );
      Redis.init(process.env.redisUrl, "default", process.env.redisPassword);
      callback(null, "");
    };
    
    exports.handler = (req, res, context) => {
      res.setHeader("content-type", "application/json");
      const targets = {
        "/api": new ApiController(),
      };
      Router.route(targets, req, res, context);
    };
  3. Automatically generate CRUD operations. Execute the following command in the root of the project and select the database table:
    less-js-gen

Features

Each function has specific documentation for its parameters, which will not be repeated here.

Route

Simple routing, usually placed in the entry function index. In the Controller, you need to execute send or directly return a value (the value will be automatically converted to text to meet the send standard).

// ProductController is a class implementation
let targets = {
  "/product": ProductController,
  "/order": OrderController,
};
Router.route(targets, req, res);

Cache

Caching returns data if available, otherwise calls a function and saves the result. Uses Redis for caching and requires initialization. No annotations are used, allowing for quick testing with Mocha.

const { Cache, Redis } = require("@less-is-more/less-js");
// Initialize once, can be placed in a common area
Redis.init("address", "username", "password");

let testFunction = (a, b) => {
  console.log(a + b);
  return a + b + "";
};
// Call
const result = await Cache.get("test", 20, testFunction, testFunction, 1, 2);

Db

Currently supports MySQL. Uses Sequelize; refer to the official documentation for objects and query methods.

const { Db } = require("@less-is-more/less-js");
// Initialize once, can be placed in a common area
Db.init("address", "database", "user", "password");
// Simple query
let data = await Db.find(Menu, { ordering: "1" });
// With pagination
let data = await Db.find(Menu, { ordering: "2" }, [["id", "desc"]], 2, 3);
// Specify return columns
let data = await Db.find(Menu, { ordering: "0" }, [["id", "desc"]], 1, 10, [
  "id",
]);
// Add, Product is a generated object, refer to sequelize-automate
Db.add(Product, {
  code: "test",
  name: "product",
});
// Update
Db.update(Menu, { name: "test name2", ordering: "2" }, { id: 7 });
// Delete, limited to one record
Db.delOne(Menu, { code: "abc" });

Redis

Simple encapsulation. Commands are the same as the official ones.

const { Redis } = require("@less-is-more/less-js");
// Initialize once, can be placed in a common area
Redis.init("address", "username", "password");
// Execute command, call official command, parameter order is the same
let result = await Redis.exec("get", "test");

Param

Parameter handling tool. Checks parameters, throws an Error on failure, returns a parameter set on success. Primarily uses methods from the validator package: https://www.npmjs.com/package/validator. The check method adds isNotEmpty and require. Supports multiple checks, separated by spaces. By default, is methods do not include empty values.

let params = await Param.checkParams([
  ["return parameter key", value, "isNotEmpty", "error message"],
  ["return parameter key2", value2, "isNotEmpty", "error message2"],
]);
// Check if empty
Param.isBlank(value);

Sms

Currently supports Alibaba Cloud's SMS service.

// Initialize once, can be placed in a common area
Sms.init("key", "secret", "token");
Sms.debug(true);
Sms.send("phone number", { info: "SMS parameters" }, "signature", "SMS code");