{"id":15022280,"url":"https://github.com/fritx/koa-captcha-2","last_synced_at":"2025-04-12T12:33:54.276Z","repository":{"id":66094573,"uuid":"99017638","full_name":"fritx/koa-captcha-2","owner":"fritx","description":"Captcha utils for koa 2","archived":false,"fork":false,"pushed_at":"2020-02-08T10:51:16.000Z","size":27,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T07:11:22.782Z","etag":null,"topics":["captcha","koa"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/koa-captcha-2","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/fritx.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":"2017-08-01T15:43:46.000Z","updated_at":"2023-02-26T13:38:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"4ddb9049-c477-49c4-8ede-e5368548cda6","html_url":"https://github.com/fritx/koa-captcha-2","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"9a3070996298bc0e003a625afde6b0cbd4fa146d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fritx%2Fkoa-captcha-2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fritx%2Fkoa-captcha-2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fritx%2Fkoa-captcha-2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fritx%2Fkoa-captcha-2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fritx","download_url":"https://codeload.github.com/fritx/koa-captcha-2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248566706,"owners_count":21125707,"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":["captcha","koa"],"created_at":"2024-09-24T19:57:44.322Z","updated_at":"2025-04-12T12:33:54.256Z","avatar_url":"https://github.com/fritx.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# koa-captcha-2\n\n\u003cimg width=\"300\" src=\"https://raw.githubusercontent.com/fritx/koa-captcha-2/master/pic.png\"\u003e\n\n\u003e Captcha utils for koa 2\n\n*Based on [gd-bmp](https://github.com/zengming00/node-gd-bmp)*\n\n### Install via npm\n\n```plain\nnpm i -S koa-captcha-2\n```\n\n### Draw the image\n\n```js\nlet { drawCaptcha } = require('koa-captcha-2')\n// ...\nrouter.get('/api/captcha', drawCaptcha)\n```\n\n### Verify the code\n\n```js\nlet { verifyCaptcha } = require('koa-captcha-2')\n// ...\nrouter.post('/api/login', ctx =\u003e {\n  if (!verifyCaptcha(ctx)) {\n    ctx.throw(400, 'Captcha not correct')\n  }\n  // ...\n})\n```\n\n### Form markups\n\n```vue\n\u003ctemplate\u003e\n  \u003cel-form-item label=\"Captcha\"\u003e\n    \u003cel-input type=\"text\" v-model=\"model.captcha\" auto-complete=\"off\"\u003e\n      \u003cimg slot=\"append\" :src=\"captchaSrc\" @click=\"reloadCaptcha\"\u003e\n    \u003c/el-input\u003e\n  \u003c/el-form-item\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\nexport default {\n  data () {\n    return {\n      captchaKey: Date.now(),\n      model: {\n        account: 'admin',\n        password: 'admin',\n        captcha: ''\n      }\n    }\n  },\n  computed: {\n    captchaSrc () {\n      return `/api/captcha?key=${this.captchaKey}`\n    }\n  },\n  methods: {\n    reloadCaptcha () {\n      this.captchaKey = Date.now()\n      this.model.captcha = ''\n    },\n    submitForm () {\n      let { captchaKey } = this\n      postApi('/api/login', {\n        ...this.model, captchaKey\n      })\n      .then(() =\u003e {\n        // ...\n      })\n      .catch(err =\u003e {\n        // ...\n        this.reloadCaptcha()\n      })\n    }\n  }\n}\n\u003c/script\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffritx%2Fkoa-captcha-2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffritx%2Fkoa-captcha-2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffritx%2Fkoa-captcha-2/lists"}