{"_id":"@c42/feathers-b","_rev":"6-0afb1b2c18031c10aebf8c88f74a1a9b","time":{"0.0.0":"2018-05-28T07:45:53.805Z","created":"2018-06-01T04:27:09.596Z","0.1.2":"2018-06-01T04:27:09.793Z","modified":"2022-04-04T21:25:21.908Z","0.1.3":"2018-06-01T04:49:24.099Z"},"name":"@c42/feathers-b","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.2":{"name":"@c42/feathers-b","version":"0.1.2","license":"UNLICENSED","private":false,"engines":{"node":">= 8.11.1","npm":">= 5.6.0","yarn":">= 1.6.0"},"scripts":{"dev":"cross-env NODE_ENV=development nodemon src","test":"npm run lint && npm run coverage","lint":"eslint . --ext .js,.vue --fix --format node_modules/eslint-friendly-formatter","coverage":"cross-env NODE_ENV=test nyc --nycrc-path test/.nycrc mocha --opts test/mocha.opts","unit":"cross-env NODE_ENV=test mocha --opts test/mocha.opts","build":"cross-env NODE_ENV=production backpack build","start":"npm run build && cross-env NODE_ENV=production C42_LOG_ALL=1 C42_LOG_PRETTY= C42_LOG_LEVEL=info C42_LOG_TIME=1 nodemon dist/main.js","prepublishOnly":"npm run build && echo module.exports = require('./dist/main.js')> index.js","postpublish":"echo module.exports = require('./src/export.js')> index.js"},"main":"index.js","files":["dist","index.js"],"husky":{"hooks":{"pre-commit":"npm run lint"}},"dependencies":{"@c42/commons":"^18.0.1","@feathersjs/authentication":"^2.1.5","@feathersjs/authentication-local":"^1.2.1","axios":"^0.18.0","babel-register":"^6.26.0","cross-env":"^5.1.6","feathers-authentication-management":"^2.0.0","feathers-hooks-common":"^4.11.1","is-odd":"^3.0.1","localstorage-memory":"^1.0.2","lodash":"^4.17.10","nodemon":"^1.17.5","shortid":"^2.2.8","uws":"^10.148.0","zxcvbn":"^4.4.2"},"devDependencies":{"babel-eslint":"^8.2.3","babel-preset-env":"^1.7.0","babel-preset-power-assert":"^2.0.0","babel-preset-stage-2":"^6.24.1","backpack-core":"^0.7.0","core-js":"2.5.6","eslint":"^4.19.1","eslint-config-airbnb-base":"^12.1.0","eslint-config-google":"^0.9.1","eslint-config-prettier":"^2.9.0","eslint-config-standard":"^11.0.0","eslint-friendly-formatter":"^4.0.1","eslint-plugin-import":"^2.12.0","eslint-plugin-node":"^6.0.1","eslint-plugin-prettier":"^2.6.0","eslint-plugin-promise":"^3.8.0","eslint-plugin-security":"^1.4.0","eslint-plugin-standard":"^3.1.0","eslint-plugin-vue":"^4.5.0","husky":"^1.0.0-rc.2","mocha":"^5.2.0","nyc":"^11.8.0","prettier":"^1.13.2","rimraf":"^2.6.2","uglifyjs-webpack-plugin":"^1.2.5","webpack-bundle-analyzer":"^2.13.1","webpack-merge":"^4.1.2"},"gitHead":"50573dc0dd9183e3d5d792826537d6bbe78f6487","description":"基于 [express](https://expressjs.com)、[feathersjs](https://feathersjs.com/) 和 [@c42/commons](https://code.aliyun.com/c42/commons) 的后端项目样板","_id":"@c42/feathers-b@0.1.2","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"beeplin","email":"beeplin@gmail.com"},"dist":{"integrity":"sha512-eyao1nnQ392ywCw2AeP8pqO082kAhZdmp7MdQ8aHgPyAN7W4oONLWyb2MEv+Op9Bmy9GcnAm0mUFEQpX11YAtw==","shasum":"ac5127f309a365df32ab96ea81baccb5764ca8b8","tarball":"https://registry.npmjs.org/@c42/feathers-b/-/feathers-b-0.1.2.tgz","fileCount":5,"unpackedSize":15192,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbEMseCRA9TVsSAnZWagAAg84QAJtS6AILFG7PA3UBobAL\nh5A5TfoFQ0grY1P009l63lOTH0hYDVQJoF8aCtRlDK0TTdWDjFEdAVCsoid0\n42BkjYhldCLbhGf+lS0tBSVZC+d6Jr3ERg2UEBD/XcFFmuCKC1K1EX/aERTg\n5mPpNfcvLzv95bRiGa0LduNwidW/HSjS+omiuGhTiY/uIfMFYx/ojHVNRqOH\nDsDF9h6IThIhOf7ZL0gvPvcT6IeOFguAAwQytGF8wsvl58jg4du9Qd41Rprf\ntfF2LV643DCp5QDH5vZr0r5cNxpXCXq8TjJXUZR/e2d/yf8ea496KSjm7w3b\nk9R9HdvdWwCdAS2+LV08+YQmHygbedgzY7TgZnTGfI1eZ6qHACzEoYMcRr7K\nVG8koM2TiFI9CNLskwaJQbNh1PRT9SzeWj59WzrbqOqJzKOl++6o03Wrp6/B\n9Lxt5r9iAO9dIG/uurarUmHJY6lDTuuy5m3Av3aNuKnjkjo9f8ugjZaxJO3+\nL2QpylPz8qX6Ji7j/d1S9NkFuRYJLEKv8plefon+71sElQKdLk4G++cjNmrm\nA5KMDGP8SEqOroR4N/DrXJjtFcW6UCmuKcWBpFHi0vSXWQMVr9dlTBWD7JQ0\nmUiqwM0vaADH/LIlFD4LbLcEFAIKyhZ/uMUm7Y3Gh1T/ByBTeSAawFThnvdr\nG9rw\r\n=pz0b\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDyctxmVbpec2jaVl/aQDE52DbGXdyuiCOMnYgR/WwMngIgA0QOqLqihCErWGqBbl6eDKP61b4NytbaZh3D7B3d6r8="}]},"maintainers":[{"name":"beeplin","email":"beeplin@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/feathers-b_0.1.2_1527827229685_0.6723315454082426"},"_hasShrinkwrap":false},"0.1.3":{"name":"@c42/feathers-b","version":"0.1.3","license":"UNLICENSED","private":false,"engines":{"node":">= 8.11.1","npm":">= 5.6.0","yarn":">= 1.6.0"},"scripts":{"dev":"cross-env NODE_ENV=development nodemon src","test":"npm run lint && npm run coverage","lint":"eslint . --ext .js,.vue --fix --format node_modules/eslint-friendly-formatter","coverage":"cross-env NODE_ENV=test nyc --nycrc-path test/.nycrc mocha --opts test/mocha.opts","unit":"cross-env NODE_ENV=test mocha --opts test/mocha.opts","build":"cross-env NODE_ENV=production backpack build","start":"npm run build && cross-env NODE_ENV=production C42_LOG_ALL=1 C42_LOG_PRETTY= C42_LOG_LEVEL=info C42_LOG_TIME=1 nodemon dist/main.js","prepublishOnly":"npm run build && echo module.exports = require('./dist/main.js')> index.js","postpublish":"echo module.exports = require('./src/export.js')> index.js"},"main":"index.js","files":["dist","index.js"],"husky":{"hooks":{"pre-commit":"npm run lint"}},"dependencies":{"@c42/commons":"^18.0.1","@feathersjs/authentication":"^2.1.5","@feathersjs/authentication-local":"^1.2.1","axios":"^0.18.0","babel-register":"^6.26.0","cross-env":"^5.1.6","feathers-authentication-management":"^2.0.0","feathers-hooks-common":"^4.11.1","is-odd":"^3.0.1","localstorage-memory":"^1.0.2","lodash":"^4.17.10","nodemon":"^1.17.5","shortid":"^2.2.8","uws":"^10.148.0","zxcvbn":"^4.4.2"},"devDependencies":{"babel-eslint":"^8.2.3","babel-preset-env":"^1.7.0","babel-preset-power-assert":"^2.0.0","babel-preset-stage-2":"^6.24.1","backpack-core":"^0.7.0","eslint":"^4.19.1","eslint-config-airbnb-base":"^12.1.0","eslint-config-google":"^0.9.1","eslint-config-prettier":"^2.9.0","eslint-config-standard":"^11.0.0","eslint-friendly-formatter":"^4.0.1","eslint-plugin-import":"^2.12.0","eslint-plugin-node":"^6.0.1","eslint-plugin-prettier":"^2.6.0","eslint-plugin-promise":"^3.8.0","eslint-plugin-security":"^1.4.0","eslint-plugin-standard":"^3.1.0","eslint-plugin-vue":"^4.5.0","husky":"^1.0.0-rc.2","mocha":"^5.2.0","nyc":"^11.8.0","prettier":"^1.13.2","rimraf":"^2.6.2","uglifyjs-webpack-plugin":"^1.2.5","webpack-bundle-analyzer":"^2.13.1","webpack-merge":"^4.1.2"},"gitHead":"f81548635233c56c5d2af0e2300865d3b63ac4cd","description":"基于 [express](https://expressjs.com)、[feathersjs](https://feathersjs.com/) 和 [@c42/commons](https://code.aliyun.com/c42/commons) 的后端项目样板","_id":"@c42/feathers-b@0.1.3","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"beeplin","email":"beeplin@gmail.com"},"dist":{"integrity":"sha512-tmo9r6U+/F8DmtwH7Yl6GCUWz+8ehRd/+Gpor/DvNLFi7zI8+oWQfLgwRU7BhRzNElxaZVzhctXKmDrOd2pEuw==","shasum":"614f215f91590f8f66782178aa319e36e122942a","tarball":"https://registry.npmjs.org/@c42/feathers-b/-/feathers-b-0.1.3.tgz","fileCount":5,"unpackedSize":15168,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbENBUCRA9TVsSAnZWagAAuQ0P/jLsXUQZ0diMjwegsUoj\na1gJKSa6rheOPs6PK08t7L3K2jcL6tZRsYP0P0KbMI2jA/ar9QXz+lpFjB9o\nftoZoIeaDMYyM/hpG+fSWLS0RYethTAVyvl7IomTU/lzV770U9F2g2OmusDc\nUhjlCc4o2N7xKlwG6S2yCzuPu3HJyv1iAtw2ejnzfhZiQOe0/y7YaCsIj+iI\nCH54bDMbBtGBQjEayLiS0IqOoOfuiWY2UbYTHUckbBjxiWscmyoE69OCjJ5E\nUV6val98mFB6Njalh7CWoQ4TpVTOkTh5sbnGt+dLeP7zX2qZpAqwpWEZgmYZ\nL7H1K7eQ/Zzd5oT35bHrsPsqqqU+NylQFuAegXRkXVkPn+/8plRCgPXyuAht\n+7Ft/ER34GTtKFrDNejULL/fLPFf44Vto2QS9TarGzbVd8ko2wZqrt9QpZyN\n7r3MT9WpzZ1vOA8fcPWF4yTus9CxldT5+ngsxHC++Vxlqy27xc+28p9JbcGH\nO5EThACb8FmZnezgSpIXt7yLczpdfvDP4G+308kapbbb8WLzVK5SNMOdyMH2\nLK1LVRWzRlvxnYgYhv12dNyor8psBd/zeH/AFj4Ta0TJDIYKSjjfW9UIfmez\nfA377D+NWlS6uhWc9reBTRlC/uSDx3YJ4f94DaKvxHMtDlabatbmVANcIjrm\niVxf\r\n=X+wc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCR1C3QALqSyVSjVIlfFlkguwmGTF16lTFSxrzsYbCy9wIhAMjwmRiVjbSMJRRkRSoFeOyDWAm+I9D2iTGqtKX2165j"}]},"maintainers":[{"name":"beeplin","email":"beeplin@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/feathers-b_0.1.3_1527828564048_0.66000802982797"},"_hasShrinkwrap":false}},"maintainers":[{"email":"lanbin_blue@163.com","name":"lanbing45"},{"email":"beeplin@gmail.com","name":"beeplin"}],"description":"基于 [express](https://expressjs.com)、[feathersjs](https://feathersjs.com/) 和 [@c42/commons](https://code.aliyun.com/c42/commons) 的后端项目样板","license":"UNLICENSED","readme":"# c42-template-feathers\n\n基于 [express](https://expressjs.com)、[feathersjs](https://feathersjs.com/) 和 [@c42/commons](https://code.aliyun.com/c42/commons) 的后端项目样板\n\n## 安装\n\n按照 [克隆项目](https://code.aliyun.com/alphahr/tasks/tree/master#%E5%85%8B%E9%9A%86%E9%A1%B9%E7%9B%AE) 的提示，克隆本项目到本地，并 copy 到你真正的开发目录。\n\n注意不要 copy /.git 目录，否则会把你真正开发项目的 .git 目录覆盖掉。\n\n如果要使用 linux cp 命令移动项目，注意要加 `-a` 参数，以防遗漏隐藏文件。\n\n克隆并 copy 完毕之后，进入你的开发项目目录，运行 `yarn` 进行初始化安装。\n\n**强烈建议使用 `yarn` 代替 `npm`。**\n\n## 开发\n\n```bash\nyarn dev # 以 src/index.js 为入口，利用 nodemon 实现热加载\n```\n\n## lint\n\n```bash\nnpm run lint # 运行 eslint\n```\n\n每次 git commit 时都会自动先执行 `yarn lint`，所以 commit 一般会花十几秒钟才能完成。\n\n如果 lint 不通过，则拒绝 commit。\n\n## 构建\n\n```bash\nyarn build # 构建并打开构建报告 .build.report.html\n```\n\n为什么后端也需要构建？因为 dev 时用 babel-register 实时转化 es6 语法的效率较低。backpack/webpack 打包后执行效率稍高。\n\n1.  如果开发的是一个完整的后端 app，不应该存在 `src/export.js`。此时构建以 `src/index.js` 为入口。\n1.  如果开发的是一个需要对外发布的 vue 组件，应该存在 `src/export.js`。此时构建以 `src/export.js` 为入口。\n\n**请注意，`src/export.js` 文件是否存在，决定了构建的入口以及其他很多具体行为。`src/export.js` 非常重要！**\n\n打包得到的 bundle 文件位置： `./dist/main.js`。其中并不包含 `node_modules` 里面的模块。\n\n构建完成后相关报告会保存在 `.build.report.html` 中。\n\n### Caveats\n\nbackpack 打包之后 `__dirname`、`__filename` 等和运行环境路径相关的变量的值的含义会发生变化，所以请避免在代码中使用 `__dirname`、`__filename`。\n\n## 生产\n\n```bash\nyarn start\n```\n\n如果开发的是一个模块，则 `yarn start` 命令没有意义。\n\n## 发布\n\n如果开发的是一个需要对外发布的 middleware、service 等模块，由 `src/export.js` 指定哪个文件是要对外发布的模块的入口。发布流程为：\n\n```bash\nnpm version major|minor|patch # 发布前要先根据本次修改的性质升级版本号\nnpm publish # 之前需要先注册并登录 npmjs.com 帐号，并确保正在使用 npmjs.com 官方源。可以使用 nrm 来切换源。\n```\n\n如果开发的是一个完整的 app，则并不存在发布这个概念。**在此情况下，为了防止误操作发布，请设置 `package.json` 中的 `private` 字段为 `true`。**\n\n## 测试\n\n```bash\nyarn unit # 单元测试\nyarn coverage # 单元测试 + 测试覆盖率统计\nyarn test # 运行 eslint + 单元测试 + 测试覆盖率统计\n```\n\n## 配置\n\n后端 feathers 配置文件：`/feathers.config.js`。用法详见 [createApp](https://code.aliyun.com/c42/commons/blob/master/src/utils/createApp.js) 注释及源码。\n\n生产环境部署常常需要通过环境变量来传入配置信息。通过设置特定环境变量，可以在不修改 `feathers.config.js` 源码的前提下动态指定一些配置的值。\n\n比如，假设项目名称（即 package.json 里的 name 取值，把所有 `@` 删除，再把所有 `/` 和 `-` 替换成 `_`，即得到真实项目名称)为 `project_a`，则：\n\n- 在 `~/.bashrc` 中设置环境变量 `export PROJECT_A_PROD_PORT=1234`，即可动态指定生产环境（`yarn start`）下的端口为 `1234`；\n\n- 在 `~/.bashrc` 中设置环境变量 `export PROJECT_A_DEV_MONGODB=\"someurl\"`，即可动态指定开发环境（`yarn dev`）下的 mongodb 地址为 `someurl`；\n\n- 在 `~/.bashrc` 中设置环境变量 `export PROJECT_A_TEST_FAVICON=\"somepath\"`，即可动态指定测试环境（`yarn unit`、`yarn coverage`、`yarn test`）下的 favicon 路径为 `somepath`。\n\n至于具体哪些配置项可由环境变量所动态指定，请见 `feathers.config.js` 源码中包含 `getEnv(...)` 的部分。\n\n## 调试\n\n1.  程序内分级 log\n\n    ```js\n    app.log('info', 'xxxx')\n    app.error('xxxx')\n    app.warn('xxxx')\n    app.info('xxxx')\n    app.debug('xxxx')\n    ```\n\n    log 的具体显示可由 `C42_LOG_LEVEL`, `C42_LOG_PRETTY` and `C42_LOG_TIME` 这三个环境变量控制：\n\n    ```bash\n    C42_LOG_LEVEL=info C42_LOG_PRETTY=true C42_LOG_TIME=true npm start\n    ```\n\n    `C42_LOG_LEVEL=error|warn|info|verbose|debug|silly`： 调用 `app[level]()` 时，只有级别高于 `C42_LOG_LEVEL` 的 log 可以显示。`error` 是最高级，`silly` 是最低级。默认级别为 `silly`，也就是默认所有级别的 log 都显示。\n\n    `C42_LOG_PRETTY=true`：美化显示，但是会占用更多的行数。默认 `false`。\n\n    `C42_LOG_TIME=true`：显示时间。默认 `false`。\n\n1.  自动 log 所有的中间件 request 和钩子 context 信息\n\n    使用环境变量 `C42_LOG_ALL=true`。** 严重影响性能，仅用于调试，禁止用于生产环境！**\n\n    ```bash\n    C42_LOG_ALL=true C42_LOG_TIME=true npm dev\n    ```\n\n    or\n\n    ```bash\n    C42_LOG_ALL=true C42_LOG_LEVEL=debug npm test\n    ```\n\n    也可以只自动 log 所有中间件 request，比如：\n\n    ```bash\n    C42_LOG_ALL_REQUESTS=true npm dev:server\n    ```\n\n    或只自动 log 所有钩子 context，比如：\n\n    ```bash\n    C42_LOG_ALL_CONTEXTS=true npm dev\n    ```\n\n1.  自动进行性能 profiling\n\n    ```bash\n    C42_PROFILER=true npm start\n    ```\n\n    or\n\n    ```bash\n    C42_PROFILER=true C42_PROFILER_STATS=total npm start\n    ```\n\n    此时可以使用 `app.get('profiler').print()` 方法打印 profiler 统计信息。\n\n## 前置知识\n\n- [HTTP on MDN](https://developer.mozilla.org/zh-CN/docs/Web/HTTP)\n\n- [expressjs](https://expressjs.com/)\n\n- [feathersjs](https://docs.feathersjs.com/)\n\n- @c42/commons：查阅 [c42/commons/src](https://code.aliyun.com/c42/commons/tree/master/src) 中的源代码注释，以熟悉 [createApp](https://code.aliyun.com/c42/commons/blob/master/src/utils/createApp.js)、[createHooks](https://code.aliyun.com/c42/commons/blob/master/src/utils/createHooks.js)、[configureMongoService](https://code.aliyun.com/c42/commons/blob/master/src/utils/configureMongoService.js) 以及众多 [hooks](https://code.aliyun.com/c42/commons/tree/master/src/hooks) 的用法。\n","readmeFilename":"README.md"}