{"id":25944830,"url":"https://github.com/raoul1996/egg-vote","last_synced_at":"2025-03-04T08:19:22.434Z","repository":{"id":50944232,"uuid":"121851119","full_name":"Raoul1996/egg-vote","owner":"Raoul1996","description":"koa-vote reconfiguration","archived":false,"fork":false,"pushed_at":"2024-06-18T03:19:03.000Z","size":107,"stargazers_count":7,"open_issues_count":8,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-18T04:48:47.614Z","etag":null,"topics":["bithound","codecov","codecoverage","cookie","egg","egg-cors","egg-jwt","egg-mail","egg-vote","fs","node","qiniu","qiniu-storage-bucket","travis-ci","xlsx"],"latest_commit_sha":null,"homepage":"http://egg.raoul1996.cn","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Raoul1996.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-17T11:50:32.000Z","updated_at":"2024-06-18T04:48:58.178Z","dependencies_parsed_at":"2024-06-18T04:48:52.227Z","dependency_job_id":"1511280f-7974-459a-9cb0-14714c3412d1","html_url":"https://github.com/Raoul1996/egg-vote","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raoul1996%2Fegg-vote","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raoul1996%2Fegg-vote/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raoul1996%2Fegg-vote/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Raoul1996%2Fegg-vote/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Raoul1996","download_url":"https://codeload.github.com/Raoul1996/egg-vote/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241809532,"owners_count":20023787,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bithound","codecov","codecoverage","cookie","egg","egg-cors","egg-jwt","egg-mail","egg-vote","fs","node","qiniu","qiniu-storage-bucket","travis-ci","xlsx"],"created_at":"2025-03-04T08:19:20.929Z","updated_at":"2025-03-04T08:19:22.418Z","avatar_url":"https://github.com/Raoul1996.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# egg-vote\n[![Build Status](https://travis-ci.org/Raoul1996/egg-vote.svg?branch=master)](https://travis-ci.org/Raoul1996/egg-vote)\n[![codecov](https://codecov.io/gh/Raoul1996/egg-vote/branch/master/graph/badge.svg)](https://codecov.io/gh/Raoul1996/egg-vote)\n[![bitHound Overall Score](https://www.bithound.io/github/Raoul1996/egg-vote/badges/score.svg)](https://www.bithound.io/github/Raoul1996/egg-vote)\n[![bitHound Dependencies](https://www.bithound.io/github/Raoul1996/egg-vote/badges/dependencies.svg)](https://www.bithound.io/github/Raoul1996/egg-vote/master/dependencies/npm)\n[![bitHound Dev Dependencies](https://www.bithound.io/github/Raoul1996/egg-vote/badges/devDependencies.svg)](https://www.bithound.io/github/Raoul1996/egg-vote/master/dependencies/npm)\n[![bitHound Code](https://www.bithound.io/github/Raoul1996/egg-vote/badges/code.svg)](https://www.bithound.io/github/Raoul1996/egg-vote)\n[![Maintainability](https://api.codeclimate.com/v1/badges/8d31fa28164dc4a47fce/maintainability)](https://codeclimate.com/github/Raoul1996/egg-vote/maintainability)\n\n\u003e koa-vote 使用 egg 重构版本\n\n## 接口文档\n- [POSTMAN](https://documenter.getpostman.com/view/3083800/egg-vote/RVfyAp5B)\n\n## 开发日志\n### 20180216 初一\n- egg 跨域问题解决办法\n    1. 在 [plugin.js](config/plugin.js) 中开启 `egg-cors` 插件\n    2. 在 `config.${env}.js` 中配置白名单，注意域名不需要添加 http \u0026\u0026 https 前缀\n    3. 有关跨域和同源策略的文章网上多的去了\n- ~~egg-jwt 插件的初步使用~~\n    1. 参考项目：[eggjs-demo](https://github.com/glh1991/eggjs-demo)\n    2. 参考之前我做的 jwt 校验的项目 [koa-vote](https://github.com/Raoul1996/koa-vote.git)\n    2. jwt 校验的基础知识和好处网上同样一大堆，这里可以贴一下之前我翻译的一篇文章：[[译] Angular 安全 —— 使用 JSON 网络令牌（JWT）的身份认证：完全指南](https://juejin.im/post/5a64267c518825734e3e5c22)，虽然是 Angular + Express，但是关于 JWT 的知识是通用的\n    3. 在 [plugin.js](config/plugin.js) 中开启 `egg-jwt` 插件或者其它插件， egg 玩的人不是特别多，所以很多问题可以强迫自己通过看文档啥的自己解决，而且官方给的文档和 demo 都很用心，很棒\n    4. 目前是自己在 middleware 中放了一个[中间件](middleware/auth.js)\n    5. 尝试将 [auth](middleware/auth.js) 中间件放到 `config.${env}.js` 中，但是在中间件抛出异常之后会影响 vue-ssr 的正常进行，所以暂时没有全局应用，在后期的实现中会增加 match 和 ignore 的配置\n    6. 将 jwt 解密之后的内容挂载到 `ctx.state.user` 上，方便对用户进行标识，思路源于 koa-jwt 的实现\n    7. 一定不要使用 jwt 存放敏感信息，原因可以查看我翻译的文章\n- 使用 egg-jwt 文档中指定的方式进行使用\n### 20180219 初四\n- login register 接口重构\n\n### 20180220 初五\n- 熟悉框架基本完成\n- 完成 jwt 部分，并使用 jwt 记录用户 id，详见 `/user` 路由\n- 完成图形验证码部分，使用 ccap 并结合 session 进行使用\n- 使用 redis 拓展 session，但是目前只有 captcha 部分使用到了 session，所以没有绝对的必要使用 redis， 仅仅只是为了学习\n- 完成文件上传功能，并返回静态文件地址\n\n### 20180221 初六\n- 多个文件上传功能完成，并按照用户 id 进行独立存储\n- 多文件上传至七牛并返回外链地址\n- 删除本地public下的文件，并自定义异常处理中间件\n\n### 20180222 初七\n- 密码忘记于重置接口\n- 删除文件并进行数据库同步记录\n- 获取七牛提供的文件信息\n\n### 20180223 初八\n- 发送验证邮件并激活\n- 向 [egg-mail](https://github.com/zhouzhi3859/egg-mail) plugin 发 pr\n- [package.json](package.json) 中指定从 github 拉取 egg-mail 依赖\n\n### 20180224 初九\n- 封装 [egg-captcha](https://github.com/raoul1996/egg-captcha) 插件\n- 封装 [egg-qiniu-upload](https://github.com/raoul1996/egg-qiniu-upload) 插件\n\n### 20180225 初十\n- 创建投票相关接口\n- 获取投票列表，删除投票\n\n### 20180226 十一\n- 创建投票，提交投票\n\n### 20180227 十二\n- 创建 xlsx 解析功能\n- 封装 [egg-xlsx](https://github.com/Raoul1996/egg-xlsx.git) plugin\n\n### 20180304 - 20180305\n- 忙活开学的一堆事情\n- 向 [egg-cors](https://github.com/eggjs/egg-cors.git) 提交 [PR](https://github.com/eggjs/egg-cors/pull/10)\n- egg-cors 跨域问题解决方案(不携带 cookie)：\n    ```js\n    // {app_root}/config/plugin.js\n    exports.cors = {\n      enable: true,\n      package: 'egg-cors',\n    };\n    ```\n    ```js\n    // {app_root}/config/config.default.js\n    exports.cors = {}\n    exports.security = {\n      domainWhiteList: [ 'http://localhost:8080' ]\n    };\n    ```\n- egg-cors 跨域问题解决方案(在使用 session 的时候需要携带 cookie)\n    ```js\n    // {app_root}/config/plugin.js\n    exports.cors = {\n      enable: true,\n      package: 'egg-cors',\n    };\n    ```\n    ```js\n    // {app_root}/config/config.default.js\n      exports.cors = {\n        credentials: true\n      }\n    exports.security = {\n      csrf: {\n          enable: false\n        },\n      domainWhiteList: [ 'http://localhost:8080' ]\n    };\n    ```\n### 20180406\n- 开始增加单元测试，已经测试完成 `/user` `/login` `/register` `/forget` `/update` 控制器的测试\n\n### 20180407\n\n- `UserController` 测试覆盖率 `100%`\n- 测试 `VoteController`\n\n### 20180506\n\n- 根据 `ctx.header['user-agent']` 确定来访者身份，如果不是浏览器、curl、postman、搜索引擎爬虫的话，就拒绝处理\n- 好像没做点啥，其实是想做 prerender 的。。。。\n\n### 20180507\n\n- 做了一下 prerender 中间件，对搜索引擎爬虫的请求使用无头浏览器渲染之后再返回。但是由于无头浏览器对性能影响太严重，所以设置了缓存、限制了请求频率\n- 具体参考[中间件](app/middleware/prerender.js)\n### npm scripts\n\n- Use `npm run lint` to check code style.\n- Use `npm test` to run unit test.\n- Use `npm run autod` to auto detect dependencies upgrade, see [autod](https://www.npmjs.com/package/autod) for more detail.\n\n\n[egg]: https://eggjs.org","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraoul1996%2Fegg-vote","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraoul1996%2Fegg-vote","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraoul1996%2Fegg-vote/lists"}