{"_id":"egg-userservice","_rev":"1213713","name":"egg-userservice","description":"userservice plugin for egg","dist-tags":{"latest":"2.0.0"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"}],"time":{"modified":"2021-10-13T05:46:54.000Z","created":"2016-05-26T09:09:52.810Z","2.0.0":"2017-11-23T07:18:50.000Z","1.0.0":"2016-08-31T01:46:37.416Z","0.1.0":"2016-07-20T13:51:57.750Z","0.0.1":"2016-05-26T09:09:52.810Z"},"users":{},"author":{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-userservice.git"},"versions":{"2.0.0":{"name":"egg-userservice","version":"2.0.0","description":"userservice plugin for egg","eggPlugin":{"name":"userservice"},"scripts":{"lint":"eslint .","test":"npm run lint -- --fix && egg-bin test","cov":"egg-bin cov","ci":"npm run lint && npm run cov","autod-china":"autod --registry=https://registry.npm.taobao.org","autod":"autod"},"files":["app","config","app.js"],"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-userservice.git"},"keywords":["egg","egg-plugin","eggPlugin","userservice","session"],"author":{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/eggjs/egg-userservice/issues"},"homepage":"https://github.com/eggjs/egg-userservice#readme","dependencies":{},"devDependencies":{"autod":"^3.0.1","egg":"^2.0.0","egg-bin":"^4.3.5","egg-ci":"^1.8.0","egg-mock":"^3.13.1","eslint":"^4.11.0","eslint-config-egg":"^5.1.1"},"engines":{"node":">= 8.0.0"},"ci":{"version":"8, 9"},"gitHead":"0630bc9c60cc6a6495aa3466cf1d563ec6a217f8","_id":"egg-userservice@2.0.0","_npmVersion":"5.5.1","_nodeVersion":"8.4.0","_npmUser":{"name":"dead_horse","email":"dead_horse@qq.com"},"dist":{"shasum":"602bb34907593a807e22f6172e143d774891361c","size":2378,"noattachment":false,"key":"/egg-userservice/-/egg-userservice-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-userservice/download/egg-userservice-2.0.0.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg-userservice-2.0.0.tgz_1511421529782_0.19973983708769083"},"directories":{},"publish_time":1511421530000,"_hasShrinkwrap":false,"_cnpm_publish_time":1511421530000},"1.0.0":{"name":"egg-userservice","version":"1.0.0","description":"userservice plugin for egg","eggPlugin":{"name":"userservice"},"scripts":{"lint":"eslint . --fix","test":"egg-bin test","cov":"egg-bin cov","ci":"npm run lint && npm run cov","autod-china":"autod --registry=https://registry.npm.taobao.org","autod":"autod"},"files":["app","config","app.js"],"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-userservice.git"},"keywords":["egg","userservice","session"],"author":{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/eggjs/egg-userservice/issues"},"homepage":"https://github.com/eggjs/egg-userservice#readme","dependencies":{},"devDependencies":{"autod":"^2.7.1","egg":"^0.1.2","egg-bin":"^1.3.0","egg-ci":"^1.0.2","egg-mock":"^0.0.4","eslint":"^3.4.0","eslint-config-egg":"^3.1.0","supertest":"^2.0.0"},"engines":{"node":">= 4.0.0"},"ci":{"version":"4, 6"},"gitHead":"88bd5228a68ce911ebabfdec919cc9466f96ec86","_id":"egg-userservice@1.0.0","_shasum":"c649654ffad9cd443709ae19e976310fbd8d5d7b","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.4.0","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"dist":{"shasum":"c649654ffad9cd443709ae19e976310fbd8d5d7b","size":2000,"noattachment":false,"key":"/egg-userservice/-/egg-userservice-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-userservice/download/egg-userservice-1.0.0.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/egg-userservice-1.0.0.tgz_1472607995780_0.7769430389162153"},"directories":{},"publish_time":1472607997416,"_cnpm_publish_time":1472607997416,"_hasShrinkwrap":false},"0.1.0":{"name":"egg-userservice","version":"0.1.0","description":"userservice plugin for egg","eggPlugin":{"name":"userservice"},"main":"index.js","scripts":{"lint":"eslint . --fix","test":"egg-bin test","autod":"autod"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-userservice.git"},"keywords":["egg","userservice","session"],"author":{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/eggjs/egg-userservice/issues"},"homepage":"https://github.com/eggjs/egg-userservice#readme","dependencies":{},"devDependencies":{"autod":"^2.6.1","egg-bin":"^1.0.1","egg-ci":"^1.0.2","eslint":"^3.0.1","eslint-config-egg":"^3.1.0","should":"^9.0.2","supertest":"^1.2.0"},"engines":{"node":">= 4.0.0"},"ci":{"version":"4, 6"},"gitHead":"3d69819a71b97c70fefc191536b62441ed1bd03e","_id":"egg-userservice@0.1.0","_shasum":"dc85f6335b920fcb1b861bcfec3ad34906610f28","_from":".","_npmVersion":"2.14.20","_nodeVersion":"4.4.1","_npmUser":{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"}],"dist":{"shasum":"dc85f6335b920fcb1b861bcfec3ad34906610f28","size":2322,"noattachment":false,"key":"/egg-userservice/-/egg-userservice-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-userservice/download/egg-userservice-0.1.0.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/egg-userservice-0.1.0.tgz_1469022716381_0.5640047446358949"},"directories":{},"publish_time":1469022717750,"_cnpm_publish_time":1469022717750,"_hasShrinkwrap":false},"0.0.1":{"name":"egg-userservice","version":"0.0.1","description":"egg plugin <egg-userservice>","keywords":["egg","eggjs","egg-plugin"],"homepage":"https://github.com/eggjs/egg-userservice","license":"MIT","author":{"name":"eggjs"},"contributors":[{"name":"TZ","email":"atian25@qq.com"},{"name":"popomore","email":"sakura9515@gmail.com"},{"name":"fengmk2","email":"m@fengmk2.com"},{"name":"dead-horse","email":"heyiyu.deadhorse@gmail.com"}],"repository":{"type":"git","url":"git+ssh://git@github.com/eggjs/egg-userservice.git"},"bugs":{"url":"https://github.com/eggjs/egg-userservice/issues"},"_id":"egg-userservice@0.0.1","scripts":{},"_shasum":"6ed959de9d14430f5a02882b5ad52eee546b84fe","_from":".","_npmVersion":"2.15.1","_nodeVersion":"4.4.4","_npmUser":{"name":"atian25","email":"atian25@qq.com"},"dist":{"shasum":"6ed959de9d14430f5a02882b5ad52eee546b84fe","size":432,"noattachment":false,"key":"/egg-userservice/-/egg-userservice-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-userservice/download/egg-userservice-0.0.1.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"popomore","email":""},{"name":"shaoshuai0102","email":"shaoshuai0102@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/egg-userservice-0.0.1.tgz_1464253790090_0.6154596493579447"},"directories":{},"publish_time":1464253792810,"_cnpm_publish_time":1464253792810,"_hasShrinkwrap":false}},"readme":"# egg-userservice\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/egg-userservice.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/egg-userservice\n[travis-image]: https://img.shields.io/travis/eggjs/egg-userservice.svg?style=flat-square\n[travis-url]: https://travis-ci.org/eggjs/egg-userservice\n[codecov-image]: https://codecov.io/github/eggjs/egg-userservice/coverage.svg?branch=master\n[codecov-url]: https://codecov.io/github/eggjs/egg-userservice?branch=master\n[david-image]: https://img.shields.io/david/eggjs/egg-userservice.svg?style=flat-square\n[david-url]: https://david-dm.org/eggjs/egg-userservice\n[snyk-image]: https://snyk.io/test/npm/egg-userservice/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/egg-userservice\n[download-image]: https://img.shields.io/npm/dm/egg-userservice.svg?style=flat-square\n[download-url]: https://npmjs.org/package/egg-userservice\n\nUserservice plugin for Egg.\n\nThis plugin provides a convention of how your application accesses current user data.\n\nYou can define the way to retrieve current user data according to the exact user\nstrategy your application is using.\n\nUser data may be stored in:\n\n- cookie\n- database\n- some kind of service\n- cache system(eg. redis)\n- etc..\n\nWhatever kind of strategy you are using, just configurate it with this plugin, and keep\nthe way of accessing user data unchanged, for a better understanding across the entire whole\negg community.\n\n\n---\n\n## Install\n\n```bash\n$ npm i egg-userservice\n```\n\n## Usage\n\n- `ctx.user`: current user data\n- `ctx.userId`: the user id of current user\n- `app.config.userservice.service.getUser(ctx)`:  \n- `app.config.userservice.service.getUserId(ctx)`:\n\n\n\n## Configuration\n\nAdd your userservice configurations to `config/config.default.js`\n\n```js\nexports.userservice = {\n  service: {\n    async getUser(ctx) {\n      // Retrieve your user data from cookie, redis, db, whatever\n      // For common web applications using cookie, you may get session id with ctx.cookies\n    },\n\n    getUserId(ctx) {\n      // The way to get userId\n      // eg. return ctx.user.userId\n    }\n  }\n}\n```\n\n\n\n\n\n## For complicated applications\n\nThe way your application retrieving user data can be complicated, it may be very weird\nif configurating it in a config file.\n\nA standalone plugin of your own can be a better solution. In this kind of situation,\n__the way of accessing data with `ctx.user` and `ctx.userId` should be left unchanged__.\n\n## License\n\n[MIT](LICENSE)\n","_attachments":{},"homepage":"https://github.com/eggjs/egg-userservice#readme","bugs":{"url":"https://github.com/eggjs/egg-userservice/issues"},"license":"MIT"}