随笔分类 -  nodejs

node绑定域名
摘要:创建nodejs文件,并测试执行有没有问题。 var express = require('express'); var app = express(); app.get('/', function (req, res) { res.type('text/plain'); res.send('nod 阅读全文
posted @ 2022-06-15 18:26 chenlw101 阅读(591) 评论(0) 推荐(0)
express访问外部url,get/post
摘要:var request = require('request'); var qs=require( 'querystring' ); // 发起请求 var httpRequest = function (url,data=null,method="GET",headers={}){ return 阅读全文
posted @ 2020-12-02 11:10 chenlw101 阅读(501) 评论(0) 推荐(0)
express设置跨域
摘要:// 设置允许跨域访问 app.all('*', function (req, res, next) { res.header("Access-Control-Allow-Origin",req.headers.origin || '*'); //允许的header类型 res.header("Ac 阅读全文
posted @ 2020-11-27 13:54 chenlw101 阅读(625) 评论(0) 推荐(0)
node操作excel
摘要:const xlsx = require('xlsx'); const path = require('path') 读取绝对地址的excel let workbook = xlsx.readFile(`./app/public/excel/a1573289191730.xls`); //workb 阅读全文
posted @ 2019-11-09 16:55 chenlw101 阅读(1557) 评论(0) 推荐(0)
koa自带包的使用
摘要:koa-router 路由管理 koa-body 返回参数转换成json,以及文件 koa-json-error 错误处理 (设置在开发环境显示具体的错误) app.use(error({ postFormat:(e,{stack,...rest})=> process.env.NODE_ENV ' 阅读全文
posted @ 2019-10-21 16:56 chenlw101 阅读(367) 评论(0) 推荐(0)
pm2常用命令
摘要:npm install pm2 -g 安装pm2 pm2 list 查看正在运行的进程 pm2 restart <AppName>/<id> 重新启动 pm2 stop <AppName>/<id> 停止进程 pm2 delete <AppName>/<id> 删除进程 pm2 info <AppN 阅读全文
posted @ 2019-09-29 14:28 chenlw101 阅读(1474) 评论(0) 推荐(0)
express入口代码解释
摘要:var createError = require('http-errors');//404检测错误页 var express = require('express'); var path = require('path'); var cookieParser = require('cookie-parser');//解析cookie var logger = require('morgan')... 阅读全文
posted @ 2019-05-22 17:03 chenlw101 阅读(972) 评论(0) 推荐(0)
express安装与配置
摘要:全局安装脚手架 创建项目 安装依赖/启动 方便代码修改和重启项目 添加执行代码(监听文件变化) 修改一下 执行命令 阅读全文
posted @ 2019-05-22 16:39 chenlw101 阅读(168) 评论(0) 推荐(0)
安全问题
摘要:sql注入解决 xss攻击 加密 阅读全文
posted @ 2019-05-22 14:10 chenlw101 阅读(126) 评论(0) 推荐(0)