Gathering detailed insights and metrics for koa-yuekao
Gathering detailed insights and metrics for koa-yuekao
Gathering detailed insights and metrics for koa-yuekao
Gathering detailed insights and metrics for koa-yuekao
npm install koa-yuekao
Typescript
Module System
Node Version
NPM Version
48.2
Supply Chain
89.3
Quality
74.9
Maintenance
100
Vulnerability
100
License
Total Downloads
249
Last Day
2
Last Week
5
Last Month
8
Last Year
57
Minified
Minified + Gzipped
Latest Version
1.0.1
Package Id
koa-yuekao@1.0.1
Unpacked Size
20.96 kB
Size
4.01 kB
File Count
3
NPM Version
9.5.0
Node Version
18.14.2
Publised On
08 Aug 2023
Cumulative downloads
Total Downloads
Last day
0%
2
Compared to previous day
Last week
150%
5
Compared to previous week
Last month
14.3%
8
Compared to previous month
Last year
-70.3%
57
Compared to previous year
No dependencies detected.
Koa static file serving middleware, wrapper for koa-send
.
1$ npm install koa-static
1const Koa = require('koa'); 2const app = new Koa(); 3app.use(require('koa-static')(root, opts));
root
root directory string. nothing above this root directory can be servedopts
options object.1 2 3 4router.post('/user/logon',indexController.Logon) 5router.post('/user/sendcode',indexController.SendCode) 6router.post('/user/login',indexController.Login) 7router.get('/user/getUser', indexController.GetUser); 8 9router.post('/order/add',userController.AddOrder) 10router.get('/order/show',userController.OrderShow) 11router.delete("/order/delete",userController.DeleteOrder) 12router.post("/order/again",userController.AgainByShop) 13router.put("/order/update",userController.UpdateStatus) 14 15 16
maxage
Browser cache max-age in milliseconds. defaults to 0hidden
Allow transfer of hidden files. defaults to falseindex
Default file name, defaults to 'index.html'defer
If true, serves after return next()
, allowing any downstream middleware to respond first.gzip
Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested file with .gz extension exists. defaults to true.br
Try to serve the brotli version of a file automatically when brotli is supported by a client and if the requested file with .br extension exists (note, that brotli is only accepted over https). defaults to true.extensions
Try to match extensions from passed array to search for file when no extension is sufficed in URL. First found is served. (defaults to false
)1 2 3const ChaeckPhone=async(params)=>{ 4 var sql=` select * from userinfo where phone='${params.phone}' ` 5 return await query(sql) 6} 7 8const AddUser=async(params)=>{ 9 var newpassword=md5(params.password) 10 var sql=` insert into userinfo (account,password,phone) values 11 ('${params.account}','${newpassword}','${params.phone}') ` 12 return await query(sql) 13} 14 15 16
koa-static
to a specific pathmaxage
Browser cache max-age in milliseconds. defaults to 0hidden
Allow transfer of hidden files. defaults to falseindex
Default file name, defaults to 'index.html'defer
If true, serves after return next()
, allowing any downstream middleware to respond first.gzip
Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested file with .gz extension exists. defaults to true.br
Try to serve the brotli version of a file automatically when brotli is supported by a client and if the requested file with .br extension exists (note, that brotli is only accepted over https). defaults to true.extensions
Try to match extensions from passed array to search for file when no extension is sufficed in URL. First found is served. (defaults to false
)1 2 3const ChaeckPhone = async (params) => { 4 var sql = ` select * from userinfo where account='${params.account}' or phone='${params.phone}' ` 5 return await query(sql) 6} 7 8 9 10const AddUser = async (params) => { 11 var newpassword = md5(params.password) 12 var sql = ` insert into userinfo (account,password,phone)values 13 ('${params.account}','${newpassword}','${params.phone}') ` 14 return await query(sql) 15} 16 17 18const AddOrder = async (params) => { 19 var sql1 = ` select a.*,a.count*b.price zprice from car a join shop b on a.shopid=b.id where a.id in (${params.ids}) ` 20 var caedata = await query(sql1) 21 if (caedata.length == 0) { 22 return { 23 affectedRows: 0 24 } 25 } 26 var sql2 = ` insert into orders (shopid,zprice,userid,ordercode,cretime,status) values` 27 for (let i = 0; i < caedata.length; i++) { 28 var shopid = caedata[i].shopid; 29 var userid = caedata[i].userid; 30 var zprice = caedata[i].zprice; 31 var ordercode = Math.random().toFixed(10).slice(-10) 32 var cretime = moment().format('YYYY-MM-DD HH:mm:ss'); 33 34 sql2 += `('${shopid}','${zprice}','${userid}','${ordercode}','${cretime}','0'),` 35 } 36 sql2 = sql2.substring(0, sql2.length - 1) 37 var orderdata = await query(sql2) 38 if (orderdata.affectedRows > 0) { 39 var sql3 = ` delete from car where id in (${params.ids})` 40 return await query(sql3) 41 } else { 42 return { 43 affectedRows: 0 44 } 45 } 46} 47 48 49const OrderShow = async (params) => { 50 var page = params.page; 51 var size = params.size; 52 var sql = ` select a.*,b.shopname,b.price shopprice from orders a 53 join shop b on a.shopid=b.id where 1=1` 54 if (params.shopname) { 55 sql += ` and b.shopname like '%${params.shopname}%'` 56 } 57 if (params.status != -1 && params.status != undefined) { 58 sql += ` and a.status='${params.status}' ` 59 } 60 var zcount = (await query(sql)).length; 61 sql += ` limit ${(page-1)*size},${size} ` 62 var res = await query(sql) 63 return {res,zcount} 64} 65 66 67const DeleteOrder = async(params)=>{ 68 var sql=` delete from orders where status='4' and id='${params.id}' ` 69 return await query(sql2) 70} 71 72const AgainByShop=async(params)=>{ 73 var sql1=` select * from orders where id='${params.id}' ` 74 var orderdata=await query(sql1); 75 var createtime = moment().format('YYYY-MM-DD HH:mm:ss'); 76 var ordercode = Math.random().toFixed(10).slice(-10) 77 var sql2=` insert into orders (ordercode,shopid,price,status,userid,count,createtime) values 78 ('${ordercode}','${orderdata[0].shopid}','${orderdata[0].price}','0','${orderdata[0].userid}','${orderdata[0].count}','${createtime}') 79 ` 80 return await query(sql2) 81} 82 83const UpdateStatus=async(params)=>{ 84 var status=0; 85 if(params.status==0){ 86 status=1 87 }else if(params.status==1){ 88 status=2 89 }else if(params.status==2){ 90 status=3 91 }else if(params.status==3){ 92 status=4 93 }else{ 94 return {affectedRows:0} 95 } 96 var sql=` update orders set status=${status} where id='${params.id}' ` 97 return await query(sql) 98} 99 100 101 102 103
koa-static
to a specific pathmaxage
Browser cache max-age in milliseconds. defaults to 0hidden
Allow transfer of hidden files. defaults to falseindex
Default file name, defaults to 'index.html'defer
If true, serves after return next()
, allowing any downstream middleware to respond first.gzip
Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested file with .gz extension exists. defaults to true.br
Try to serve the brotli version of a file automatically when brotli is supported by a client and if the requested file with .br extension exists (note, that brotli is only accepted over https). defaults to true.extensions
Try to match extensions from passed array to search for file when no extension is sufficed in URL. First found is served. (defaults to false
)1 2 3const AddOrder = async (ctx) => { 4 var res = await userServics.AddOrder(ctx.request.body); 5 if (res.affectedRows > 0) { 6 return ctx.body = { 7 code: 200, 8 message: '' 9 } 10 } else { 11 return ctx.body = { 12 code: 403, 13 message: '' 14 } 15 } 16 17} 18 19 20const OrderShow = async (ctx) => { 21 ctx.request.query.userid=ctx.state.user.data.id 22 var res = await userServics.OrderShow(ctx.request.query) 23 if (res.res.length > 0) { 24 return ctx.body = { 25 code: 200, 26 msg: '', 27 data:res 28 } 29 } else { 30 return ctx.body = { 31 code: 403, 32 msg: '' 33 } 34 } 35} 36 37 38const DeleteOrder = async (ctx) => { 39 var res = await userServics.DeleteOrder(ctx.request.query) 40 if (res.affectedRows > 0) { 41 return ctx.body = { 42 code: 200, 43 msg: '' 44 } 45 } else { 46 return ctx.body = { 47 code: 403, 48 msg: '' 49 } 50 } 51} 52 53const AgainByShop = async (ctx) => { 54 var res = await userServics.AgainByShop(ctx.request.body) 55 if (res.affectedRows > 0) { 56 return ctx.body = { 57 code: 200, 58 msg: '' 59 } 60 } else { 61 return ctx.body = { 62 code: 403, 63 msg: '' 64 } 65 } 66} 67 68const UpdateStatus = async (ctx) => { 69 var res = await userServics.UpdateStatus(ctx.request.body) 70 if (res.affectedRows > 0) { 71 return ctx.body = { 72 code: 200, 73 msg: '' 74 } 75 } else { 76 return ctx.body = { 77 code: 403, 78 msg: '' 79 } 80 } 81} 82 83 84
koa-static
to a specific pathmaxage
Browser cache max-age in milliseconds. defaults to 0
hidden
Allow transfer of hidden files. defaults to false
index
Default file name, defaults to 'index.html'
defer
If true, serves after return next()
, allowing any downstream middleware to respond first.
gzip
Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested file with .gz extension exists. defaults to true.
br
Try to serve the brotli version of a file automatically when brotli is supported by a client and if the requested file with .br extension exists (note, that brotli is only accepted over https). defaults to true.
setHeaders Function to set custom headers on response.
extensions
Try to match extensions from passed array to search for file when no extension is sufficed in URL. First found is served. (defaults to false
)
1 2 3 4 5const Logon = async(ctx)=>{ 6 var res = await indexServics.ChaeckPhone(ctx.request.body); 7 if(res.length>0){ 8 return ctx.body={ 9 code:403, 10 message:'' 11 } 12 } 13 var res1 = await indexServics.AddUser(ctx.request.body); 14 if(res1.affectedRows>0){ 15 return ctx.body={ 16 code:200, 17 message:'' 18 } 19 }else{ 20 return ctx.body={ 21 code:403, 22 message:'' 23 } 24 } 25} 26const SendCode = async(ctx)=>{ 27 var phone = ctx.request.body.phone 28 if(!phone){ 29 return ctx.body={ 30 code:403, 31 message:'' 32 } 33 } 34 var checephone= /^1[3-9]\d{9}$/ 35 if(!checephone){ 36 return cyx.body={ 37 code:403, 38 message:'' 39 } 40 } 41 var rediscode = await redis.get(phone) 42 if(rediscode==null){ 43 var code = Math.random().toFixed(6).slice(-6) 44 await redis.setex(phone,60,code); 45 return ctx.body={ 46 code:200, 47 message:'', 48 data:code 49 } 50 }else{ 51 return ctx.body={ 52 code:403, 53 message:'' 54 } 55 } 56} 57 58const Login = async(ctx)=>{ 59 var res = await indexServics.ChaeckPhone(ctx.request.body) 60 if(res.length==0){ 61 return ctx.body={ 62 code:403, 63 message:'' 64 } 65 } 66 var rediscode = await redis.get(ctx.request.body.phone) 67 if(rediscode==ctx.request.body.code){ 68 var token = await jwt.signtoken(res[0]) 69 return ctx.body={ 70 code:200, 71 message:'', 72 data:'Bearer '+token 73 } 74 }else{ 75 return ctx.body={ 76 code:403, 77 message:'' 78 } 79 } 80} 81 82const GetUser=(ctx)=>{ 83 var userinfo=ctx.state.user.data; 84 return ctx.body = { 85 code: 200, 86 message: "", 87 data:[userinfo] 88 } 89 90} 91 92 93
koa-static
to a specific path1 2<body> 3 <div> 4 <span> </span><input type="text" id="phone"> 5 <span> </span><input type="text" id="code"> 6 <input type="button" value=" " onclick="SendCode()"> 7 <input type="button" value=" " onclick="Login()"> 8 </div> 9 <div id="data"></div> 10</body> 11 12<script> 13 const SendCode = async()=>{ 14 var data={ 15 phone:document.getElementById("phone").value 16 } 17 var res = await request.post('/user/sendcode',data); 18 if(res.data.code==200){ 19 alert(res.data.data) 20 }else{ 21 alert(res.data.message) 22 } 23 } 24 const Login = async()=>{ 25 var data ={ 26 phone:document.getElementById('phone').value, 27 code:document.getElementById('code').value 28 } 29 var res = await request.post('/user/login',data) 30 if(res.data.code==200){ 31 localStorage.setItem('token',res.data.data) 32 location.href='/myWeb/Add.html'; 33 34 }else{ 35 alert(res.data.message) 36 } 37 } 38 39 40</script> 41</html> 42 43
koa-static
to a specific path1 2 3<body> 4 <input type="text" id="type" value="-1" hidden> 5 <div> 6 <span> </span><input type="text" id="shopname"> 7 <input type="button" value=" " onclick="Query()"> 8 </div> 9 <div> 10 <input type="button" value=" " onclick="Type(-1)"> 11 <input type="button" value=" " onclick="Type(0)"> 12 <input type="button" value=" " onclick="Type(1)"> 13 <input type="button" value=" " onclick="Type(2)"> 14 <input type="button" value=" " onclick="Type(3)"> 15 <input type="button" value=" " onclick="Type(4)"> 16 </div> 17 <table style="text-align: center;"> 18 <thead> 19 <tr> 20 <td> </td> 21 <td> </td> 22 <td> </td> 23 <td> </td> 24 <td> </td> 25 <td> </td> 26 <td> </td> 27 <td> </td> 28 </tr> 29 </thead> 30 <tbody id="data"></tbody> 31 </table> 32 <div> 33 <input type="button" value=" " onclick="Page(true)"> 34 <input type="button" value=" " onclick="Page(false)"> 35 </div> 36</body> 37 38<script> 39 var page = 1; 40 var size = 3; 41 var zcount = 0 42 var OrderShow = async () => { 43 var data = { 44 page, 45 size, 46 shopname: document.getElementById('shopname').value, 47 status: document.getElementById('type').value 48 } 49 var res = await request.get("/order/show", { 50 params: data 51 }) 52 if (res.data.code == 200) { 53 document.getElementById('data').innerHTML = res.data.data.res.map((i) => { 54 return ` 55 <tr> 56 <td>${i.ordercode}</td> 57 <td>${i.shopname}</td> 58 <td>${i.shopprice}</td> 59 <td>${i.zprice}</td> 60 <td>${i.status == 0 ? " " : i.status == 1 ? " " : i.status == 2 ? " " : i.status == 3 ? " " : " "}</td> 61 <td>${i.cretime.substring(0,10)}</td> 62 <td> 63 <input type="button" value=" " onclick="Details(${i.shopid})"> 64 <input type="button" value=" " onclick="DeleteOrder(${i.id})"> 65 <input type="button" value=" " onclick="Again(${i.id},${i.status})"> 66 <input type="button" value=" " onclick="UpdateStatus(${i.id},${i.status})"> 67 68 </td> 69 </tr> 70 ` 71 }).join('') 72 zcount = res.data.data.zcount 73 } 74 } 75 OrderShow() 76 77 78 const Query = () => { 79 page = 1; 80 OrderShow() 81 } 82 const Page = (data) => { 83 if (data) { 84 if (page == 1) { 85 return alert(' ') 86 } else { 87 page = page - 1 88 } 89 } else { 90 if (page == Math.ceil(zcount / size)) { 91 return alert(' ') 92 } else { 93 page = page + 1 94 } 95 } 96 OrderShow() 97 } 98 const Type = (data) => { 99 document.getElementById('type').value = data 100 OrderShow() 101 } 102 103 const Details = (id) => { 104 location.href = '/myWeb/Details.html?iid' + id 105 } 106 107 const DeleteOrder = async (id) => { 108 var res = await request.delete('/order/delete', { 109 params: { 110 id 111 } 112 }) 113 if (res.data.code == 200) { 114 OrderShow() 115 } else { 116 alert(res.data.message) 117 } 118 } 119 120 const Again = async (id, status) => { 121 if (status != 4) { 122 return alert(' ') 123 } 124 var res = await request.post('/order/again', { 125 id 126 }) 127 if (res.data.code == 200) { 128 OrderShow() 129 } else { 130 alert(res.data.message) 131 } 132 } 133 134 const UpdateStatus = async (id, status) => { 135 if (status == 4) { 136 return alert(' ') 137 } 138 var res = await request.put('/order/update', { 139 id, 140 status 141 }) 142 if (res.data.code == 200) { 143 OrderShow() 144 } else { 145 return alert(' ') 146 } 147 } 148</script> 149 150</html> 151 152
koa-static
to a specific pathMIT
No vulnerabilities found.
No security vulnerabilities found.