
node.js
2b勿扰
专注技术的研究
展开
-
node 中jwt的使用token的加解密
// nodejs+express+jwt-simplelet jwt = require('jwt-simple');//秘钥let secret = "laney";let time = 10;let tokenExpiresTime = 1000 * 60 * 60 * 24 * 7;//token过期时间,毫秒为单位, 7天 module.exports = { /* ...原创 2020-05-02 15:50:19 · 17802 阅读 · 0 评论 -
node 中数据库连接的三种方式(mysql案例)
mysql包的数据库连接首先安装npm i mysqlconst mysql = require("mysql2");/*建立数据库链接 连接配置 */// createPool//getConnection// createPool 连接池 --- getConnection 获取到连接对象 操作后建议主动的释放连接// createConnection方法创建连接对...原创 2020-05-02 13:15:19 · 17563 阅读 · 0 评论 -
node 文件读取与写入
const fs = require("fs");function get(key) { fs.readFile("./db.json", (err, data) => { const json = JSON.parse(data); console.log(json[key]); });}function set(key, value) { fs.rea...原创 2020-04-26 23:11:04 · 16295 阅读 · 0 评论