{"_id":"@c42/feathers-a","_rev":"6-1083ba18c19f2cd747b6311fb9694b2b","time":{"0.0.0":"2018-05-28T07:45:45.715Z","created":"2018-06-01T04:27:09.587Z","0.1.2":"2018-06-01T04:27:09.848Z","modified":"2022-04-04T21:25:21.760Z","0.1.3":"2018-06-01T04:49:09.009Z"},"name":"@c42/feathers-a","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.2":{"name":"@c42/feathers-a","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","dayjs":"^1.6.5","feathers-authentication-management":"^2.0.0","feathers-hooks-common":"^4.11.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":"8ea8d2ba019d56ce0d8bf2f1266abcc03e96dcf8","description":"基于 [express](https://expressjs.com)、[feathersjs](https://feathersjs.com/) 和 [@c42/commons](https://code.aliyun.com/c42/commons) 的后端项目样板","_id":"@c42/feathers-a@0.1.2","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"beeplin","email":"beeplin@gmail.com"},"dist":{"integrity":"sha512-slHv3yT0QWrO2kVv71HJXp4AzYnWUHMyybP/DHCg7RdWOiHPFVRqkbG/8+8DXC5v18TKDzZRgBHn0WgnfQh3Gw==","shasum":"58c8f04f035bc8ed08c2228e638e2d5dd35254f5","tarball":"https://registry.npmjs.org/@c42/feathers-a/-/feathers-a-0.1.2.tgz","fileCount":5,"unpackedSize":15174,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbEMseCRA9TVsSAnZWagAAAIIP/2FK7kw9fqg/DB8rAwM6\niq2DtcA6zeGYbjodz+YjsxLgTaPco7/oqeAgsiI4w8s1AkG0WvoSXWQFgjFD\nFth+xI00KeJRUJwfxYbalEpkBeIyKTMe6RqGSejWFqTAT6HUsw+r0EZUqs80\nqdDRUOonX1ywzjljiXmLHTCTn0PCuJAtrpnRrtOMz/18BsGSKv+yFnmyDybi\nnO4pU5+08tOtYIZjEva+gqPeHagkd+JmESJepsGEXDRkBKfvs4LjPh4dnYKM\n1ViQOEuBCXQe+Dro9Ovya2T1DR8jJA8qb26YeXAqs8xE9xK/tMygfEWJq/ZN\nbE3YNhZdt9secCLZxQJOddCSRReafgTbHGd0ECHsldO7YfVLqfmBXMz+9T54\nwEmtS4WhLuI1PjgIPLSC5Nxh2AUiVetEo44OdIQtpE9w6pHqumGybThMpViF\nZwuZ/Fn7D+jz/R51w0vAwes/cooKw3nWpBFRdIcf+y4YMDdd9vwXJTj0M48S\nXNiTvQdGUNbRHZrP+lxxbRDRvFZRGD/kuCiLDeBA8i5Jfhk2ikDxRrzAN//S\nyx74n0HSuImJQPDwcATtU6lb6nXPMGURtkKQEj2tK7oHfGnTvzoAtAgIgEea\nigUyvJG10z5w0iUvMAv1dGAfsNw6N8hrPkQu9T5aurXkwzdMPxr3QTQN6IF3\n8ET3\r\n=/R5r\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBrBaM0UEEobWjE1S2E4Lki3q3QNZbowHTx8lUJL4weTAiAFWoGfvV6NkL2yElM1A1iuBYi/OwUxRXk/7hxH9lBGCA=="}]},"maintainers":[{"name":"beeplin","email":"beeplin@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/feathers-a_0.1.2_1527827229683_0.9077587775048839"},"_hasShrinkwrap":false},"0.1.3":{"name":"@c42/feathers-a","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","dayjs":"^1.6.5","feathers-authentication-management":"^2.0.0","feathers-hooks-common":"^4.11.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":"0a8768fc1b603d67b5944885bb29e44c47622d2a","description":"基于 [express](https://expressjs.com)、[feathersjs](https://feathersjs.com/) 和 [@c42/commons](https://code.aliyun.com/c42/commons) 的后端项目样板","_id":"@c42/feathers-a@0.1.3","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"beeplin","email":"beeplin@gmail.com"},"dist":{"integrity":"sha512-cv+Ed8zt3PaeQNS0rlTlJKbgYxmEQDmHm/glTSi1P07hcHm6jr2dj5FVjLQM+tYFbRrjM/RibkaNTZRJKVHEJw==","shasum":"48a695b8b0d33cb17f850e43f368e7cbc78e5691","tarball":"https://registry.npmjs.org/@c42/feathers-a/-/feathers-a-0.1.3.tgz","fileCount":5,"unpackedSize":15150,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbENBGCRA9TVsSAnZWagAA8AIP/15xOokBVbJQyo/nJ3PI\na54+H6p4CnJGf1T+cwYEGPk3yMpKstKSQPwxhCcnhewoNX9q6lWmY1BDoTY8\naXzAS3x2i4UQ8maMwqtw8QNe/H7IpXVRNGVvORYzGKjA/URIWrl9JIpsLEC2\nTfmj+rVl5WgM85UFrhYy2prcR7oRe/l5Q2BGjlzbkW5ut3v8aFSPXDrZ8w+X\nzgi8w3r3lTY1ja15mrQqRebOvZZ800Z08hWWsZpqBEg1lNTw6AY4sxYqv1Yp\n2HbWsSNtz4qXkAP9fpuXQmftyau6neW9Nu9jI5aHT/6Gnh6Hq1INB2V5E9XL\nXWpXmZ/MScF8VtvkFLSf/Wk2rNq04XyJzv/PpuaIUZrhSmIwMBQCkP6NolSH\n8ZC1480ns8vYtOlSfXxSEupos+uZ3JzCNq2KkRY2sP4ZDztL4ygv26mG73RQ\nXkPkrUv74CfMC5L8sPMYIscygA+4OeadUdG/umgiO0mQKTd25sKsQGx45XxI\ntOOyx26YFIK7e81UnyoToP3Jj1dANwfvcqoF7n5KE4n/bKYNatTegHav8V+e\nglwCoVH0e2gKSyceG5R+MgKR66qEgr21/V62WOUc2+E4DrdOC+vr3UyZMoZB\nRaZNuEjHLhCC9d5mpvdMnREcps8Z9V8SfjzQaVtpiRoHhs6VTIa4Pd33Tl3/\nicPa\r\n=6Kpu\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH4wPHGKRrQohXNp+V7uXBuH+jMWU/oqIBXheDNk25+7AiEAmVpdYyHQe72/h6p3ujVBVQEPua2Wl3ARn2kfE9aCoIw="}]},"maintainers":[{"name":"beeplin","email":"beeplin@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/feathers-a_0.1.3_1527828548930_0.10522154188943622"},"_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"}