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

api-node-cli

v1.0.11

Published

node服务端构建工具

Downloads

2

Readme

api-node-cli

说明

该项目为node微小服务端开发框架,求轻喷QAQ。工具,db,service,router,config分离,提供mongo(mongoist),mysql(mysql),redis(ioredis)数据库基础工具。项目环境可配置,统一请求和返回值处理,自定义错误信息,可配置日志(错误和请求),可选择邮件提示。

第一步

全局安装 sudo npm install api-node-cli -g

第二步

创建工程目录 mkdir demo

第三步

进入工程新目录 cd demo

第四步

执行命令 api-node-cli 构建目录

第五步

自定义 package.json

第六步

安装依赖 npm install

第七步

修改配置 值选择配置文件夹 config/dev,config/product,config/test 默认为config/dev

第八步

自定义.gitignore

第九步

运行app.js(webstorm) / 1. sudo npm install pm2 -g 2. npm run dev 将根据package.json中的

第十步

创建数据库 test 新建表 t1 -> 字段 id,name 插入数据 使用postman工具模拟请求 http://localhost:7001/api/user/hello 传参数 id:1

TIPS

1.为方便管理建议重命名 app.js为 项目名.js 并同时修改 pm2.json下的name 2.README.md提供目录结构解释 3.请求日志和错误日志路径参照 app/config/log.js 4.mongo操作依赖模块mongoist 5.mysql操作依赖模块mysql,在app/common/mysql.js 中进行了方法的简单封装: getConnection 从连接池里获取一个数据库连接 beginTransaction 开始事物 commit 提交事物 rollback 回滚事物 release 释放连接 query 返回查询相关的所有信息{results, fields} findOne 返回一条结果集对象 find 返回多条结果集数组 update 返回修改的行数 insert 返回插入的id 6./router下index.js 中将对所有请求进行拦截格式化处理和记录日志,可通过路由正则的方式进行额外处理 7./error下封装了自定义的错误类型 8.时间处理模块moment 校验模块validator 9.新增commom/requestPro.js 用于服务端调用第三方api,并可以选择记录日志