基於本人在如今公司的Node微服務實踐, 不斷維護升級着一個Node Restful API種子項目, 特此共享出來以供借鑑和討論. 項目中幾乎全部的東西都使用了node/javascript及相應模塊的最新功能, 語法, 和實踐.
若是你須要的是一個大而全的框架, eggjs應該是很好的選擇. 若是你動手能力強, 追求自由靈活, 而且不排斥express, 那能夠試試採用我這個項目.javascript
項目github倉庫地址, 歡迎star: github.com/xiaozhongli…
下面先貼一下我在github上對項目的綜合描述, 完了在下一篇帖子會一一展現項目的各個方面, 至於怎麼實現的能夠看源碼, 相信你會喜歡上我乾淨簡潔, 層次清晰, 與時俱進的代碼風格的😅.java
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.node
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
複製代碼