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

hsswebmsql

v2.0.3

Published

=========================

Downloads

2

Readme

=========================


koa2需要下载的包名

cnpm i mysql -D  koa2的mysql语句

cnpm i js-cookie -D     前端存贮token      egg通用

cnpm i jsonwebtoken -D   后端解析用token    egg通用


axios 拦截  挂载 token
config.headers.authorization=Cookie.get('token')

store里面 存入cookie

  if(res.data.code===1){

          let {token}=res.data

          Cookie.set('token',token)

         
        }

发送

let token=jwt.sign({...userResult},'HSS',{expiresIn:'1h'})

后台登录 解密 token
 try{

      jwt.verify(authorization,'HSS')

     }catch(err){

      ctx.body={

        code:500,

        message:'没有权限',

        results

      }
      return
     }

const mysql=require('mysql')

const pool=mysql.createPool({

        host:'localhost',

        user:'root',

        password:'root',

        database:'数据库名字',

        port:3306
})

function exec(sql){
    return new Promise((resolve,reject)=>{
        pool.query(sql,(err,data)=>{
            if(err){

             reject(err)

            }
            resolve(data)
        })
    })
}

module.exports={
    exec
}

引入
===============
const { exec } = require('../db')
===============
let sql = `select * from 表名`  所有数据

let data = await exec(sql)

let sql = `delete from 表名 where id=${id}` 删除 
                                修改列的名字               对应值
let sql = `INSERT INTO 表名 (name,age,address) VALUES ('${name}', '${age}','${address}')` 插入

let sql = `UPDATE 表名 SET name = '${name}', age = '${age}', address='${address}'  WHERE id = ${id}` 编辑
                                            
let sql = `SELECT * FROM 表名 WHERE name LIKE '%${Val}%'`  搜索

=========================

Egg

cnpm i validate -D 验证类型
cnpm i crypto -D 加密

 let err= this.app.validator.validate({username:'string',password:'string'},ctx.request.body) 验证


  const {ctx}=this
   const {username,password}=ctx.request.body
    //验证类型
   let err= this.app.validator.validate({username:'string',password:'string'},ctx.request.body)

创建一个文件夹 db.js

const crypto=require('crypto')

const md5=(content)=>{

    let md5=crypto.createHash('md5')

    return md5.update(content).digest('hex')


}

const getPassword=(password)=>{

    let str=`password=${password}&secret=hss`

    return md5(str)

}

module.exports=getPassword


引入
 const getPassword=require('../../utils/db')


在config/plugin.js 

  'egg-mysql':{

    enable: true,
    package:'egg-mysql'  

  },

  'egg-cors':{

    enable:true,

    package:'egg-cors'

  }

   'egg-validate':{
    enable:true,
    package:'egg-validate'
  }


在config/config.delault.js



//后端跨域

'cors':{

      origin:'*',

      allowMethods:'GET,PUT,POST,DELETE'

 }

security:{ //关闭防火墙

     csrf:{

         enable:false

         }

}


'egg-validate':{
        convert:true
    }





=========================