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 🙏

© 2024 – Pkg Stats / Ryan Hefner

mall-wu-jiang

v1.0.8

Published

UTIL CONfig.js 一、 // token 秘钥 const secret = 'zxcvbnm123456'

Downloads

9

Readme

UTIL CONfig.js 一、 // token 秘钥 const secret = 'zxcvbnm123456'

//白名单

const whiteList = [/^\/myweb/,'/goods/type','/goods/detail','/goods/list',/^\/phone/,];


module.exports = {
    secret,
    whiteList
}

二、 IORedis.js const Redis = require('ioredis'); const redis = new Redis()

 function get(key) {
     return redis.get(key)
 }

 function set(key, time,val) {
     return redis.setex(key, time,val);
 }

 module.exports = {
     get,set
 }

三、 Jwt var jwt = require('jsonwebtoken'); var {secret} = require('./config'); // const secret = 'zxcvbnm123456'

// class JWT {
//     constructor(parameter) {
//     }
//      sign(userinfo) {
//         return jwt.sign(userinfo, secret, { expiresIn: '2h'})
//     }
//      verify(token) {
//         return jwt.verify(token, secret)
//     }
// }
function sign(userinfo) {
    return jwt.sign(userinfo, secret, { expiresIn: '2h'})
}
function verify(token) {
    return jwt.verify(token, secret)
}


module.exports = {
    sign,
    verify
}

List of goods

    const query = require('../db/query');

    //查询二级分类

    const selectType = ()=>{
        let sql = `select * from type_tab`;
        return query(sql)
    }

    //查询商品
    const selectGoods = (params)=>{
        /* 
            typeid  二级分类
            title  标题  模糊查询
            goodsid 商品 id   
            page count   分页查询
        */
        let sql = `select * from goods_tab `;

        if (params?.typeid || params?.title || params?.goodsid || params?.brandid ) {
            sql += ' where '
            
        }
        //根据分类查询
        if (params?.typeid ) {
            sql += ` typeid = ${params.typeid} `
        }
        //根据商品 id 查询
        if (params?.goodsid ) {
            sql += ` goodsid = ${params.goodsid} `
        }
        //根据品牌 id 查询
        if (params?.brandid ) {
            sql += ` brandid = '${params.brandid}' `
        }
        //模糊查询
        if (params?.title ) {
            sql += ` title like '%${params.title}%' `
        }
        //根据价格升序降序
        // select * from goods_tab order by price desc
        if (params?.desc == 1 ) { // desc  1  升序 2 降序
            sql += ` order by price `
        }else if (params?.desc == 2 ){
            sql += ` order by price desc`
        }
        //根据品牌查询
        if (params?.title ) {
            sql += ` title like '%${params.title}%' `
        }
        //根据品牌查询
        if (params?.page && params?.count) {
            sql += ` limit ${(params.page-1)*params.count},${params.count} `
        }
        console.log(sql);
        return query(sql)
    }
    const selectGoodsDetail = (params)=>{
        // 多表  两表联查
        // select * from 表1 inner join 表2  on  表1.articleid = 表二.tagid  where 表1.articleid = 10001
        //               join 拼接  
        // let sql = `select * from  comment_tab inner join detail_tab `
        // sql+=`on comment_tab.goodsid = detail_tab.goodsid where comment_tab.goodsid=${params.goodsid}`

        //多表   三表联查

        let sql = `select * from goods_tab as t1  inner join  comment_tab as t2 on t1.goodsid = t2.goodsid `
        sql += `inner join detail_tab as t3 on t1.goodsid=t3.goodsid `
        sql += `where t1.goodsid=${params.goodsid}`
        // console.log(sql);
        return query(sql)
    }
    //更新点赞状态

    const updateCommentZan = (params)=>{
        // update 表名  set  列名 = '内容'  where  userid = "标识值"
        let sql = `update comment_tab set zan = ${params.zan},userid = ${params.userid}  where id=${params.id}`
        console.log(sql);
        return query(sql)
    }

    const selectZan = ()=>{
        // update 表名  set  列名 = '内容'  where  userid = "标识值"
        let sql = `select * from comment_tab where zan=1`
        console.log(sql);
        return query(sql)
    }