首页
关于
Search
1
分享一些收集的Sync Key
5,508 阅读
2
mysql错误ERROR 1130 (HY000): Host 'localhost' is not allowed to connect to this MySQL server
1,634 阅读
3
对比win10系统上的三种软件包管理器scoop、chocolatey、winget
1,626 阅读
4
Resilio Sync 许可证下载
1,594 阅读
5
阿里云盘资源分享
1,249 阅读
前端
CSS
NodeJS
Javascript
小程序
Webpack
Vue
Typescript
Linux
软件教程
云服务器
脚本编程
技术扩展
Scoop
SSR
Youtube-dl
You-Get
Typecho
Annie
奇技淫巧
资源分享
Sync Key
随笔
疑难杂症
mysql
Docker
Python
Serverless
登录
Search
标签搜索
docker
K3S
powershell
scoop
webstorm
jQuery
webpack
typecho
mysql
windows10
linux
typescript
ssh
windows11
vue
git
Sync
fastify
winget
github
偏向技术
累计撰写
99
篇文章
累计收到
2
条评论
首页
栏目
前端
CSS
NodeJS
Javascript
小程序
Webpack
Vue
Typescript
Linux
软件教程
云服务器
脚本编程
技术扩展
Scoop
SSR
Youtube-dl
You-Get
Typecho
Annie
奇技淫巧
资源分享
Sync Key
随笔
疑难杂症
mysql
Docker
Python
Serverless
页面
关于
搜索到
2
篇与
fastify
的结果
2021-07-27
快速使用 - 部署fastify项目
#操作步骤 #1. 拉取模板代码 powershell复制 fun init -n custom-fastify https://github.com/liuqian1996/fc-fastify # Or fun init -n custom-fastify gh:liuqian1996/fc-fastify # Typescript fun init -n custom-fastify-ts gh:liuqian1996/fc-fastify --var lang=ts 12345 #2. 开发 本地 powershell复制 # 安装依赖 npm install # Development npm run dev # Build (Only Typescript) npm run build # Test npm run test 12345678 FC powershell复制 # 安装依赖 fun install # Development fun local start Domain # Build fun build # Deploy fun deploy 12345678 #注意事项 如果出现以下错误,undefined, 请不要使用temp文件夹或在.funignore中出现的文件夹名称 powershell复制 build function using image: fun-cache-af0ac9c8-2cf0-48e3-8c63-bdd9ca06ee28 running task: flow NpmTaskFlow running task: CopySource undefined 1234 如果出现以下错误,"Cannot read property 'stop' of null",先删除.fun文件夹再重新执行fun install powershell复制 skip pulling image aliyunfc/runtime-custom:1.9.17... reloading success, stop old container background... Cannot read property 'stop' of null stopping old container successfully 1234
2021年07月27日
266 阅读
0 评论
0 点赞
2021-04-10
mysql://root@localhost/mysql是什么?
# 在使用了fastify-mysql的项目开发中,发现连接数据库时是传的字符串mysql://root@localhost/mysql,和url地址类似,百思不得其解,正常的配置都是有多个选项的一个对象,那么常规理解就是字符串的位置一定对应选项中每个字段,那么,对应关系是如何的呢?源码走起…… 点击直达最后的潘多拉魔盒 #源码分析 fastify-mysql传的参数类型如下,连接类型有两种,连接池和普通连接,默认连接类型是 pool ts复制 // node_modules/fastify-mysql/index.d.ts export type ConnectionType = "connection" | "pool"; export interface MySQLOptions extends PoolOptions, ConnectionOptions { type?: ConnectionType; name?: string; promise?: boolean; connectionString?: string; } 123456789 fastify-mysql底层使用的是mysql2在新窗口打开,从fastify-mysql源码中得知,当 ConnectionType 为 pool 时,调用的是 mysql.createPool 方法,为 connection 时,调用的是 mysql.createConnection 方法 js复制 exports.createPool = function(config) { const PoolConfig = require('./lib/pool_config.js'); return new Pool({ config: new PoolConfig(config) }); }; 1234 再进一步是在 pool_config.js 中处理我们传过来的 connectionstring js复制 === line-highlight data-line: 9-11 === // node_modules/mysql2/lib/pool_config.js const ConnectionConfig = require('./connection_config.js'); class PoolConfig { constructor(options) { if (typeof options === 'string') { options = ConnectionConfig.parseUrl(options); } this.connectionConfig = new ConnectionConfig(options); …… } } module.exports = PoolConfig; 1234567891011121314151617 接着在connection_config.js里面查找,发现了一个 parseUrl 的静态方法,mysql://root@localhost/mysql对应连接数据库配置参数的对应关系就出来了 #对应关系 js复制 static parseUrl(url) { url = urlParse(url, true); const options = { host: url.hostname, port: url.port, database: url.pathname.substr(1) }; if (url.auth) { const auth = url.auth.split(':'); options.user = auth[0]; options.password = auth[1]; } if (url.query) { for (const key in url.query) { const value = url.query[key]; try { // Try to parse this as a JSON expression first options[key] = JSON.parse(value); } catch (err) { // Otherwise assume it is a plain string options[key] = value; } } } return options; } 1234567891011121314151617181920212223242526 #URL额外补充 url是统一资源定位符(Uniform Resource Locator)的缩写,他的格式为: markdown复制 [comment]: <> (标准格式) [协议类型]://[服务器地址]:[端口号]/[资源层级UNIX文件路径][文件名]?[查询]#[片段ID] [comment]: <> (完整格式) [协议类型]://[访问资源需要的凭证信息]@[服务器地址]:[端口号]/[资源层级UNIX文件路径][文件名]?[查询]#[片段ID] [comment]: <> (其中[访问凭证信息]、[端口号]、[查询]、[片段ID]属于选填项) 1234567 统一资源定位符在新窗口打开不但被用作网页地址,JDBC在新窗口打开 客户端在新窗口打开也使用统一资源定位符连接其数据库服务器。作为对比,ODBC在新窗口打开 的连接字符串作用相同,但并不采用 URL 格式,而是分号和等号分隔的键值对。右侧是一个 Oracle在新窗口打开 数据库的统一资源定位符:jdbc:datadirect:oracle://myserver:1521;sid=testdb #最终呈现 假设有这样一个地址:mysql://user:password@host:3306/database?charset=utf8,Node环境解析如下 注意,传统的urlObject方式(即以下方式)在v11.0.0开始弃用,新的方式为new URL(<URL>) js复制 const urlParse = require('url').parse; urlParse('mysql://user:password@host:3306/database?charset=utf8') Url { protocol: 'mysql:', slashes: true, auth: 'user:password', host: 'host:3306', port: '3306', hostname: 'host', hash: null, search: '?charset=utf8', query: 'charset=utf8', pathname: '/database', path: '/database?charset=utf8', href: 'mysql://user:password@host:3306/database?charset=utf8' } // 通过上面的parseUrl解析之后得到 { host: 'host', port: '3306', database: 'database', user: 'user', password: 'password', charset: 'utf8' } 123456789101112131415161718192021222324252627 #总结 所以,我这一顿操作分析了个寂寞??????
2021年04月10日
195 阅读
0 评论
0 点赞