基于本人在现在公司的 Node 微服务实践, 不断维护升级着一个 Node Restful API 种子项目, 特此共享出来以供借鉴和讨论. 项目中几乎所有的东西都使用了 node/javascript 及相应模块的最新功能, 语法, 和实践.
如果你需要的是一个大而全的框架, eggjs 应该是很好的选择. 如果你动手能力强, 追求自由灵活, 并且不排斥 express, 那可以试试采用我这个项目.
项目 github 仓库地址, 欢迎 star: https://github.com/xiaozhongliu/node-api-seed
下面先贴一下我在 github 上对项目的综合描述, 完了在下一篇帖子会一一展示项目的各个方面, 至于怎么实现的可以看源码, 相信你会喜欢上我干净简洁, 层次清晰, 与时俱进的代码风格的😅.
(V2EX 貌似不支持 MD 的表格语法, 去 github 上看吧)
|Aspect |Tech |
|:--- |:--- |
|web fx |express |
|task |node-schedule |
|db postgres|sequelize |
|db mongodb |mongoose |
|memcache |node_redis |
|http client|axios |
|logger |log4js-node |
|mailer |nodemailer |
|dashboard |express-status-monitor |
|jwt auth |jsonwebtoken |
|validation |express-validator |
|async flow |async/await of ES7 |
|log auth |http-auth |
|js checker |eslint |
|proc mana |pm2 |
Api access control via ts & token.
Elaborate api request log into files.
Flexible declarative request validation.
Request log online view behind http auth.
Server status monitor dashboard behind http auth.
Ready made api samples with jwt and latest js features.
Centralized system level config & messages management.
Reasonable multi-env config merging mechanism.
Definite DRY, SRP, AOP, ES6/ES7, OCD, etc.
cnpm i # install all packages for dev env
npm start # run service in dev env, or hit F5 to debug in vsc
npm run pm2start # host via pm2 in prod env
npm run pm2startqa # host via pm2 in qa env
npm run pm2starttest # host via pm2 in test env
npm run pm2restart # restart hosted service in prod env
npm run pm2restartqa # restart hosted service in qa env
npm run pm2restarttest # restart hosted service in test env
npm run pm2stop # hang up hosted service
npm run pm2delete # remove hosted service
1
strugglexiang 2018-01-27 12:50:55 +08:00
github 上的英文都是大佬您写的吗?都这么厉害
|
2
liux466713 OP @strugglexiang 是我写的, 可是大佬是谁?
|